Skip to content

UnionRolistes/Bot-Roles

Repository files navigation

UnionRolistes.fr

Fonctionnalité du Bot Discord De UnionRolistes.fr, opensources

This code appears to be a JavaScript file for a Discord bot named "Bot_Roles". The bot has several commands, including ping, credit, version, and help, which provide information about the bot, its version, and available commands. The bot also has a roles command that displays information about roles in a Discord server. When this command is run with a specific channel mentioned, it returns a list of roles that have access to that channel.

OneLine Update / Install

cd /usr/local/src/

sudo git clone https://github.com/UnionRolistes/Bot-Roles Bot_Roles && cd ./Bot_Roles/ && sudo npm install && sudo npm run install

sudo pm2 status && sudo pm2 delete 0 && sudo pm2 start Start_Bot_Roles.js

-> Default Directory

-> Create a new folder

-> Clone the project in the folder you just created.

-> Go into the folder where you cloned the project.

-> Install all node_modules again ( in case something changed/updated).

-> Execute setup.js in case something in the config has changed.

-> Stop the daemon(pm2) and restart it again (to keep the bot online).

Detailled Installation

  1. You need node installed on your system, detailled instructions for different operating systems can be found here.

  2. Check your node version with node -v . Node.js 12.0.0 or newer is required.

  3. Cloning the project via git.

-> Navigate in the folder where it should cloned in: cd /usr/local/src/

Clone it:

sudo git clone https://github.com/UnionRolistes/Bot-Roles Bot_Roles

Before setting up the "real" bot you must check some things:

  • You need a so called token for your bot. You need it later.

-> How to obtain the token? Create an application and follow the steps below:

Now navigate to "Bot"

Bot

Obtain the token

  • Since Discord restricted the access to specific user data, you need to enable the so called Privileged Gateway Intents. To so, scroll down and enable both of them And click "Copy"

  • A suitable prefix. There is no sense in choosing one which another bot already utilises. So choose a unique one.

  1. Now navigate into the folder with the cloned project:

cd /usr/local/src/Bot_Roles

Install the npm packages:

sudo npm install

  1. Execute sudo npm run install to create a configuration file before the first startup of the bot.
  • prefix : This will be the prefix for which the bot will listen(I suggest $).
  • token : Token which you obtained earlier.
  • intents : Don't touch the next options! If you're interested why check out this discord post.
  1. Run the bot node index.js.

Keeping it online with PM2


PM2 is an advanced, production process manager for Node.JS.

The Documentation can be found here.

Install it globally:

sudo npm install pm2 -g

Now navigate to the folder with the bot. ( cd /.....)

 pm2 start index.js

You can also specify more options:

# Specify an app name
--name <app_name>

# Watch and Restart app when files change
--watch

# Set memory threshold for app reload
--max-memory-restart <200MB>

# Specify log file
--log <log_path>

# Pass extra arguments to the script
-- arg1 arg2 arg3

# Delay between automatic restarts
--restart-delay <delay in ms>

# Prefix logs with time
--time

# Do not auto restart app
--no-autorestart

# Specify cron for forced restart
--cron <cron_pattern>

# Attach to application log
--no-daemon

Now everything is done! Check the status of pm2 with

$ pm2 status

Managing processes

Managing application state is simple here are the commands:

pm2 restart app_name
pm2 reload app_name
pm2 stop app_name
pm2 delete app_name

Instead of app_name you can pass:

  • all to act on all processes
  • id to act on a specific process id

For more informations check the documentation -> https://pm2.keymetrics.io/ and the quickstart guide -> https://pm2.keymetrics.io/docs/usage/quick-start/


Updating the code


First of all we have to stop the process manager pm2 Execute: pm2 status to get the id or the name of your app (Since we only have one here, the id should 0 and the name should be index)

Now stop the process with pm2 stop (name/id) in this case -> pm2 stop index

Now update the code in the respective folder via Git. go into the folder: cd.... git clone https://github.com/Myst82015/L-Union-des-R-listes.git

Then npm run install (just in case I added another npm module)


Update on 16.10.2020: IMPORTANT: To fix the problems with the incorrect membercounts go to setup guide above and check the intents (below point 4). Then regenerate the config npm run install( in the folder where the code is in), don't change anything at the preselected intents!

You're nearly done!

Navigate in the folder with the bot (cd ./....) and daemonize it with pm2 pm2 start index.js

Finally check the status of the process with pm2 status.

About

private discord bot for L'Union des Rôlistes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published