A console based discord bot built with Go.
How can I get discord token?
User token:
- Run your internet browser.
- Go to the
https://discordapp.com/
site. - Open developer tools in your browser (Ctrl^Shift^I).
- Sign in to your account.
- Open local storage in dev-tools.
- Find the "token" scope and copy value.
Bot token:
- Run your internet browser.
- Go to the
https://discordapp.com/developers/applications/
site.
- If you already have a bot:
- Select your application.
- Go to the "Bot" page.
- Below "Username" in the "Token" field, click to the "Copy".
- If you don't have a bot:
- At the upper right corner click to the "New Application" button.
- Specify any name to your bot.
- ^See how to get token if you already have a bot^
How to invite bot to the server?
- Run your internet browser.
- Go to the
https://discordapp.com/developers/applications/
site. - Select your application.
- Below "Name" in the "Client ID" field, click to the "Copy".
- Put your Client ID instead of "CLIENTID" in this link:
https://discordapp.com/oauth2/authorize?client_id=CLIENTID&scope=bot
- If you want to add a bot without any permissions, then just use link from above and invite bot to your server.
- If you need permissions, then go to the "Bot" page and scroll to the bottom, then check scopes.
- Now copy your "Permissions Integer", put your Client ID instead of "CLIENTID" and Permissions Integer instead of "PERMISSIONS" in this link:
https://discordapp.com/oauth2/authorize?client_id=CLIENTID&scope=bot&permissions=PERMISSIONS
- Use this link and invite bot to your server.
How can I get GitHub token?
- You need available GitHub account.
- Login in to the GitHub site.
- In the upper right corner click to the your avatar and open menu.
- Select settings and scroll to the bottom.
- Select developer settings and go to the personal access tokens.
- Generate new token (without any scope) and paste its in the
config.json
.
How can I get Firebase credentials?
- You need available Google account.
- Login in to the Firebase site.
- Select the Firebase console in the right upper corner.
- Create a new project and select it.
- In the upper left corner, near the project overview, click on the button with the gear icon.
- Open project settings and go to the "service accounts" tab.
- Download your service account credentials and put to the
config.json
file.
Compile bot for yourself with Go:
- Download Go from official site
- Unpack Go somewhere.
- Add Go bin folder to your PATH.
- Clone the repo to your computer:
git clone https://github.com/Dmitriy-Vas/go-discord-bot.git
After these manipulations, you can start configuring bot.
Now that bot is installed, you will need to setup your config.json file. This can be done in few steps:
- Open the project folder in file explorer.
- Rename the file config-sample.json to config.json. (Note: Depending on your computer's settings you might not see the .json part of the file name)
- Change the bot settings with your own settings.
{
// Your discord token to connect bot
"token": "KuZrjndpA2sjTCuwqGecWUrkXd2ehysFRx6AM8rqYxr56H",
// GitHub personal token to work with GitHub API (v3)
"github": "Q7gmSVU6iPK3kX8Dwzhb2g87UQ5CV59aYnWL9gzA",
// true if you use user account, false if bot
"user": false,
// Your prefix to use with commands
"prefix": ">"
}
After setting up the config.json file, bot is ready to go. To run program, simply use the command go run main.go
in the console.
If you have setup your config.json properly (and used the correct credentials) you should see an output similar to this
Loaded 6 commands
Loaded config
Logged in as Dmitriy
- [n-n] n is any number. Specify number between this range.
- [word] word is any word. Specify any word instead of this.
- [user] user is any user mention. Specify any mention, example: @Dmitriy#0325
- [role] role is any role name. Specify any role name instead of this.
- If command has "+" suffix, then you can specify multiple values.
- Don't forget to add command prefix.
Commands list
- help
- Shows list of commands
- ping
- Responds with "pong"
- clear [0-100] [user]
- Removes specified amount of last messages in the current channel
- Optionally: delete messages from mentioned user
- role [user]+ [role]
- Adds or removes roles from specified users
- projects [word]
- Shows list of projects from specified GitHub username
- stars [word]
- Shows how many stars developer have in its GitHub projects