A Discord bot that tracks the usage of emotes within a Discord server.
Command and bot info can be found here.
- Install the database engine (See the database installation instructions)
- Install NodeJS version 8 or later
- Open a terminal in the bot's folder
- Run
npm install
First, you'll need a new bot account
- Head over to the applications page.
- Click "new application". Give it the name, picture, and description you want.
- Click "Create Bot User" and click "Yes, Do It!" when the dialog pops up.
- Copy down the
token
. This is what is used to log the bot in. - Put your
token
in an environment variable namedEMOTE_BOT_TOKEN
. If you don't know how to do that, google "How to define environment variable on" followed by your operating system (Windows, Linux, macOS, etc.)
Then, you'll need to invite the bot on a server
- Head over to the applications page.
- Click on your bot
- Click on the
Generate OAuth2 URL
button - Click the
COPY
button (the default values are good enough, if you know what you're doing, you can change them) - Paste the copied url into your browser
- Select the server you want the bot to be in
- Click the
Authorize
button
The bot comes with a default configuration file that allows it to work right out of
the box (once you set your environment variables), but you're able to override this
behavior. The example config file allows you to
specify config values in the same way they're defined in the defaults.
Once you've edited the example to your liking, simply rename it to config.json
.
Finally, you'll need to run the bot, see the next section for instructions about that.
- Open a terminal in the bot's folder
- Run
npm start
If you want to add some flags, you can do so by doing npm start --
and by adding a space before each flag. For example: npm start -- -c
for the -c
flag (see the Execution flags section for a list of flags).
Flags | Description |
---|---|
-c |
Adds colors to some console messages |
-d or --debug |
Enables debugging messages |
--no-backfill |
Disable the parsing of older messages |
--drop-tables |
Recreates all tables on bot startup |
--wipe-data |
Deletes all data on bot startup |
- Install PostgreSQL with
sudo apt install postgresql
- Change the password of the default user
- Log into the database by doing
sudo -u postgres psql
- Change the password with
ALTER USER postgres WITH PASSWORD 'new password'
(replacenew password
by the password you want)
- Log into the database by doing
- Change the config to enable password login on the postgres user
- Edit the postgres configuration file with
sudo vim /etc/postgresql/<version>/main/pg_hba.conf
- Find the
local all postgres peer
line - Change
peer
tomd5
- Edit the postgres configuration file with
- Restart PostgreSQL with
sudo service postgresql restart
- Create a database for the bot by running
createdb -U postgres <table name>
- Add the following to your environnement variables
PGUSER=postgres
PGPASSWORD=<the password you've set in point 2.2>
PGDATABASE=<the database you created in point 5>