AttendanceBot is a Discord bot for guilds and other online communities to manage attendance.
I recommend hosting the bot on a free-tier EC2 instance.
- Set up application in the Discord Developer Portal.
- Add a bot user to the application. Copy the token. Don't share or commit it. Adjust .gitignore if needed.
- Invite bot to server. Recommended permissions
- Download files and test the bot locally.
npm install
tsc
node dist/src/index.js
- Launch instance and save the key pair provided.
- Convert .ppk to .pem with PuTTYgen.
- Connect to EC2 server with WinSCP (or any FTP client).
- Upload files.
- Install node & package dependencies.
$ sudo apt-get update
$ sudo apt-get install nodejs
$ sudo apt-get install npm
$ npm install
-
Install forever module
$ sudo npm install forever -g
. I highly suggest reading the logging options and also specifying logging files. -
Run application
$ forever start index.js
- Never have more than one running instance (especially for a long period of time)
- Set up billing notifications
- Free instances last 1 year before they are not free (on that account)
To customize the bot for your community, a few edits will be needed.
-
Create your appSettings. Start by copying the appSettings to a new file. Customize the data accordingly. I usually set up appSettings.dev.json and appSettings.prod.json (one with keys for a dev Discord server, another with the "main" server).
-
Create the channels and roles as described in appSettings.
-
In index.ts, point the app to the appSettings you wish to use. e.g.
import * as appSettings from '../appSettings.prod.json';
Recompile tsc
.
/start
, /s
Starts attendance.
/end
, /e
Ends attendance.
/end --nolog
, /e --nolog
/refreshpublic
Refresh public attendance chart.
/refreshinternal
Refresh bot data (refetches messages and composes new maps of data).
/refreshmembers
Refresh member list (done automatically in most cases).
/totalraids
Responds with total raids logged.
/edit --attendance
, /edit --seniority
Edit blocks of attendance/seniority.
/edit --attendance {"value":[["200099393041465345",100]
First, enter snippet of data you want to edit. Must return a single entry to be valid. I find it easiest to just paste the whole object.
```{obj}```
Then enter full object you want to replace it with surrounded by code block tags.
/clear --attendance
Clear attendance/seniority for member.
/clear --attendance "Member Name"
Clearing attendance is only needed in very specific cases. Useful if a member leaves then rejoins at a later date and you want to only count the new attendance. Not required in general for members who leave.
/import --attendance
, /import --seniority
Import existing data.
/import --attendance attendance-1-1-2021.json
Attendance/seniority backups are saved automatically to /backups. Files may need to be moved before they can be successfully restored (or adjust path accordingly).
/test
(to bot in DMs)
Will respond 'Bot running.' if running.