Ronald Liu
Ronald Liu

Reputation: 47

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.

Upvotes: 3

Views: 8831

Answers (1)

Jadev
Jadev

Reputation: 303

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

Upvotes: 8

Related Questions