Sn0wCrack / saucybot-discord

A discord bot that fills in the gaps for art sites without proper inline embeds.
MIT License
40 stars 11 forks source link

[BUG] Error [ShardingReadyDied] #31

Closed LeviSnoot closed 2 years ago

LeviSnoot commented 2 years ago

Describe the bug Bit of a noob, especially with docker, so I'm sure this is probably my fault in some way, but I'm stuck trying to deploy this thing and googling errors hasn't been much help.

The fields in the .env file I've left blank are either websites I don't want to include with the bots functionality, or not being sure what value should be applied.

After running docker compose up, everything seems to start up as expected, but when it tries to connect to a shard, I get a 403.

I've invited the bot to my server with the bot and applications.commands scopes, as well as all Privileged Gateway Intents enabled and Text Permissions Send Messages, Embed Links, Attach Files and Read Message History.

To Reproduce

Create .env file like below, run docker compose up.

Expected behavior

Bot coming online and functioning.

Additional context

.env file:

NODE_ENV=production

DISCORD_API_KEY=[CENSORED]
DISCORD_SHARD_RESPAWN=true
DISCORD_SHARD_SPAWN_TIMEOUT=30000

DISCORD_GUILD_ID= # For development only
DISCORD_CLIENT_ID= # For development only

MAXIMUM_EMBEDS=8
DISABLED_SITES=

SENTRY_DSN=
REDIS_URL=

PIXIV_LOGIN=
PIXIV_PASSWORD=
PIXIV_COOKIE=
PIXIV_POST_LIMIT=5
PIXIV_UGOIRA_FORMAT=mp4
PIXIV_UGOIRA_BITRATE=2000

ARTSTATION_POST_LIMIT=5

FA_COOKIE_A=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx [OBFUSCATED TO SHOW SYNTAX BEING USED]
FA_COOKIE_B=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx [OBFUSCATED TO SHOW SYNTAX BEING USED]

EHENTAI_IPB_ID=
EHENTAI_IPB_PASS=

TWITTER_API_KEY=[CENSORED]
TWITTER_API_SECRET=[CENSORED]
TWITTER_ACCESS_TOKEN=[CENSORED]
TWITTER_ACCESS_SECRET=[CENSORED]
TWITTER_BEARER_TOKEN=[CENSORED]
TWITTER_READ_DELAY=1350

DEVIANTART_CLIENT_ID=
DEVIANTART_CLIENT_SECRET=

Log output:

saucybot-discord-cache-1  | 1:M 18 Sep 2022 15:39:53.364 * Ready to accept connections
saucybot-discord-bot-1    | [2022-09-18 15:39:55] [Manager] [INFO] Launched Shard 0
saucybot-discord-bot-1    | node:internal/process/promises:279
saucybot-discord-bot-1    |             triggerUncaughtException(err, true /* fromPromise */);
saucybot-discord-bot-1    |             ^
saucybot-discord-bot-1    |
saucybot-discord-bot-1    | [UnhandledPromiseRejection: 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(). The promise rejected with the reason "Response code 403 (Forbidden)".] {
saucybot-discord-bot-1    |   code: 'ERR_UNHANDLED_REJECTION'
saucybot-discord-bot-1    | }
saucybot-discord-bot-1    | [2022-09-18 15:40:00] [Manager] [ERROR] Shard 0's process exited before its Client became ready.
saucybot-discord-bot-1    | node:internal/process/promises:279
saucybot-discord-bot-1    |             triggerUncaughtException(err, true /* fromPromise */);
saucybot-discord-bot-1    |             ^
saucybot-discord-bot-1    |
saucybot-discord-bot-1    | [UnhandledPromiseRejection: 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(). The promise rejected with the reason "Response code 403 (Forbidden)".] {
saucybot-discord-bot-1    |   code: 'ERR_UNHANDLED_REJECTION'
saucybot-discord-bot-1    | }
saucybot-discord-bot-1    | /bot/node_modules/discord.js/src/sharding/Shard.js:162
saucybot-discord-bot-1    |         reject(new Error(ErrorCodes.ShardingReadyDied, this.id));
saucybot-discord-bot-1    |                ^
saucybot-discord-bot-1    |
saucybot-discord-bot-1    | Error [ShardingReadyDied]: Shard 0's process exited before its Client became ready.
saucybot-discord-bot-1    |     at Shard.onDeath (/bot/node_modules/discord.js/src/sharding/Shard.js:162:16)
saucybot-discord-bot-1    |     at Object.onceWrapper (node:events:628:26)
saucybot-discord-bot-1    |     at Shard.emit (node:events:513:28)
saucybot-discord-bot-1    |     at Shard.emit (node:domain:489:12)
saucybot-discord-bot-1    |     at Shard._handleExit (/bot/node_modules/discord.js/src/sharding/Shard.js:408:10)
saucybot-discord-bot-1    |     at ChildProcess.emit (node:events:513:28)
saucybot-discord-bot-1    |     at ChildProcess.emit (node:domain:489:12)
saucybot-discord-bot-1    |     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
saucybot-discord-bot-1    | Emitted 'error' event on Shard instance at:
saucybot-discord-bot-1    |     at /bot/node_modules/discord.js/src/sharding/Shard.js:416:56
saucybot-discord-bot-1    |     at processTicksAndRejections (node:internal/process/task_queues:96:5) {
saucybot-discord-bot-1    |   code: 'ShardingReadyDied'
saucybot-discord-bot-1    | }
saucybot-discord-bot-1 exited with code 1
Sn0wCrack commented 2 years ago

I have the feeling this is caused by not having certain sites disabled since you're not providing valid details for all sites you don't wish to use.

You'll want to set your DISABLED_SITES env variable to this probably: DISABLED_SITES=Pixiv,DeviantArt

Those two sites specifically attempt to authenticate themselves when the bot starts up, and if they fail they could cause one of the shards to crash.

If that doesn't work I can see if I can't replicate it myself.

The value of Disabled Sites is basically a comma separated list of the file names from this particular directory https://github.com/Sn0wCrack/saucybot-discord/tree/master/src%2Fsites

LeviSnoot commented 2 years ago

Changed DISABLED_SITES entry to the following:

DISABLED_SITES=Pixiv,DeviantArt,ArtStation,HentaiFoundry,ExHentai

Unfortunately the same error persists.

Sn0wCrack commented 2 years ago

I've just realized the DISABLED_SITES still have a bit of initialization code run and the culprit here appears to be DeviantArt.

I've moved some things around and made release v1.8.4, which should fix this issue for you.

LeviSnoot commented 2 years ago

Looks like that solved it, thanks!