How to test a bot that manages dozens of users in a voice channel?

I am working on a discord bot that manages dozens of active users in a servers voice channels. I can easily test with 2-3 users by logging in on several of my own devices, but I am worried that once I hit dozens of users I may run into some rate limiting issues or other bugs and I would love to find these before I start running in production. The bot sets up an event then moves users around once the event starts, so it'd be pretty embarrassing if something breaks after people arrive for the event. I tried to set up a bunch of bots and then log them in a loop, but there must be some limitation from Discord because it only lets me log in one bot at a time from my laptop. Does anyone have any advice on how I can test this locally?
6 Replies
d.js toolkit
d.js toolkitโ€ข2w ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Will
WillOPโ€ข2w ago
discord.js 14.18.0 node v20.18.1 I read somewhere there's a 60 second cooldown between client creations so I tried just logging in each bot 65 seconds apart, but that didn't work. It allows the first bot I have to log in but the 2nd just can't join My backup plan is to spin up a bunch of really cheap servers on some cloud provider and log in one bot per server, but was wondering if there's an easier (and cheaper) solution
Will
WillOPโ€ข2w ago
Code: https://pastebin.com/jWS0thS8 Output:
โœ… Bot test user 1#9512 is ready!
๐ŸŽค Bot test user 1#9512 joined voice channel coffee-chat-lobby
โณ Waiting 65 seconds before initializing next bot...
โœ… Bot test user 2#4315 is ready!
๐ŸŽค Bot test user 2#4315 joined voice channel coffee-chat-lobby
โœจ All bots initialized successfully!
๐Ÿ‘ฅ Users in voice channel: 1

๐Ÿ“ Type "exit" to gracefully shutdown the bots
exit
๐Ÿ‘‹ Initiating graceful shutdown...
๐Ÿงน Cleaning up voice connections...
โŒ Error destroying voice connection: Error: Cannot destroy VoiceConnection - it has already been destroyed
at VoiceConnection.destroy (/Users/user/Documents/Projects/N3S/coffee-chat-bot-discord-test-users/node_modules/.pnpm/@[email protected]/node_modules/@discordjs/voice/src/VoiceConnection.ts:553:10)
at cleanup (/Users/user/Documents/Projects/N3S/coffee-chat-bot-discord-test-users/src/index.ts:18:18)
at Interface.<anonymous> (/Users/user/Documents/Projects/N3S/coffee-chat-bot-discord-test-users/src/index.ts:38:7)
โœ… Bot test user 1#9512 is ready!
๐ŸŽค Bot test user 1#9512 joined voice channel coffee-chat-lobby
โณ Waiting 65 seconds before initializing next bot...
โœ… Bot test user 2#4315 is ready!
๐ŸŽค Bot test user 2#4315 joined voice channel coffee-chat-lobby
โœจ All bots initialized successfully!
๐Ÿ‘ฅ Users in voice channel: 1

๐Ÿ“ Type "exit" to gracefully shutdown the bots
exit
๐Ÿ‘‹ Initiating graceful shutdown...
๐Ÿงน Cleaning up voice connections...
โŒ Error destroying voice connection: Error: Cannot destroy VoiceConnection - it has already been destroyed
at VoiceConnection.destroy (/Users/user/Documents/Projects/N3S/coffee-chat-bot-discord-test-users/node_modules/.pnpm/@[email protected]/node_modules/@discordjs/voice/src/VoiceConnection.ts:553:10)
at cleanup (/Users/user/Documents/Projects/N3S/coffee-chat-bot-discord-test-users/src/index.ts:18:18)
at Interface.<anonymous> (/Users/user/Documents/Projects/N3S/coffee-chat-bot-discord-test-users/src/index.ts:38:7)
Pastebin
import { Client, GatewayIntentBits, ChannelType } from 'discord.js'...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
d.js docs
d.js docsโ€ข2w ago
:propertysignature: JoinVoiceChannelOptions#group voice@main An optional group identifier for the voice connection.
Will
WillOPโ€ข2w ago
hmm okay, so maybe I can use the bot id as the group identifier. Will try that, thanks.
Will
WillOPโ€ข2w ago
@Qjuh You are the GOAT!! Thank you
No description

Did you find this page helpful?