We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
TypeError: Only messages, members or roles may be passed
https://sentry.io/will-tekulve/bot-development/issues/419244737/

```
TypeError: Only messages, members or roles may be passed
  File "redbot/core/utils/mod.py", line 132, in is_mod_or_superior
    raise TypeError('Only messages, members or roles may be passed')

Exception in on_message
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `redbot/core/utils/mod.py`
Content:
```
1 import asyncio
2 from datetime import timedelta
3 from typing import List, Iterable, Union
4 
5 import discord
6 
7 from redbot.core import Config
8 from redbot.core.bot import Red
9 
10 
11 async def mass_purge(messages: List[discord.Message],
12                      channel: discord.TextChannel):
13     """Bulk delete messages from a channel.
14 
15     If more than 100 messages are supplied, the bot will delete 100 messages at
16     a time, sleeping between each action.
17 
18     Note
19     ----
20     Messages must not be older than 14 days, and the bot must not be a user
21     account.
22 
23     Parameters
24     ----------
25     messages : `list` of `discord.Message`
26         The messages to bulk delete.
27     channel : discord.TextChannel
28         The channel to delete messages from.
29 
30     Raises
31     ------
32     discord.Forbidden
33         You do not have proper permissions to delete the messages or you’re not
34         using a bot account.
35     discord.HTTPException
36         Deleting the messages failed.
37 
38     """
39     while messages:
40         if len(messages) > 1:
41             await channel.delete_messages(messages[:100])
42             messages = messages[100:]
43         else:
44             await messages[0].delete()
45             messages = []
46         await asyncio.sleep(1.5)
47 
48 
49 async def slow_deletion(messages: Iterable[discord.Message]):
50     """Delete a list of messages one at a time.
51 
52     Any exceptions raised when trying to delete the message will be silenced.
53 
54     Parameters
55     ----------
56     messages : `iterable` of `discord.Message`
57         The messages to delete.
58 
59     """
60     for message in messages:
61         try:
62             await message.delete()
63         except discord.HTTPException:
64             pass
65 
66 
67 def get_audit_reason(author: discord.Member, reason: str = None):
68     """Construct a reason to appear in the audit log.
69 
70     Parameters
71     ----------
72     author : discord.Member
73         The author behind the audit log action.
74     reason : str
75         The reason behidn the audit log action.
76 
77     Returns
78     -------
79     str
80         The formatted audit log reason.
81 
82     """
83     return \
84         "Action requested by {} (ID {}). Reason: {}".format(author, author.id, reason) if reason else \
85         "Action requested by {} (ID {}).".format(author, author.id)
86 
87 
88 async def is_allowed_by_hierarchy(bot: Red,
89                                   settings: Config,
90                                   guild: discord.Guild,
91                                   mod: discord.Member,
92                                   user: discord.Member):
93     if not await settings.guild(guild).respect_hierarchy():
94         return True
95     is_special = mod == guild.owner or await bot.is_owner(mod)
96     return mod.top_role.position > user.top_role.position or is_special
97 
98 
99 async def is_mod_or_superior(
100     bot: Red, obj: Union[discord.Message, discord.Member, discord.Role]):
101     """Check if an object has mod or superior permissions.
102 
103     If a message is passed, its author's permissions are checked. If a role is
104     passed, it simply checks if it is one of either the admin or mod roles.
105 
106     Parameters
107     ----------
108     bot : redbot.core.bot.Red
109         The bot object.
110     obj : `discord.Message` or `discord.Member` or `discord.Role`
111         The object to check permissions for.
112 
113     Returns
114     -------
115     bool
116         :code:`True` if the object has mod permissions.
117 
118     Raises
119     ------
120     TypeError
121         If the wrong type of ``obj`` was passed.
122 
123     """
124     user = None
125     if isinstance(obj, discord.Message):
126         user = obj.author
127     elif isinstance(obj, discord.Member):
128         user = obj
129     elif isinstance(obj, discord.Role):
130         pass
131     else:
132         raise TypeError('Only messages, members or roles may be passed')
133 
134     server = obj.guild
135     admin_role_id = await bot.db.guild(server).admin_role()
136     mod_role_id = await bot.db.guild(server).mod_role()
137 
138     if isinstance(obj, discord.Role):
139         return obj.id in [admin_role_id, mod_role_id]
140     mod_roles = [r for r in server.roles if r.id == mod_role_id]
141     mod_role = mod_roles[0] if len(mod_roles) > 0 else None
142     admin_roles = [r for r in server.roles if r.id == admin_role_id]
143     admin_role = admin_roles[0] if len(admin_roles) > 0 else None
144 
145     if user and user == await bot.is_owner(user):
146         return True
147     elif admin_role and discord.utils.get(user.roles, name=admin_role):
148         return True
149     elif mod_role and discord.utils.get(user.roles, name=mod_role):
150         return True
151     else:
152         return False
153 
154 
155 def strfdelta(delta: timedelta):
156     """Format a timedelta object to a message with time units.
157 
158     Parameters
159     ----------
160     delta : datetime.timedelta
161         The duration to parse.
162 
163     Returns
164     -------
165     str
166         A message representing the timedelta with units.
167 
168     """
169     s = []
170     if delta.days:
171         ds = '%i day' % delta.days
172         if delta.days > 1:
173             ds += 's'
174         s.append(ds)
175     hrs, rem = divmod(delta.seconds, 60*60)
176     if hrs:
177         hs = '%i hr' % hrs
178         if hrs > 1:
179             hs += 's'
180         s.append(hs)
181     mins, secs = divmod(rem, 60)
182     if mins:
183         s.append('%i min' % mins)
184     if secs:
185         s.append('%i sec' % secs)
186     return ' '.join(s)
187 
188 
189 async def is_admin_or_superior(
190     bot: Red, obj: Union[discord.Message, discord.Member, discord.Role]):
191     """Same as `is_mod_or_superior` except for admin permissions.
192 
193     If a message is passed, its author's permissions are checked. If a role is
194     passed, it simply checks if it is the admin role.
195 
196     Parameters
197     ----------
198     bot : redbot.core.bot.Red
199         The bot object.
200     obj : `discord.Message` or `discord.Member` or `discord.Role`
201         The object to check permissions for.
202 
203     Returns
204     -------
205     bool
206         :code:`True` if the object has admin permissions.
207 
208     Raises
209     ------
210     TypeError
211         If the wrong type of ``obj`` was passed.
212 
213     """
214     user = None
215     if isinstance(obj, discord.Message):
216         user = obj.author
217     elif isinstance(obj, discord.Member):
218         user = obj
219     elif isinstance(obj, discord.Role):
220         pass
221     else:
222         raise TypeError('Only messages, members or roles may be passed')
223 
224     server = obj.guild
225     admin_role_id = await bot.db.guild(server).admin_role()
226 
227     if isinstance(obj, discord.Role):
228         return obj.id == admin_role_id
229     admin_roles = [r for r in server.roles if r.id == admin_role_id]
230     admin_role = admin_roles[0] if len(admin_roles) > 0 else None
231 
232     if user and await bot.is_owner(user):
233         return True
234     elif admin_roles and discord.utils.get(user.roles, name=admin_role):
235         return True
236     else:
237         return False
238
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/redbot/core/utils/mod.py b/redbot/core/utils/mod.py
--- a/redbot/core/utils/mod.py
+++ b/redbot/core/utils/mod.py
@@ -124,7 +124,7 @@
     user = None
     if isinstance(obj, discord.Message):
         user = obj.author
