mirror of
https://github.com/yuzu-emu/Command-fix.git
synced 2024-11-22 10:35:41 +01: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');
|
import discord = require('discord.js');
|
||||||
|
|
||||||
export const roles = ['Admins', 'Moderators', 'CitraBot'];
|
export const roles = ['Admins', 'Moderators', 'CitraBot'];
|
||||||
@ -8,11 +10,19 @@ export function command (message: discord.Message) {
|
|||||||
const alreadyJoined = member.roles.cache.has(role);
|
const alreadyJoined = member.roles.cache.has(role);
|
||||||
|
|
||||||
if (alreadyJoined) {
|
if (alreadyJoined) {
|
||||||
member.roles.remove(role);
|
member.roles.remove(role).then(() => {
|
||||||
message.channel.send(`${user.toString()}'s speech has been revoked in the #development channel.`);
|
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 {
|
} else {
|
||||||
member.roles.add(role);
|
member.roles.add(role).then(() => {
|
||||||
message.channel.send(`${user.toString()} has been granted speech in the #development channel.`);
|
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);
|
const cmd = message.content.split(' ', 1)[0].slice(1);
|
||||||
|
|
||||||
// Check by the name of the command.
|
// Check by the name of the command.
|
||||||
let cachedModule = cachedModules[`${cmd}.js`];
|
let cachedModule = cachedModules[`${cmd.toLowerCase()}`];
|
||||||
let quoteResponse = null;
|
let quoteResponse = null;
|
||||||
// Check by the quotes in the configuration.
|
// Check by the quotes in the configuration.
|
||||||
if (!cachedModule) quoteResponse = state.responses.quotes[cmd];
|
if (!cachedModule) quoteResponse = state.responses.quotes[cmd];
|
||||||
@ -167,8 +167,8 @@ client.on('message', message => {
|
|||||||
try {
|
try {
|
||||||
if (!!cachedModule) {
|
if (!!cachedModule) {
|
||||||
cachedModule.command(message);
|
cachedModule.command(message);
|
||||||
} else if (cachedModules['quote.js']) {
|
} else if (cachedModules['quote']) {
|
||||||
cachedModules['quote.js'].command(message, quoteResponse.reply);
|
cachedModules['quote'].command(message, quoteResponse.reply);
|
||||||
}
|
}
|
||||||
} catch (err) { logger.error(err); }
|
} catch (err) { logger.error(err); }
|
||||||
|
|
||||||
@ -183,8 +183,9 @@ fs.readdirSync('./commands/').forEach(function (file) {
|
|||||||
if (file.includes('.disabled')) {
|
if (file.includes('.disabled')) {
|
||||||
logger.info(`Did not load disabled module: ${file}`);
|
logger.info(`Did not load disabled module: ${file}`);
|
||||||
} else {
|
} else {
|
||||||
logger.info(`Loaded module: ${file}`);
|
const moduleName = path.basename(file, '.js').toLowerCase();
|
||||||
cachedModules[file] = require(`./commands/${file}`);
|
logger.info(`Loaded module: ${moduleName} from ${file}`);
|
||||||
|
cachedModules[moduleName] = require(`./commands/${file}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user