Git Product home page Git Product logo

basic-discord-bot's Introduction

Basic Discord bot

This repo has boilerplate code for a Ruby Discord bot written with discordrb. This bot will run on an AWS t3.micro instance and it should also run on a t3.nano or Pi Zero or similar (but it is untested).

Creating the bot

This are the instructions for creating a Discord bot and running it on your system.

  1. Go to https://discord.com/developers/applications.
  2. Click New Application at the top right.
  3. Give your bot a name and read and agree to the T&C.
  4. Give your bot a picture and a description (optional).
  5. Go to OAuth2.
  6. Make a note of Client ID - this is your bot's user ID.
  7. Under OAuth2 URL Generator, select scope bot (second column, sixth row) and your permissions.
  8. Copy the URL at the bottom of the page and open it - this will invite it to your server.
  9. Go to Bot.
  10. Get the Bot Token - it should be 72 characters and have a couple of . and a -. If you lose this you will have to request a new one and restart your bot. It is essentially your bot's password.
  11. Go to App Testers and add some friends to test your bot (optional).
  12. Copy your bot token and ID into main.rb OR (better) save to a .env file or similar.
  13. Run main.rb in the terminal or set up a systemd service (Linux only).
  14. Your bot should now be running.

Adding new commands

The commands /text_repeater will repeat phrases. The command shows the syntax for requiring strings, numbers, and booleans. When you create a new slash command, copy one of the files in /commands/. You need to register the command and update the code which runs the function. Change the names of the functions (there is a string and two symbols for defining the functions themselves). When main.rb is reloaded, all slash commands will be added automatically via the functions in module_loader.rb.

Sensitive commands

Some commands have user_id listed in an array - you should replace this with an list of user IDs who are allowed to use these functions.

basic-discord-bot's People

Contributors

david-manning avatar

Stargazers

 avatar

Watchers

 avatar

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.