Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

ctx.author.send() gives a 404 "Unknown Channel" error #94

Closed
tiltowait opened this issue Sep 4, 2021 · 7 comments
Closed

ctx.author.send() gives a 404 "Unknown Channel" error #94

tiltowait opened this issue Sep 4, 2021 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@tiltowait
Copy link

When using discord-ui, any attempt to perform an await ctx.author.send(...) results in the following error:

File "/opt/homebrew/lib/python3.9/site-packages/discord_ui/override.py", line 50, in send
    r = await self._state.http.request(route, json=payload)
  File "/opt/homebrew/lib/python3.9/site-packages/discord/http.py", line 250, in request
    raise NotFound(r, data)
discord.errors.NotFound: 404 Not Found (error code: 10003): Unknown Channel

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

Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/homebrew/lib/python3.9/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NotFound: 404 Not Found (error code: 10003): Unknown Channel

Currently, I'm working around it by manually creating a DM channel, but it's an ugly kludge.

@kvsxxx kvsxxx self-assigned this Sep 4, 2021
@RedstoneZockt RedstoneZockt assigned RedstoneZockt and unassigned kvsxxx Sep 4, 2021
@RedstoneZockt
Copy link
Collaborator

RedstoneZockt commented Sep 4, 2021

Fixed in 4.2.4

@tiltowait
Copy link
Author

Unfortunately, this seems only partially fixed as of 4.2.6.

I have the following user interaction flow that occurs in DMs:

  1. User messages bot in public server
  2. Bot opens DM and sends user a message with components (SelectMenu)
  3. User selects component
  4. Bot deletes original message
  5. Go to step 2; repeat until done

Steps 1-3 all work fine. The bot sends the message in the DM, and the user is able to select the component, which the bot sees. However, at step 4, I get the Unknown Channel error above. This error only occurs if I use ctx.author.send() in step 2. If I create a DM channel in step 2, then step 4 finishes correctly, and the loop proceeds.

If it matters (only mentioning this because the example code all uses them), I am not using slash commands.

@RedstoneZockt
Copy link
Collaborator

I will look at it. Thanks for reporting 😃

@RedstoneZockt RedstoneZockt reopened this Sep 4, 2021
@kvsxxx kvsxxx self-assigned this Sep 4, 2021
@kvsxxx kvsxxx added the bug Something isn't working label Sep 4, 2021
@kvsxxx kvsxxx closed this as completed in 7d7e120 Sep 4, 2021
@kvsxxx
Copy link
Member

kvsxxx commented Sep 4, 2021

sorry for the issues, this is fixed in v4.2.7

@tiltowait
Copy link
Author

Sorry, but I'm still experiencing the error even in v4.2.7. Referring to my flow above, it now successfully completes step 4; however, upon executing step 5 (return to step 2), I get the same error as before.

I have written a trivial example that generates the Unknown Channel error. This fails consistently on my end when using discord-ui but not when using vanilla discord.py.

cached_ctx = None

@bot.command()
async def test_test(ctx):
    global cached_ctx
    if cached_ctx is None:
        cached_ctx = ctx
        await cached_ctx.author.send("Hi") # OK
    else:
        await cached_ctx.author.send("Bye") # Should work but generates error

Thanks for the work so far! We're getting closer.

discord-ui 4.2.7
discord.py 1.7.3
python 3.9.6

@RedstoneZockt RedstoneZockt reopened this Sep 4, 2021
@kvsxxx kvsxxx closed this as completed in d060be5 Sep 4, 2021
@kvsxxx
Copy link
Member

kvsxxx commented Sep 4, 2021

aight thanks for your patience, this should hopefully finally be fixed in v4.2.8

@tiltowait
Copy link
Author

It works now. Thanks for the quick work.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants