- Download and install NodeJS.
npm install --no-optional
- Make a bot account.
- Edit the config, placing the bot token in the config.
- Invite the bot to your Discord with a link like
https://discordapp.com/api/oauth2/authorize?client_id=CLIENT_ID&scope=bot&permissions=4
, replacingCLIENT_ID
with the one on the developer page. - Party?
Created
January 18, 2018 05:21
-
-
Save Tylian/f574a5f95ba05e43ae39685404f2067c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"token": "REPLACE ME (see readme)", | |
"keywords": ["booty", "doodoo", "poopie"] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Eris = require("eris"); | |
const config = require("./config.json"); | |
const regex = new RegExp(`(?:${config["keywords"].map(keyword => keyword.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&")).join("|")})`); | |
var bot = new Eris(config["token"]); | |
bot.on("messageCreate", message => { | |
let match = message.content.match(regex); | |
if(match && typeof message.channel.guild !== "undefined") { | |
bot.banGuildMember(message.channel.guild.id, message.author.id, 0, `User said "${match[0]}"`).catch(e => { | |
console.log(`Failed to ban ${message.author.username}#${message.author.discriminator}. Do I have permission to ban people?\n\n${e.message}`); | |
}); | |
} | |
}); | |
bot.connect(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "banbot", | |
"version": "1.0.0", | |
"description": "A Discord bot that bans when keywords are mentioned.", | |
"main": "index.js", | |
"author": "Tylian", | |
"license": "WTFPL", | |
"dependencies": { | |
"eris": "^0.8.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment