Skip to content

rohKane/discord-bot-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Discord Bot Template

A simple discord bot template for the bohr.io platform. It uses API endpoints to respond to Interactions with the bot.

Setting your project

  1. In the bohr.io platform start a new project with this template.

  2. Create a Discord application and a bot.

  3. Generate a url in the OAuth2/Url Generator, with the options:

    • SCOPES:

      • applications.commands
      • bot

    • BOT PERMISSIONS:

      • Use Slash Commands
      • Send Messages

  4. Invite the bot to your server using the generated url.

  5. Set the following environment variables on the bohr.io project settings:

    • From your Discord Application General Information page:

      • APPLICATION_ID
      • DISCORD_PUBLIC_KEY

    • From your Discord Application Bot page.

      • DISCORD_BOT_TOKEN

    • From your Discord Client (enable the 'developer mode' under advanced settings. Then right click on your test server)

      • TEST_GUILD_ID

    1. In the discord application General Information, set the INTERACTIONS ENDPOINT URL with the project's interactions api endpoint: https://<PROJECT_URL>/api/interactions

Developing

  1. Create a second Discord application to be your development application.

  2. Start the project locally using the terminal commands:

    git clone <PROJECT_REPOSITORY_URL>
    cd <REPOSITORY_NAME>
    npx -y bohr@latest dev
    
  3. When starting your project locally, a tunnel url to your local project will be provided. Use it for the INTERACTIONS ENDPOINT URL in the development application.


Updating Commands

To update the bot commands use the project's endpoint /update-commands.

This endpoint can receive the global query parameter. When set to 'true', it updates global bot commands. Otherwise, it only updates commands for the TEST_GUILD_ID server.

Commands

  • server: send the channel and server that the user is in
  • user: send a mention to the user