4 Commits

Author SHA1 Message Date
Olly 01ef3cfb02 Merge pull request #5 from jcreek/add-command-disabling
feat(*): Add functionality to enable and disable moderator commands
2021-02-22 20:59:11 +00:00
jcreek 202d22b28b feat(*): Add functionality to enable and disable moderator commands 2021-02-21 10:23:05 +00:00
Olly Nicholass e6950df529 feat(*): Restrict ud command to the adult channel 2021-01-29 23:16:30 +00:00
jcreek 39cb0521fe fix(*): Add back in missing brackets 2021-01-29 19:44:39 +00:00
+38 -1
View File
@@ -3,6 +3,9 @@ const axios = require('axios');
const cheerio = require('cheerio');
const got = require('got');
let enableModCommands = false;
const adultChannelName = 'adult-only-chat';
module.exports = {
dailyTasks: function (client) {
sendDailyDilbert(client);
@@ -13,7 +16,27 @@ module.exports = {
commandHelp(Discord, config, logger, message, command, args);
break;
case 'ud':
if (message.channel.name === adultChannelName) {
commandUrbanDictionary(Discord, config, logger, message, command, args);
}
else {
const channel = message.client.channels.cache.find((channel) => channel.name === adultChannelName);
message.channel.send(`This command is restricted to the <#${channel.id}> channel.`);
}
break;
case 'enablemod':
commandModEnable(Discord, config, logger, message, command, args);
break;
case 'disablemod':
commandModDisable(Discord, config, logger, message, command, args);
break;
case 'examplemod':
if(enableModCommands) {
commandModExample(Discord, config, logger, message, command, args);
}
else {
message.channel.send(`That command is currently disabled. To find out more visit ${config.github_url}`);
}
break;
default:
message.channel.send(`That command is not one I know yet - but you could add it! To find out more visit ${config.github_url}`);
@@ -43,7 +66,7 @@ The commands available to you are:
}
}
function commandUrbanDictionary(Discord, config, logger, message, command, args) {
function commandUrbanDictionary (Discord, config, logger, message, command, args) {
if (!args.length) {
//If the command is used incorrectly without arguments
return message.channel.send(`You didn't provide any arguments, ${message.author}!\nCorrect Usage: \`${config.prefix}ud <query>\``);
@@ -94,6 +117,20 @@ function commandUrbanDictionary(Discord, config, logger, message, command, args)
.catch(function (error) {
logger.error('Failed to make GET request to Urban Dictionary API', error);
});
}
}
function commandModEnable (Discord, config, logger, message, command, args) {
enableModCommands = true;
}
function commandModDisable (Discord, config, logger, message, command, args) {
enableModCommands = false;
}
function commandModExample (Discord, config, logger, message, command, args) {
// This would be a Mod command that can be enabled and disabled using the enableModCommands variable
}
async function sendDailyDilbert(client) {
let comicImageUrl;