Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide discord token on github

I'm trying to make a discord bot that is online 24/7. I am using Heroku to host my discord bot. Heroku gets my code uploaded to github. But, apparently github and discord are parterned and github detects when a discord token is posted on it and discord automatically changes the token. And when the token changes I can't use my bot.

like image 356
Ronald Liu Avatar asked May 02 '26 18:05

Ronald Liu


1 Answers

As mentioned in the comments, put your token in a seperat config file and dont commit the config into git (so basicly add the config file in the .gitignore file)

config.json

{
    "prefix": "!",
    "token": "your-token-goes-here"
}

.gitignore

config.json

bot.js

const config = require('./config.json');

...
client.login(config.token)

EDIT: It is important that you do not share your token with someone else, if someone got your token and has some malicous intend they can do all kind of bad stuff with your bot. Here is a link where you read about this and why you should not give this token out at any cost. https://github.com/reactiflux/discord-irc/wiki/Creating-a-discord-bot-&-getting-a-token

like image 76
Jadev Avatar answered May 04 '26 12:05

Jadev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!