Repository: python-discord/bot
Issue: `wait_for_deletion` from `bot/utils/messages.py` raises an exception if the `client` parameter is not specified, although it's optional 

If the `client` parameter of `wait_for_deletion` is not specified, the function itself will set the `client` parameter, but as an instance of `discord.Member`, rather than an instance of `discord.Client` or a subclass of it. What's the problem with this? `discord.Member` object has no attribute `wait_for`, and this attribute is actually used in the function, no matter what.

Points of interest:
https://github.com/python-discord/bot/blob/4df3089d8d03f54cdbd14d7683149ae7931036c1/bot/utils/messages.py#L25 - The `client` parameter
https://github.com/python-discord/bot/blob/4df3089d8d03f54cdbd14d7683149ae7931036c1/bot/utils/messages.py#L39 - How the `client` parameter is set if `client` is `None`

Changed files:
bot/cogs/snekbox.py, bot/cogs/bot.py, bot/utils/messages.py, bot/cogs/tags.py

diff --git a/bot/cogs/bot.py b/bot/cogs/bot.py
index 79510739..70ef407d 100644
--- a/bot/cogs/bot.py
+++ b/bot/cogs/bot.py
@@ -337,7 +337,7 @@ class BotCog(Cog, name="Bot"):
                         self.codeblock_message_ids[msg.id] = bot_message.id
 
                         self.bot.loop.create_task(
-                            wait_for_deletion(bot_message, user_ids=(msg.author.id,), client=self.bot)
+                            wait_for_deletion(bot_message, (msg.author.id,), self.bot)
                         )
                     else:
                         return
diff --git a/bot/cogs/snekbox.py b/bot/cogs/snekbox.py
index 52c8b6f8..63e6d7f3 100644
--- a/bot/cogs/snekbox.py
+++ b/bot/cogs/snekbox.py
@@ -220,9 +220,7 @@ class Snekbox(Cog):
                 response = await ctx.send("Attempt to circumvent filter detected. Moderator team has been alerted.")
             else:
                 response = await ctx.send(msg)
-            self.bot.loop.create_task(
-                wait_for_deletion(response, user_ids=(ctx.author.id,), client=ctx.bot)
-            )
+            self.bot.loop.create_task(wait_for_deletion(response, (ctx.author.id,), ctx.bot))
 
             log.info(f"{ctx.author}'s job had a return code of {results['returncode']}")
         return response
diff --git a/bot/cogs/tags.py b/bot/cogs/tags.py
index 3d76c5c0..d0164731 100644
--- a/bot/cogs/tags.py
+++ b/bot/cogs/tags.py
@@ -236,7 +236,7 @@ class Tags(Cog):
                 await wait_for_deletion(
                     await ctx.send(embed=Embed.from_dict(tag['embed'])),
                     [ctx.author.id],
-                    client=self.bot
+                    self.bot
                 )
             elif founds and len(tag_name) >= 3:
                 await wait_for_deletion(
@@ -247,7 +247,7 @@ class Tags(Cog):
                         )
                     ),
                     [ctx.author.id],
-                    client=self.bot
+                    self.bot
                 )
 
         else:
diff --git a/bot/utils/messages.py b/bot/utils/messages.py
index 67028994..aa8f17f7 100644
--- a/bot/utils/messages.py
+++ b/bot/utils/messages.py
@@ -19,25 +19,20 @@ log = logging.getLogger(__name__)
 async def wait_for_deletion(
     message: Message,
     user_ids: Sequence[Snowflake],
+    client: Client,
     deletion_emojis: Sequence[str] = (Emojis.trashcan,),
     timeout: float = 60 * 5,
     attach_emojis: bool = True,
-    client: Optional[Client] = None
 ) -> None:
     """
     Wait for up to `timeout` seconds for a reaction by any of the specified `user_ids` to delete the message.
 
     An `attach_emojis` bool may be specified to determine whether to attach the given
-    `deletion_emojis` to the message in the given `context`
-
-    A `client` instance may be optionally specified, otherwise client will be taken from the
-    guild of the message.
+    `deletion_emojis` to the message in the given `context`.
     """
-    if message.guild is None and client is None:
+    if message.guild is None:
         raise ValueError("Message must be sent on a guild")
 
-    bot = client or message.guild.me
-
     if attach_emojis:
         for emoji in deletion_emojis:
             await message.add_reaction(emoji)
@@ -51,7 +46,7 @@ async def wait_for_deletion(
         )
 
     with contextlib.suppress(asyncio.TimeoutError):
-        await bot.wait_for('reaction_add', check=check, timeout=timeout)
+        await client.wait_for('reaction_add', check=check, timeout=timeout)
         await message.delete()