-    elif isinstance(obj, discord.Member):
+    elif isinstance(obj, discord.Member) or isinstance(obj, discord.User):
         user = obj
     elif isinstance(obj, discord.Role):
         pass
@@ -214,7 +214,7 @@
     user = None
     if isinstance(obj, discord.Message):
         user = obj.author
-    elif isinstance(obj, discord.Member):
+    elif isinstance(obj, discord.Member) or isinstance(obj, discord.User):
         user = obj
     elif isinstance(obj, discord.Role):
         pass

{"golden_diff": "diff --git a/redbot/core/utils/mod.py b/redbot/core/utils/mod.py\n--- a/redbot/core/utils/mod.py\n+++ b/redbot/core/utils/mod.py\n@@ -124,7 +124,7 @@\n     user = None\n     if isinstance(obj, discord.Message):\n         user = obj.author\n-    elif isinstance(obj, discord.Member):\n+    elif isinstance(obj, discord.Member) or isinstance(obj, discord.User):\n         user = obj\n     elif isinstance(obj, discord.Role):\n         pass\n@@ -214,7 +214,7 @@\n     user = None\n     if isinstance(obj, discord.Message):\n         user = obj.author\n-    elif isinstance(obj, discord.Member):\n+    elif isinstance(obj, discord.Member) or isinstance(obj, discord.User):\n         user = obj\n     elif isinstance(obj, discord.Role):\n         pass\n", "issue": "TypeError: Only messages, members or roles may be passed\nhttps://sentry.io/will-tekulve/bot-development/issues/419244737/\n\n```\nTypeError: Only messages, members or roles may be passed\n  File \"redbot/core/utils/mod.py\", line 132, in is_mod_or_superior\n    raise TypeError('Only messages, members or roles may be passed')\n\nException in on_message\n```\n", "before_files": [{"content": "import asyncio\nfrom datetime import timedelta\nfrom typing import List, Iterable, Union\n\nimport discord\n\nfrom redbot.core import Config\nfrom redbot.core.bot import Red\n\n\nasync def mass_purge(messages: List[discord.Message],\n                     channel: discord.TextChannel):\n    \"\"\"Bulk delete messages from a channel.\n\n    If more than 100 messages are supplied, the bot will delete 100 messages at\n    a time, sleeping between each action.\n\n    Note\n    ----\n    Messages must not be older than 14 days, and the bot must not be a user\n    account.\n\n    Parameters\n    ----------\n    messages : `list` of `discord.Message`\n        The messages to bulk delete.\n    channel : discord.TextChannel\n        The channel to delete messages from.\n\n    Raises\n    ------\n    discord.Forbidden\n        You do not have proper permissions to delete the messages or you\u2019re not\n        using a bot account.\n    discord.HTTPException\n        Deleting the messages failed.\n\n    \"\"\"\n    while messages:\n        if len(messages) > 1:\n            await channel.delete_messages(messages[:100])\n            messages = messages[100:]\n        else:\n            await messages[0].delete()\n            messages = []\n        await asyncio.sleep(1.5)\n\n\nasync def slow_deletion(messages: Iterable[discord.Message]):\n    \"\"\"Delete a list of messages one at a time.\n\n    Any exceptions raised when trying to delete the message will be silenced.\n\n    Parameters\n    ----------\n    messages : `iterable` of `discord.Message`\n        The messages to delete.\n\n    \"\"\"\n    for message in messages:\n        try:\n            await message.delete()\n        except discord.HTTPException:\n            pass\n\n\ndef get_audit_reason(author: discord.Member, reason: str = None):\n    \"\"\"Construct a reason to appear in the audit log.\n\n    Parameters\n    ----------\n    author : discord.Member\n        The author behind the audit log action.\n    reason : str\n        The reason behidn the audit log action.\n\n    Returns\n    -------\n    str\n        The formatted audit log reason.\n\n    \"\"\"\n    return \\\n        \"Action requested by {} (ID {}). Reason: {}\".format(author, author.id, reason) if reason else \\\n        \"Action requested by {} (ID {}).\".format(author, author.id)\n\n\nasync def is_allowed_by_hierarchy(bot: Red,\n                                  settings: Config,\n                                  guild: discord.Guild,\n                                  mod: discord.Member,\n                                  user: discord.Member):\n    if not await settings.guild(guild).respect_hierarchy():\n        return True\n    is_special = mod == guild.owner or await bot.is_owner(mod)\n    return mod.top_role.position > user.top_role.position or is_special\n\n\nasync def is_mod_or_superior(\n    bot: Red, obj: Union[discord.Message, discord.Member, discord.Role]):\n    \"\"\"Check if an object has mod or superior permissions.\n\n    If a message is passed, its author's permissions are checked. If a role is\n    passed, it simply checks if it is one of either the admin or mod roles.\n\n    Parameters\n    ----------\n    bot : redbot.core.bot.Red\n        The bot object.\n    obj : `discord.Message` or `discord.Member` or `discord.Role`\n        The object to check permissions for.\n\n    Returns\n    -------\n    bool\n        :code:`True` if the object has mod permissions.\n\n    Raises\n    ------\n    TypeError\n        If the wrong type of ``obj`` was passed.\n\n    \"\"\"\n    user = None\n    if isinstance(obj, discord.Message):\n        user = obj.author\n    elif isinstance(obj, discord.Member):\n        user = obj\n    elif isinstance(obj, discord.Role):\n        pass\n    else:\n        raise TypeError('Only messages, members or roles may be passed')\n\n    server = obj.guild\n    admin_role_id = await bot.db.guild(server).admin_role()\n    mod_role_id = await bot.db.guild(server).mod_role()\n\n    if isinstance(obj, discord.Role):\n        return obj.id in [admin_role_id, mod_role_id]\n    mod_roles = [r for r in server.roles if r.id == mod_role_id]\n    mod_role = mod_roles[0] if len(mod_roles) > 0 else None\n    admin_roles = [r for r in server.roles if r.id == admin_role_id]\n    admin_role = admin_roles[0] if len(admin_roles) > 0 else None\n\n    if user and user == await bot.is_owner(user):\n        return True\n    elif admin_role and discord.utils.get(user.roles, name=admin_role):\n        return True\n    elif mod_role and discord.utils.get(user.roles, name=mod_role):\n        return True\n    else:\n        return False\n\n\ndef strfdelta(delta: timedelta):\n    \"\"\"Format a timedelta object to a message with time units.\n\n    Parameters\n    ----------\n    delta : datetime.timedelta\n        The duration to parse.\n\n    Returns\n    -------\n    str\n        A message representing the timedelta with units.\n\n    \"\"\"\n    s = []\n    if delta.days:\n        ds = '%i day' % delta.days\n        if delta.days > 1:\n            ds += 's'\n        s.append(ds)\n    hrs, rem = divmod(delta.seconds, 60*60)\n    if hrs:\n        hs = '%i hr' % hrs\n        if hrs > 1:\n            hs += 's'\n        s.append(hs)\n    mins, secs = divmod(rem, 60)\n    if mins:\n        s.append('%i min' % mins)\n    if secs:\n        s.append('%i sec' % secs)\n    return ' '.join(s)\n\n\nasync def is_admin_or_superior(\n    bot: Red, obj: Union[discord.Message, discord.Member, discord.Role]):\n    \"\"\"Same as `is_mod_or_superior` except for admin permissions.\n\n    If a message is passed, its author's permissions are checked. If a role is\n    passed, it simply checks if it is the admin role.\n\n    Parameters\n    ----------\n    bot : redbot.core.bot.Red\n        The bot object.\n    obj : `discord.Message` or `discord.Member` or `discord.Role`\n        The object to check permissions for.\n\n    Returns\n    -------\n    bool\n        :code:`True` if the object has admin permissions.\n\n    Raises\n    ------\n    TypeError\n        If the wrong type of ``obj`` was passed.\n\n    \"\"\"\n    user = None\n    if isinstance(obj, discord.Message):\n        user = obj.author\n    elif isinstance(obj, discord.Member):\n        user = obj\n    elif isinstance(obj, discord.Role):\n        pass\n    else:\n        raise TypeError('Only messages, members or roles may be passed')\n\n    server = obj.guild\n    admin_role_id = await bot.db.guild(server).admin_role()\n\n    if isinstance(obj, discord.Role):\n        return obj.id == admin_role_id\n    admin_roles = [r for r in server.roles if r.id == admin_role_id]\n    admin_role = admin_roles[0] if len(admin_roles) > 0 else None\n\n    if user and await bot.is_owner(user):\n        return True\n    elif admin_roles and discord.utils.get(user.roles, name=admin_role):\n        return True\n    else:\n        return False\n", "path": "redbot/core/utils/mod.py"}], "after_files": [{"content": "import asyncio\nfrom datetime import timedelta\nfrom typing import List, Iterable, Union\n\nimport discord\n\nfrom redbot.core import Config\nfrom redbot.core.bot import Red\n\n\nasync def mass_purge(messages: List[discord.Message],\n                     channel: discord.TextChannel):\n    \"\"\"Bulk delete messages from a channel.\n\n    If more than 100 messages are supplied, the bot will delete 100 messages at\n    a time, sleeping between each action.\n\n    Note\n    ----\n    Messages must not be older than 14 days, and the bot must not be a user\n    account.\n\n    Parameters\n    ----------\n    messages : `list` of `discord.Message`\n        The messages to bulk delete.\n    channel : discord.TextChannel\n        The channel to delete messages from.\n\n    Raises\n    ------\n    discord.Forbidden\n        You do not have proper permissions to delete the messages or you\u2019re not\n        using a bot account.\n    discord.HTTPException\n        Deleting the messages failed.\n\n    \"\"\"\n    while messages:\n        if len(messages) > 1:\n            await channel.delete_messages(messages[:100])\n            messages = messages[100:]\n        else:\n            await messages[0].delete()\n            messages = []\n        await asyncio.sleep(1.5)\n\n\nasync def slow_deletion(messages: Iterable[discord.Message]):\n    \"\"\"Delete a list of messages one at a time.\n\n    Any exceptions raised when trying to delete the message will be silenced.\n\n    Parameters\n    ----------\n    messages : `iterable` of `discord.Message`\n        The messages to delete.\n\n    \"\"\"\n    for message in messages:\n        try:\n            await message.delete()\n        except discord.HTTPException:\n            pass\n\n\ndef get_audit_reason(author: discord.Member, reason: str = None):\n    \"\"\"Construct a reason to appear in the audit log.\n\n    Parameters\n    ----------\n    author : discord.Member\n        The author behind the audit log action.\n    reason : str\n        The reason behidn the audit log action.\n\n    Returns\n    -------\n    str\n        The formatted audit log reason.\n\n    \"\"\"\n    return \\\n        \"Action requested by {} (ID {}). Reason: {}\".format(author, author.id, reason) if reason else \\\n        \"Action requested by {} (ID {}).\".format(author, author.id)\n\n\nasync def is_allowed_by_hierarchy(bot: Red,\n                                  settings: Config,\n                                  guild: discord.Guild,\n                                  mod: discord.Member,\n                                  user: discord.Member):\n    if not await settings.guild(guild).respect_hierarchy():\n        return True\n    is_special = mod == guild.owner or await bot.is_owner(mod)\n    return mod.top_role.position > user.top_role.position or is_special\n\n\nasync def is_mod_or_superior(\n    bot: Red, obj: Union[discord.Message, discord.Member, discord.Role]):\n    \"\"\"Check if an object has mod or superior permissions.\n\n    If a message is passed, its author's permissions are checked. If a role is\n    passed, it simply checks if it is one of either the admin or mod roles.\n\n    Parameters\n    ----------\n    bot : redbot.core.bot.Red\n        The bot object.\n    obj : `discord.Message` or `discord.Member` or `discord.Role`\n        The object to check permissions for.\n\n    Returns\n    -------\n    bool\n        :code:`True` if the object has mod permissions.\n\n    Raises\n    ------\n    TypeError\n        If the wrong type of ``obj`` was passed.\n\n    \"\"\"\n    user = None\n    if isinstance(obj, discord.Message):\n        user = obj.author\n    elif isinstance(obj, discord.Member) or isinstance(obj, discord.User):\n        user = obj\n    elif isinstance(obj, discord.Role):\n        pass\n    else:\n        raise TypeError('Only messages, members or roles may be passed')\n\n    server = obj.guild\n    admin_role_id = await bot.db.guild(server).admin_role()\n    mod_role_id = await bot.db.guild(server).mod_role()\n\n    if isinstance(obj, discord.Role):\n        return obj.id in [admin_role_id, mod_role_id]\n    mod_roles = [r for r in server.roles if r.id == mod_role_id]\n    mod_role = mod_roles[0] if len(mod_roles) > 0 else None\n    admin_roles = [r for r in server.roles if r.id == admin_role_id]\n    admin_role = admin_roles[0] if len(admin_roles) > 0 else None\n\n    if user and user == await bot.is_owner(user):\n        return True\n    elif admin_role and discord.utils.get(user.roles, name=admin_role):\n        return True\n    elif mod_role and discord.utils.get(user.roles, name=mod_role):\n        return True\n    else:\n        return False\n\n\ndef strfdelta(delta: timedelta):\n    \"\"\"Format a timedelta object to a message with time units.\n\n    Parameters\n    ----------\n    delta : datetime.timedelta\n        The duration to parse.\n\n    Returns\n    -------\n    str\n        A message representing the timedelta with units.\n\n    \"\"\"\n    s = []\n    if delta.days:\n        ds = '%i day' % delta.days\n        if delta.days > 1:\n            ds += 's'\n        s.append(ds)\n    hrs, rem = divmod(delta.seconds, 60*60)\n    if hrs:\n        hs = '%i hr' % hrs\n        if hrs > 1:\n            hs += 's'\n        s.append(hs)\n    mins, secs = divmod(rem, 60)\n    if mins:\n        s.append('%i min' % mins)\n    if secs:\n        s.append('%i sec' % secs)\n    return ' '.join(s)\n\n\nasync def is_admin_or_superior(\n    bot: Red, obj: Union[discord.Message, discord.Member, discord.Role]):\n    \"\"\"Same as `is_mod_or_superior` except for admin permissions.\n\n    If a message is passed, its author's permissions are checked. If a role is\n    passed, it simply checks if it is the admin role.\n\n    Parameters\n    ----------\n    bot : redbot.core.bot.Red\n        The bot object.\n    obj : `discord.Message` or `discord.Member` or `discord.Role`\n        The object to check permissions for.\n\n    Returns\n    -------\n    bool\n        :code:`True` if the object has admin permissions.\n\n    Raises\n    ------\n    TypeError\n        If the wrong type of ``obj`` was passed.\n\n    \"\"\"\n    user = None\n    if isinstance(obj, discord.Message):\n        user = obj.author\n    elif isinstance(obj, discord.Member) or isinstance(obj, discord.User):\n        user = obj\n    elif isinstance(obj, discord.Role):\n        pass\n    else:\n        raise TypeError('Only messages, members or roles may be passed')\n\n    server = obj.guild\n    admin_role_id = await bot.db.guild(server).admin_role()\n\n    if isinstance(obj, discord.Role):\n        return obj.id == admin_role_id\n    admin_roles = [r for r in server.roles if r.id == admin_role_id]\n    admin_role = admin_roles[0] if len(admin_roles) > 0 else None\n\n    if user and await bot.is_owner(user):\n        return True\n    elif admin_roles and discord.utils.get(user.roles, name=admin_role):\n        return True\n    else:\n        return False\n", "path": "redbot/core/utils/mod.py"}]}