Skip to content

Getting Started

MaoShizhong edited this page Jul 10, 2024 · 3 revisions

Initial Setup

  1. Fork this repository and use the git clone command in your terminal to clone it to your machine
  2. cd into the cloned repository and run npm install to install the dependencies
  3. create a new .env file in the repository with the command touch .env

You will need to enter a few things in the .env file. You can find an example file called .env.sample of which you can copy the entire contents into your newly generated .env file. At a minimum you should replace the xxxxx's for the below key and ID's and we'll explain how to retrieve those in the next sections.

  • DISCORD_API_KEY
  • DISCORD_CLIENT_ID
  • DISCORD_GUILD_ID

Leaving the other items as they are with their xxxxx's will not cause issues.

Install Redis

If you already have Redis installed, you can skip this section.

  1. Go to https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/
  2. Follow the installation instructions for your OS to install Redis.

Getting Your Discord API Key

  1. Go to https://discord.com/developers/applications

  2. Click on New Application

  3. Give the bot a name and click Create. Try to make it unique since Discord may not allow a name if it has too many users with that same name.

    You'll now be taken to the bot's "General Information" page. When visiting the Developer Portal at a later time, you can reach the bot options through Applications and selecting your bot.

  4. In the bot's menu, select Bot

  5. Click on Reset Token and copy the output. You may need to enter your 2FA code at this point

  6. Paste the copied token after DISCORD_API_KEY= in your .env file

Getting the Discord Client ID

  1. In the Discord Developer Portal with your bot selected, Navigate to menu item OAuth2
  2. Copy the Client ID as shown
  3. Paste the copied ID after DISCORD_CLIENT_ID= in your .env file

Getting the Discord Guild ID

  1. Open Discord
  2. Right-click your server to which you will later invite the bot
  3. Click Copy Server ID. Note that Developer mode has to be turned on for this in Discord Advanced profile settings
  4. Paste the copied ID after DISCORD_GUILD_ID= in your .env file

Adjust the Bot Settings

  1. In the Discord Developer Portal with your bot selected, Navigate to menu item Bot
  2. In the section Privileged Gateway Intents turn on Server Members Intent and Message Content Intent and save these settings
  3. Click on the OAuth2 menu item and then on URL Generator
  4. In the Scopes section, select bot
  5. In the Bot Permissions select at least
    • Read Messages/View Channels
    • Send Messages
    • Manage Messages
    • Embed Links
  6. Copy the generated URL for use in the next section

Invite the Bot to Your Server and Run it Locally

  1. Open the previously generated URL in your browser
  2. Select your personal server in the dropdown and click Continue for the bot to be added and to show up in your member list
  3. In your terminal, navigate to the cloned repository and run npm start

At this point your cloned version of Odin Bot should come online and its commands should work!