GithubHelp home page GithubHelp logo

rapax00 / discord-auto-reactor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lacrypta/discord-auto-reactor

0.0 0.0 0.0 2.45 MB

Automatically react to Discord messages

Shell 14.03% TypeScript 85.97%

discord-auto-reactor's Introduction

Discord Auto-Reactor Bot

Very lightweight Discord bot that automatically reacts to messages. Written in TypeScript, based on discord.js.


  1. Setup
    1. Development Environment Setup
      1. NVM
      2. PNPM
    2. Discord Integration
      1. The Discord Bot Token
      2. The Discord Guild ID
      3. Inviting the Bot to Discord
    3. .env Setup

Setup

Setting up this project entails two main parts:

  1. setting up your development environment (we'll show detailed steps for VSCode under Linux, but you can pretty much use whatever works for you), and
  2. setting up the integration with Discord.

We'll tackle each in turn and guide you through the whole ordeal.

Development Environment Setup

NVM

First, we'll install nvm, Node Version Manager.

Run the following script or check the complete instructions here.

Install
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash
Setup

Install Node version:

nvm install

Use the version required in the project:

nvm use

PNPM

Install PNPM:

npm install -g pnpm

Discord Integration

Integrating with Discord will entail generating / finding two specific values:

  1. the Discord Bot Token, and
  2. the Discord Guild ID.

We'll treat each in turn.

The Discord Bot Token

The first thing you need to do is create a new application on the Discord Developer Portal:

New Discord Application

Give your new application a flashy new name:

Create Discord Application

Be sure to copy the application ID, we'll need it later:

Copy Discord Application ID

Now let's add a bot to your newly-created application:

New Application Bot

And confirm our choice:

Confirm Bot Creation

Give your new boy a flashy new name:

Name Discord Bot

Finally, let's give the bot the Message Content Intent Privileged Gateway Intent:

Configure Discord Bot

Although not technically required, you may verify that the permission bitmap value we'll use further down (ie. 68672) does not contain any spurious permissions by checking the Bot Permissions Calculator:

Discord Bot Permissions

After all this fooling around, let's wrap up the bot integration by resetting the bot token:

Reset Discord Bot Token

Don't mind the FUD:

Confirm Reset Token

And copy the value revealed:

Copy Discord Bot Token

Now, it's very important that you paste this value in a safe place, at least until we finish the integration and configuration steps, since we'll need it further down.

The Discord Guild ID

If you've managed this far, this is going to be a breeze. Simply go to the Discord application, look for the server you want the bot to appear, right-click on it, and select "Copy ID":

Copy Discord Guild ID

Paste this value somewhere safe, we'll need it further down.

Inviting the Bot to Discord

In order to invite the bot you just created, you'll need to build an invite URL... don't worry, it's really easy. Just copy this URL replacing YOUR_DISCORD_APPLICATION_ID with the value we saved before:

https://discord.com/oauth2/authorize?client_id=YOUR_DISCORD_APPLICATION_ID&scope=bot&permissions=68672

Navigating to it will greet you with:

Invite Bot to Discord

Finally, confirm the permissions set above:

Authorize Bot

And... you're done! Congratulations!

.env Setup

Every runtime datum in the project will be directed by the .env file. You don't have an .env file yet, let's fix that.

Copy .env.example to .env:

cp .env.example .env

This will leave you with an .env file like:

# shellcheck disable=SC2148,SC2034

# Discord
DISCORD_BOT_TOKEN="YOUR_DISCORD_BOT_TOKEN"
DISCORD_GUILD_ID="YOUR_DISCORD_GUILD_ID"

Now is the time for our hard work to bear fruit. You need to change the placeholder values (ie. YOUR_... strings) to the values we extracted before:

  1. replace YOUR_DISCORD_BOT_TOKEN with the value we copied here,
  2. replace YOUR_DISCORD_GUILD_ID with the value we copied here,

Running the Bot

To run the bot in development mode type pnpm dev. This should only be used during the development process, use the production mode for deployments.

To run the bot in production mode type pnpm prod, this will compile the typescript code and execute the generated javascript code with Node.js.

discord-auto-reactor's People

Contributors

mariano-perez-rodriguez avatar agustinkassis avatar dependabot[bot] 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.