Dublicate shard. Many client instances for one shard.
Hello everyone, I'm using this code for a bot (https://github.com/iamnotacoder-djs/DiscordBotIda) and trying to run sharding (https://discordjs.guide/sharding/#when-to-shard). The problem is that due to the walk function in handlers/commands.js, as many client instances are created for one shard as there are commands in total. I assume that this is due to the recursive call to the walk function. If you remove from index.js, then sharding works correctly, but commands do not work as logically. Maybe someone got stuck, tell me how to fix it? Thank you in advance
Full code at the link to github: https://github.com/iamnotacoder-djs/DiscordBotIda
This function with recursions:
[email protected]
node.js v19.3.0
I would appreciate any help, thanks in advance!
GitHub
GitHub - iamnotacoder-djs/DiscordBotIda: Бот Ида не является финаль...
Бот Ида не является финальным продуктом. イド разрабатывается в рамках тестового полигона для обучающих видео по Discord.js. И не предназначен для использования на своих серверах. - GitHub - iamnotac...
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
8 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Post the full error stack trace, not just the top part!
- Show your code!
- Explain what exactly your issue is.
- Not a discord.js issue? Check out #useful-servers.
- Issue solved? Press the button!index.js code:
bot.js code:
ok, sorry
handlers/commands.js
structures/BaseCommand.js: https://github.com/iamnotacoder-djs/DiscordBotIda/blob/master/structures/BaseCommand.js
everything else is the same as on that github
i changed only these 3 files: index.js, bot.js, handlers/commands.js
yes, I just created bot.js, transferred the contents of index.js there, and wrote the code for creating shards in index.js. And I tried to fix the problem with creating multiple clients for one shard in commands.js
do you mean this?
module.exports = client;
I removed it, but it still launches repeatedly. Writes Shard Launched 0, Shard Launched 1 several times and restarts each time. Therefore, the bot responds to one command many times in the same shard
Don't use that template. It sucks
thanks for the advice, and what template would you recommend, what should I strive for?
I can see the structure close to the ideal somewhere?
If you want a framework use sapphire
#useful-servers
ok, thanks