Problems with discord.js (DiscordAPIError)


#1

Hello!
Just about an hour ago I’ve noticed that my discord bot was offline.
Checking the console revealed the following error:

(node:5650) UnhandledPromiseRejectionWarning: DiscordAPIError
at item.request.gen.end (/rbd/pnpm-volume/f96f8ea6-0a1e-4e66-a1f0-2008c62a018b/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:79:15)
at then (/rbd/pnpm-volume/f96f8ea6-0a1e-4e66-a1f0-2008c62a018b/node_modules/.registry.npmjs.org/snekfetch/3.6.4/node_modules/snekfetch/src/index.js:215:21)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:5650) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:5650) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I think the problem might’ve started after an automatic update of discord.js
To clarify, removing .git didn’t help with anything. (This seems to have been the answer to every single one of my problems so far.)
Another interesting thing the console shows is the following (after reinstalling everything):

node v10.10.0, with pnpm
Installing…
Resolving: total 72, reused 58, downloaded 0
Resolving: total 174, reused 156, downloaded 0
WARN discord.js@11.4.2 requires a peer of bufferutil@^3.0.3 but none was installed.
WARN discord.js@11.4.2 requires a peer of erlpack@discordapp/erlpack but none was installed.
WARN discord.js@11.4.2 requires a peer of node-opus@^0.2.7 but none was installed.
WARN discord.js@11.4.2 requires a peer of opusscript@^0.0.6 but none was installed.
WARN discord.js@11.4.2 requires a peer of sodium@^2.0.3 but none was installed.
WARN discord.js@11.4.2 requires a peer of libsodium-wrappers@^0.7.3 but none was installed.
WARN discord.js@11.4.2 requires a peer of uws@^9.14.0 but none was installed.
Resolving: total 185, reused 185, downloaded 0, done
WARN Cannot link bin “uuid” of “node-uuid” to “/app/node_modules/.bin”. A package called “uuid” already has its bin linked.
Total install time: 5077ms

Manually putting all the dependencies in package.json had later resulted in incompatibility warning in the console, but I resolved it by updating node to 10.10.0, which brought me back to the first error (DiscordAPIError). I really can’t think of anything that would fix it anymore, especially given that two other discord bots I code still work. Copying their dependencies and installing those didn’t help either, by the way.

Here’s the bot page if needed: https://opibot-discord.glitch.me/

Thanks you sincerely for your help in advance,
Opisek


#2

It could be that Discord banned the IP address the project is using. We’ll take a look and let you know.


#3

We’ve taken a look but this project isn’t on an IP address that Discord has banned. Can you confirm the full error message you are getting from Discord? If you add a catch to handle the DiscrodAPIError then you should get a more complete error message. Thanks.


#4

I’m not sure if necro-posting is allowed or not.
But this error happened to me as well. The only way to resolve (at least for me) is to download the project, upload it to a GitHub repo and then import it into a new project. And later you can delete the repo!

If you decide to go the GitHub way, use Git to push to your repo.
A Tutorial on How To Use Git To Push To Remote Repos


#5

It looks like your issue is with snekfetch …