Code Monkey home page Code Monkey logo

go-discord-bot's Introduction

go-discord-bot

A console based discord bot built with Go.

Table of Contents

FAQ

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.

Install

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.

Setup

Now that bot is installed, you will need to setup your config.json file. This can be done in few steps:

  1. Open the project folder in file explorer.
  2. 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)
  3. 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": ">"
}

Run

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

Commands

  • [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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.