dolfies / discord.py-self

A fork of the popular discord.py for user accounts.
https://discordpy-self.rtfd.io/en/latest/
MIT License
688 stars 160 forks source link

TextChannel.Search error #557

Closed koetsmax closed 1 year ago

koetsmax commented 1 year ago

Summary

Trying to search a text channel on the development version. But I'm getting a "discord.errors.HTTPException: 400 Bad Request (error code: 50024): Cannot execute action on this channel type"

Reproduction Steps

Traceback (most recent call last): File "c:\Users\User\Desktop\self-bot\self-bot\Lib\site-packages\discord\ext\commands\core.py", line 242, in wrapped ret = await coro(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\User\Desktop\self-bot\cogs\search_test.py", line 24, in search async for message in channel.search("ms", limit=100): File "c:\Users\User\Desktop\self-bot\self-bot\Lib\site-packages\discord\abc.py", line 385, in _handle_message_search data = await endpoint(entity_id, payload) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "c:\Users\User\Desktop\self-bot\self-bot\Lib\site-packages\discord\http.py", line 925, in request raise HTTPException(response, data) discord.errors.HTTPException: 400 Bad Request (error code: 50024): Cannot execute action on this channel type

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "c:\Users\User\Desktop\self-bot\self-bot\Lib\site-packages\discord\ext\commands\bot.py", line 1169, in invoke await ctx.command.invoke(ctx) File "c:\Users\User\Desktop\self-bot\self-bot\Lib\site-packages\discord\ext\commands\core.py", line 1026, in invoke await injected(*ctx.args, **ctx.kwargs) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "c:\Users\User\Desktop\self-bot\self-bot\Lib\site-packages\discord\ext\commands\core.py", line 251, in wrapped raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50024): Cannot execute action on this channel type

Search any text channel using TextChannel.Search

Code

@commands.command()
    async def search(self, ctx):
        if ctx.guild.id != 825768260862476318:
            return
        channel_name = "commands"
        guild = self.bot.get_guild(825768260862476318)
        channel = guild.get_channel(1113952017644257280)
        if isinstance(channel, discord.TextChannel):
            async for message in channel.search("test", limit=100):
                print(message.content)
        else:
            print(f"{channel} is not a text channel")

Expected Results

I am supposed to see a list of messages containing test

Actual Results

Getting an error

System Information

Checklist

Additional Information

No response

dolfies commented 1 year ago

Should be fixed as of the latest commit!