RTByte / rtbyte

An open-source modular multipurpose Discord bot built on the incredible Sapphire framework for discord.js
https://rtbyte.xyz/
MIT License
139 stars 14 forks source link

DiscordAPIError: Cannot send messages to this user #157

Closed sentry-io[bot] closed 4 years ago

sentry-io[bot] commented 4 years ago

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

mchangrh commented 4 years ago

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

rasmusgerdin commented 4 years ago

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.

mchangrh commented 4 years ago

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 https://github.com/RTByte/rtbyte/blob/7d01f1399c555d627d6838e0c856cbbfa6bf67a6/src/extendables/KlasaGuild/fn_KlasaGuild%23rtbyteInit.js#L145 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

rasmusgerdin commented 4 years ago

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?

rasmusgerdin commented 4 years ago

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!

mchangrh commented 4 years ago

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