RTByte/rtbyte

DiscordAPIError: Cannot send messages to this user

sentry-io opened this issue · 6 comments

Sentry Issue: RTBYTE-V

DiscordAPIError: Cannot send messages to this user
  File "/root/rtbyte/node_modules/discord.js/src/rest/RequestHandler.js", line 170, in RequestHandler.execute
    return reject(new DiscordAPIError(request.path, data, request.method, res.status));
  File "internal/process/task_queues.js", line 97, in processTicksAndRejections

This error has been appearing when starting the bot. I'd assume it's due to the guild initialization function checking to see if it's able to send messages to guild owners, but failing there. Would need testing.

- Rasmus

I've encountered this issue when the bot is sharded and guilds are not available but the documentation on klasa isn't loading.

It could also be possible that the guild is being accessed through the cache and middleware is throwing process rejection before the cache is ready/ guild is fetched

There's been an ongoing issue with their documentation for a while, yeah. You should be able to view it without issue at this link.

We're not sharded at the moment, actually! Haven't had the time or energy to look into how to set it up as we're still fairly small, but it's definitely something we should look at doing.

As for the future of the bot, I think we should 100% make the switch over to Sapphire as soon as it's production ready, as Klasa is unfortunately no longer being maintained due to internal org issues. Sapphire is being actively developed by many of the previous Klasa contributors.

I'm not sure what version klasa is based off of, I can see that it's not 12 but instead of fetching from await + cache.get in

const owner = await this.client.users.cache.get(this.ownerID);
you might want to resort to this.client.users.fetch(this.ownerID) since the user would not be in the cache on startup (assuming this is the source of the problem)

discord.js docs - https://discord.js.org/?source=post_page---------------------------#/docs/main/stable/class/UserManager?scrollTo=cache

passing comment about how discord.js is superior /s

Both Klasa v0.5.0 and Sapphire both use Discord.js v12, so we're all good there 👍

Great point about the owner fetch, I completely overlooked how that could be the root of the issue. Feel free to submit a PR fixing this if you feel like it! If not, @PixelPoncho, would you be able to?

Unfortunately #158 doesn't seem to have fixed it. Gonna delve a little deeper and keep testing it on my end, thank you for your contribution so far @mchangrh!

I think i found it,

in discord.js v11 - disableEveryone is a messageOption,

in discord.js v12 - disableEveryone has been depreciated in favor of disableMentions

https://discord.js.org/?source=post_page---------------------------#/docs/main/v11/typedef/MessageOptions
https://discord.js.org/?source=post_page---------------------------#/docs/main/stable/typedef/MessageOptions

so let's hope you're right about it being discord.js v12