You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Chris Mahoney 179dcb5740 refactor rules 2 months ago
db/models started letters 5 months ago
src refactor rules 2 months ago
.dockerignore started letters 5 months ago
.gitignore started letters 5 months ago
.sequelizerc started letters 5 months ago
README.md started letters 5 months ago
config.js started letters 5 months ago
docker-compose.yaml started letters 5 months ago
dockerfile started letters 5 months ago
package-lock.json update packages 2 months ago
package.json started letters 5 months ago
tsconfig.json started letters 5 months ago

README.md

EnforcerBot2

Discord bot that enforces the rules on my server. The bot is currently running on dubsdot2.

Running

Clone the repo

git clone https://gitea.cslabs.clarkson.edu/mahonec/EnforcerBot2.git

Ignore the error and checkout the main branch

cd EnforcerBot2
git checkout main

Create a .env file and add your bot's api token like so:

TOKEN=<copy and paste the token>

Finally as root bring the service up with docker-compose

sudo docker-compose up -d

Adding rules

Rules are relatively straight forward to add. In rules.ts there is a Map named rules that maps channel.id strings to callback functions; like so:

var rules : Map<string, (msg: Discord.Message) => void> = new Map();

So adding a new rule is as simple as:

// # no posting whatsoever
rules.set("826181775981019156", function(msg) {
    msg.delete();
});

Now whenever a message is posted or edited index.ts will check if msg.channel.id has an associated function and, if so, it will call that with msg:

// get the rule
let rule : ((msg: Discord.Message) => void) | undefined = rules.get(msg.channel.id);
// check if the rule exists
if (rule != undefined) {
    // callback
    rule(msg);
}