Repository: Pycord-Development/pycord

Issue:
ctx.channel.purge does not behave as expected in threads with version b7
### Summary

ctx.channel.purge does not work as expected in threads with version b7

### Reproduction Steps

Install pycord b7 (also ensure Discord is uninstalled):
pip install -U py-cord==2.0.0b7

Run the minimum code with a given token, debug guild, etc...

Create a new thread under some text channel in one of the debug guilds. Type a few random messages in this new thread. Run /purging_thread with the test_bot. There should be an error seen in actual results

### Minimal Reproducible Code

```python
#!/usr/bin/env python3
import discord
from discord.ext import commands

class DeleteCog(commands.Cog):
    def __init__(self, bot: commands.bot):
        self.bot = bot

    @commands.slash_command(
        name="purging_thread",
        description="Deletes all messages from this bot in a thread.",
    )
    async def purging_thread(self, ctx):
        await ctx.channel.purge(limit=5)


if __name__ == "__main__":

    guilds = [...]
    token = "..."

    bot = discord.Bot(debug_guilds=guilds)
    bot.add_cog(DeleteCog(bot))

    bot.run(token)
```


### Expected Results

Messages in the thread to be deleted.

### Actual Results

Ignoring exception in command purging_thread:
Traceback (most recent call last):
  File "/home/user/.pyenv/versions/bot_dev/lib/python3.9/site-packages/discord/commands/core.py", line 122, in wrapped
    ret = await coro(arg)
  File "/home/user/.pyenv/versions/bot_dev/lib/python3.9/site-packages/discord/commands/core.py", line 825, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "/home/user/git/discord_ui_testing/./testing.py", line 18, in purging_thread
    await ctx.channel.purge(limit=5)
  File "/home/user/.pyenv/versions/bot_dev/lib/python3.9/site-packages/discord/threads.py", line 475, in purge
    return await _purge_messages_helper(
  File "/home/user/.pyenv/versions/bot_dev/lib/python3.9/site-packages/discord/abc.py", line 169, in _purge_messages_helper
    await strategy(to_delete, reason=reason)
TypeError: delete_messages() got an unexpected keyword argument 'reason'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/user/.pyenv/versions/bot_dev/lib/python3.9/site-packages/discord/bot.py", line 1098, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "/home/user/.pyenv/versions/bot_dev/lib/python3.9/site-packages/discord/commands/core.py", line 331, in invoke
    await injected(ctx)
  File "/home/user/.pyenv/versions/bot_dev/lib/python3.9/site-packages/discord/commands/core.py", line 128, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc 
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: delete_messages() got an unexpected keyword argument 'reason'

### Intents

All

### System Information

- Python v3.9.5-final
- py-cord v2.0.0-beta
    - py-cord pkg_resources: v2.0.0b7
- aiohttp v3.8.1
- system info: Linux 5.4.0-91-generic #102-Ubuntu SMP Fri Nov 5 16:31:28 UTC 2021

### Checklist

- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.

### Additional Context

One of the helpers on Discord mentioned that if you go to venv/lib/python3.9/site-packages/discord/threads.py, and change line 354 to
`async def delete_messages(self, messages: Iterable[Snowflake], *, reason: Optional[str] = None) -> None:`
It might fix the issue. I tested their fix and it does fix it.


Discussion:

Resolving patch:
diff --git a/discord/threads.py b/discord/threads.py
--- a/discord/threads.py
+++ b/discord/threads.py
@@ -351,7 +351,7 @@ def permissions_for(self, obj: Union[Member, Role], /) -> Permissions:
             raise ClientException("Parent channel not found")
         return parent.permissions_for(obj)
 
-    async def delete_messages(self, messages: Iterable[Snowflake]) -> None:
+    async def delete_messages(self, messages: Iterable[Snowflake], *, reason: Optional[str] = None) -> None:
         """|coro|
 
         Deletes a list of messages. This is similar to :meth:`Message.delete`
@@ -373,6 +373,8 @@ async def delete_messages(self, messages: Iterable[Snowflake]) -> None:
         -----------
         messages: Iterable[:class:`abc.Snowflake`]
             An iterable of messages denoting which ones to bulk delete.
+        reason: Optional[:class:`str`]
+            The reason for deleting the messages. Shows up on the audit log.
 
         Raises
         ------
@@ -394,14 +396,14 @@ async def delete_messages(self, messages: Iterable[Snowflake]) -> None:
 
         if len(messages) == 1:
             message_id = messages[0].id
-            await self._state.http.delete_message(self.id, message_id)
+            await self._state.http.delete_message(self.id, message_id, reason=reason)
             return
 
         if len(messages) > 100:
             raise ClientException("Can only bulk delete messages up to 100 messages")
 
         message_ids: SnowflakeList = [m.id for m in messages]
-        await self._state.http.delete_messages(self.id, message_ids)
+        await self._state.http.delete_messages(self.id, message_ids, reason=reason)
 
     async def purge(
             self,


Test patch: