Is it possible to run the same bot multiple times and have them each independently handle commands?

I was wondering if I can just run multiple instances of the same bot and have them handle commands on a per channel basis. Each instance of the bot would have it's own config that tells it what channel it can respond to commands in. I was able to achieve this in discord-akairo (old discord framework) with message commands, but I don't know if this would work with interaction commands.
Solution:
Nevermind. Everything worked perfectly from the start. My own filter feature was making me think no messages were being sent to the second instance's channel. I guess there was an influx of messages all at once in the first instance's channel which made me think it was both instance's messages.
Jump to solution
19 Replies
xAfflict
xAfflictOP2y ago
Basically, I have a minecraft chat bot that I can interact with through discord. One instance of my program hooks up to one discord bot and one minecraft account through a config. The config tells it what channel corresponds to what minecraft account. I want to run multiple minecraft accounts, so I'm attempting to run multiple instances of my program, but with separate configs for each.
Favna
Favna2y ago
you weren't really able to handle this with akairo because both bots still received all events, you or something akairo did was just filtering out certain events with a dead simple if check:
if (bot.name === 'whatever' && channel.id === 'some id') {
// do stuff
}
if (bot.name === 'whatever' && channel.id === 'some id') {
// do stuff
}
xAfflict
xAfflictOP2y ago
Yes that is what I was implying I checked the channel ID And checked the ID against the config the bot was running against
Favna
Favna2y ago
it's a basic if check. If you're asking if you can write a basic if check in Sapphire then ya duh ofc you can.. it's a basic if check omegalul
xAfflict
xAfflictOP2y ago
I've attempted to do that But I notice that sapphire is now sending all messages through one channel of the first instance Even though it doesn't even know about the other configs channel IDs. It shouldn't be sending messages there. So I'm wondering if this is something to do with interactions.
Favna
Favna2y ago
shouldn't be, idk, but you can solve all your problems by just making a separate bot application with a separate token. That's the proper way to do it anyway.
xAfflict
xAfflictOP2y ago
I didn't want to create 15 tokens Haha
Favna
Favna2y ago
You said 2, not 15.
xAfflict
xAfflictOP2y ago
Sorry, I meant for it to be able to run multiple instances in general AKA not just one
Favna
Favna2y ago
And maybe just stick to message commands then monkashrug no idea what you're really trying to achieve. Sounds like you're overcomplicating things very very much
xAfflict
xAfflictOP2y ago
I'm trying not to write more complicated code to manage multiple minecraft bots over multiple channels on a single instance
Favna
Favna2y ago
anyway my guess is that you're not if checking / returning properly
xAfflict
xAfflictOP2y ago
But to just run multiple instances of code designed to run a single minecraft bot / a single discord bot
Favna
Favna2y ago
can't really say much more without source code tbh
xAfflict
xAfflictOP2y ago
Sure let me finish up some commits
Favna
Favna2y ago
Ill look tomorrow. I'm going to bed now. Gnight
xAfflict
xAfflictOP2y ago
Good night.
Solution
xAfflict
xAfflict2y ago
Nevermind. Everything worked perfectly from the start. My own filter feature was making me think no messages were being sent to the second instance's channel. I guess there was an influx of messages all at once in the first instance's channel which made me think it was both instance's messages.
xAfflict
xAfflictOP2y ago
(How many times did I use the word instances?)
Want results from more Discord servers?
Add your server