mirror of
https://github.com/citra-emu/discord-bot.git
synced 2024-12-22 19:36:07 +00:00
bugfixes: more robust grantDeveloper command...
... and command is now case insensitive
This commit is contained in:
parent
59821a21d3
commit
b42c3eaf88
|
@ -1,3 +1,5 @@
|
|||
import state from '../state';
|
||||
import logger from '../logging';
|
||||
import discord = require('discord.js');
|
||||
|
||||
export const roles = ['Admins', 'Moderators', 'CitraBot'];
|
||||
|
@ -8,11 +10,19 @@ export function command (message: discord.Message) {
|
|||
const alreadyJoined = member.roles.cache.has(role);
|
||||
|
||||
if (alreadyJoined) {
|
||||
member.roles.remove(role);
|
||||
message.channel.send(`${user.toString()}'s speech has been revoked in the #development channel.`);
|
||||
member.roles.remove(role).then(() => {
|
||||
message.channel.send(`${user.toString()}'s speech has been revoked in the #development channel.`);
|
||||
}).catch(() => {
|
||||
state.logChannel.send(`Error revoking ${user.toString()}'s developer speech...`);
|
||||
logger.error(`Error revoking ${user} ${user.username}'s developer speech...`);
|
||||
});
|
||||
} else {
|
||||
member.roles.add(role);
|
||||
message.channel.send(`${user.toString()} has been granted speech in the #development channel.`);
|
||||
member.roles.add(role).then(() => {
|
||||
message.channel.send(`${user.toString()} has been granted speech in the #development channel.`);
|
||||
}).catch(() => {
|
||||
state.logChannel.send(`Error granting ${user.toString()}'s developer speech...`);
|
||||
logger.error(`Error granting ${user} ${user.username}'s developer speech...`);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ client.on('message', message => {
|
|||
const cmd = message.content.split(' ', 1)[0].slice(1);
|
||||
|
||||
// Check by the name of the command.
|
||||
let cachedModule = cachedModules[`${cmd}.js`];
|
||||
let cachedModule = cachedModules[`${cmd.toLowerCase()}`];
|
||||
let quoteResponse = null;
|
||||
// Check by the quotes in the configuration.
|
||||
if (!cachedModule) quoteResponse = state.responses.quotes[cmd];
|
||||
|
@ -167,8 +167,8 @@ client.on('message', message => {
|
|||
try {
|
||||
if (!!cachedModule) {
|
||||
cachedModule.command(message);
|
||||
} else if (cachedModules['quote.js']) {
|
||||
cachedModules['quote.js'].command(message, quoteResponse.reply);
|
||||
} else if (cachedModules['quote']) {
|
||||
cachedModules['quote'].command(message, quoteResponse.reply);
|
||||
}
|
||||
} catch (err) { logger.error(err); }
|
||||
|
||||
|
@ -183,8 +183,9 @@ fs.readdirSync('./commands/').forEach(function (file) {
|
|||
if (file.includes('.disabled')) {
|
||||
logger.info(`Did not load disabled module: ${file}`);
|
||||
} else {
|
||||
logger.info(`Loaded module: ${file}`);
|
||||
cachedModules[file] = require(`./commands/${file}`);
|
||||
const moduleName = path.basename(file, '.js').toLowerCase();
|
||||
logger.info(`Loaded module: ${moduleName} from ${file}`);
|
||||
cachedModules[moduleName] = require(`./commands/${file}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue