Restarting bot token programatically

Is there any way that we can reset a bot's token? If there is no official method or underlying api endpoint I can use, what would a possible solution be to accomplish this?
10 Replies
d.js toolkit
d.js toolkit3mo 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!
lanjt
lanjtOP3mo ago
At one point I was thinking of just having the bot publish a git gist with the token inside of it but there must be a better way
monbrey
monbrey3mo ago
Why do you need to do this?
lanjt
lanjtOP3mo ago
Requires some background info: it's a bot that is added to some high member count servers, and it requires permissions that can be damaging if the token is compromised, and since the bot has a single purpose i plan to just leave in some event listeners to see if it's doing something it should not be rather than putting security in the server's hands
NyR
NyR3mo ago
You misunderstood, obviously exposing the token online is very bad, and you should never do that. But why do you think you needed to do that in the first place?
lanjt
lanjtOP3mo ago
I was generally saying it as a workaround because I know that if you expose your token to a public github repo, Discord will reset it automatically I really don't, but I need to assure the people I need to work with on something other than my ability to keep a token safe, and this would be a method that works 100% of the time If you all don't think that it's a good idea I will respect that and try to find another method, but please lmk!
tyvn
tyvn3mo ago
You’re skipping a lot of steps of security. At which point would your token get compromised unless you were to share it? You don’t need to check if your bot is doing something malicious because by the time your bot detects it, it’s already been compromised and the malicious code executed. And in order for them to get access to the token they would need to either gain access to your discord account or your hosting. Seems completely pointless imo.
lanjt
lanjtOP3mo ago
I appreciate your response, and want to explain a little. I'm not skipping steps of security, I know how to secure my token and didn't claim I wasn't securing my host. By the time my bot detects it, it can change the token. I'd rather have 10-20 actions to clean up rather than 200-500. I'm speaking of token compromise, not host compromise.
Amgelo
Amgelo3mo ago
I don't think there's an endpoint for it, not even with oauth it really pretty much just relies on your ability to keep your token safe, and there shouldn't be many ways to expose it, if any actually the most common approach of compromising a bot is to compromise the owner's account, since that's way easier, in modern days the human factor is always the weakest link and you can easily avoid that by just securing your account: secure password, 2fa, etc maybe even using a separate account apart from your personal one, just for the bot though I'm not sure if that's against dev tos, I wouldn't think so but you should probably ask discord
souji
souji3mo ago
managing apps - creating, deleting, generating tokens, transferring to teams, etc. is a user-only action and does not have an app-authorized endpoint automating user accounts is strictly against ToS
Want results from more Discord servers?
Add your server