Add config option for prefixes

This commit is contained in:
1computer1 2019-05-16 21:02:44 -04:00
parent 9e9cf31329
commit f34cd8e427
4 changed files with 8 additions and 3 deletions

View file

@ -110,6 +110,8 @@ The container is locked down, so there is no networking, limited memory and CPU
- `owner` - The owner(s) of the bot.
Use an array for multiple owners.
- `token` - The bot token.
- `prefix` - The prefix for commands.
- `codePrefix` - The prefix for code evaluation.
- `languages` Languages to use.
The language names here are different from the user-facing ones.
Check the folders in `docker/` for the language names.

View file

@ -1,6 +1,8 @@
{
"owner": "12345678901234",
"token": "MTU1fdsYNTRb2RT.FcD2l1ig.jIuKqwertyd432RROhF5A",
"prefix": ">",
"codePrefix": ">",
"languages": [
"haskell",
"python",

View file

@ -59,8 +59,9 @@ class MessageInvalidListener extends Listener {
}
parseMessage(message) {
const regex1 = /^\s*>\s*(.+?)?\s*```(.+?)\n([^]+)```\s*$/;
const regex2 = /^\s*>\s*(.+?)?\s*`(.+?) \s*([^]+)`\s*$/;
const prefix = this.client.config.codePrefix.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
const regex1 = new RegExp(`^\\s*${prefix}\\s*(.+?)?\\s*\`\`\`(.+?)\\n([^]+)\`\`\`\\s*$`);
const regex2 = new RegExp(`^\\s*${prefix}\\s*(.+?)?\\s*\`(.+?) \\s*([^]+)\`\\s*$`);
const match = message.content.match(regex1) || message.content.match(regex2);
if (!match) {
return null;

View file

@ -13,7 +13,7 @@ class CompilerClient extends AkairoClient {
this.commandHandler = new CommandHandler(this, {
directory: path.join(__dirname, '../commands'),
prefix: '>',
prefix: config.prefix,
allowMention: true,
commandUtil: true,
commandUtilLifetime: 3e5,