Skip to content

06. Creating a Discord Bot

engels74 edited this page Oct 19, 2024 · 1 revision

🤖 Creating a Discord Bot

To use TGraph Bot, you need to create a Discord bot and obtain its token. This page will guide you through the process of creating a bot, getting the necessary token, and inviting the bot to your server.

📝 Step-by-Step Guide

1️⃣ Create a Discord Application

  1. Go to the Discord Developer Portal.
  2. Click on the "New Application" button in the top right corner.
  3. Give your application a name (e.g., "TGraph Bot") and click "Create".

2️⃣ Create a Bot User

  1. In your new application, navigate to the "Bot" tab in the left sidebar.
  2. Click on "Add Bot" and confirm by clicking "Yes, do it!".
  3. Customize your bot's username if desired.

3️⃣ Get Your Bot Token

  1. In the "Bot" tab, under the "Token" section, click "Copy" to copy your bot token.
  2. 🔒 IMPORTANT: Keep this token secret! Anyone with this token can control your bot.

4️⃣ Set Up Bot Permissions

  1. Still in the "Bot" tab, scroll down to the "Bot Permissions" section.
  2. Select the following permissions:
    • Read Messages/View Channels
    • Send Messages
    • Embed Links
    • Attach Files
    • Read Message History
    • Use Slash Commands

5️⃣ Create an Invite Link

  1. Go to the "OAuth2" tab in the left sidebar.
  2. Scroll down to the "Scopes" section and select "bot" and "applications.commands".
  3. In the "Bot Permissions" section below, select the same permissions as in step 4.
  4. Copy the generated URL at the bottom of the "Scopes" section.

6️⃣ Invite the Bot to Your Server

  1. Open a new browser tab and paste the URL you copied.
  2. Select the server you want to add the bot to from the dropdown menu.
  3. Click "Authorize" and complete any required verification.

⚙️ Configuring TGraph Bot

Now that you have created your Discord bot, you need to add the bot token to your TGraph Bot configuration:

  1. Open your config.yml file.
  2. Find the DISCORD_TOKEN setting.
  3. Replace the placeholder value with your actual bot token:
    DISCORD_TOKEN: your_actual_bot_token_here
  4. Save the config.yml file and restart TGraph Bot for the changes to take effect.

🔒 Security Notes

  • Never share your bot token publicly or commit it to version control systems.
  • If you suspect your token has been compromised, go back to the Discord Developer Portal and regenerate it immediately.
  • Use environment variables or secure secrets management systems in production environments.

🆔 Getting Your Channel ID

TGraph Bot needs to know which channel to post graphs in. To get your channel ID:

  1. Enable Developer Mode in Discord (User Settings > Appearance > Advanced > Developer Mode).
  2. Right-click on the channel you want to use and select "Copy ID".
  3. Add this ID to your config.yml file:
    CHANNEL_ID: your_channel_id_here

🔍 Troubleshooting

  • If your bot doesn't come online, double-check that you've correctly copied the token.
  • Ensure the bot has the necessary permissions in your server settings.
  • Check the TGraph Bot logs for any error messages related to Discord connectivity.

By following these steps, you should have successfully created a Discord bot and configured TGraph Bot to use it. If you encounter any issues, please refer to the Troubleshooting page or reach out for support.