How to handle multiple tokens.
I have a single file of code. I'd like to run a service where you send a bot token and it runs the code on that bot too. How could i handle that?
discord.js@latest
node.js@latest
23 Replies
- 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!depends on how you are getting that token
you cannot ask users to give you their bot token
no. it's basically my friends whenever they create a server they need a protection bot. so they give me token and i host script on that token
just use the same bot then?
You need a different bot for different servers?
If you have access to these “different tokens” you can simply maintain different env files, and whenever you start the bot you can use Node’s
—env-file
flag to specify the env file to use while running the applicationokay yeah but the point is to use multiple tokens at once
yea if for example you want go have your custom branding
discord is very limited with per-server bot identity
I’ve been doing this the entire time to deploy any of the bots (of course they authorised me to)
Is there a way around to this?!
I actually have the same “white labelling” question as @kama
Makes sense O_O
i'm not asking them. they willingly give it to me. that's why services like crowbots or myself can work around that rule
i see. well my problem still resides in how to run everything on multiple tokens without duplicating my code
I mean I'd say that having a system for that is still against the ToS, it's not like "I have it but I don't recommend using it" is a strong argument
maybe if you make it very, very clear that they're violating the ToS it'll be better
yes. but i want to run them all simultaneously without having to run the code 3x
I guess just put all of them in for loop or something and that’s it. Run a file once to start all of them.
if i ever change something, and have more bots than three thisll take forever to start everything up
but then you won't be able to start or stop a single bot
and if one bot causes the process to crash, all of them will crash
no
uh yes
If they all run in the same process it will crash the entire process
thats 1 single process indeed
if an instance crashes there will simply be error
and not too sure what you're here for, we're trying to tell them not to run it in a single process
why ?
because as of whats mentioned before, and in general its bad practice to run multiple bots in a single process
crowbot uses this method
its true that its not optimized, but for a small bot I dont think it's too much trouble
that's not how errors work, events still need to handle their own errors, otherwise you'll get an unhandled error event exception
they literally said it'll "take forever to start everything up"