Blacklist/Whitelist, cleaner coolness

This commit is contained in:
Daniel Odendahl Jr
2018-03-20 22:10:53 +00:00
parent 53fa2492fc
commit 43e62c289a
7 changed files with 97 additions and 22 deletions
+10 -11
View File
@@ -1,4 +1,5 @@
const { Command } = require('discord.js-commando');
const levels = require('../../assets/json/coolness');
module.exports = class CoolnessCommand extends Command {
constructor(client) {
@@ -19,16 +20,14 @@ module.exports = class CoolnessCommand extends Command {
}
run(msg, { user }) {
const coolness = user.id / this.client.user.id;
if (coolness < 0.2) return msg.say(`${user.username} is the coolest being to walk this Earth.`);
if (coolness < 0.4) return msg.say(`${user.username} is extremely amazingly amazing.`);
if (coolness < 0.6) return msg.say(`${user.username} is as cool as ice.`);
if (coolness < 0.8) return msg.say(`${user.username} is an extremely cool dude.`);
if (coolness < 1) return msg.say(`${user.username} is pretty sweet, not gonna lie.`);
if (coolness < 1.2) return msg.say(`${user.username} is okay, nothing special.`);
if (coolness < 1.4) return msg.say(`${user.username} is just not all that neat.`);
if (coolness < 1.6) return msg.say(`${user.username} is awful, honestly.`);
if (coolness < 1.8) return msg.say(`${user.username} smells like a sack of diapers.`);
return msg.say(`${user.username} is terrible in every way.`);
const coolness = Math.round(((user.id / this.client.user.id) * 10) / 2);
if (user.id === this.client.user.id) return msg.say('Me? I think I\'m the very best, like no one ever was.');
if (this.client.isOwner(user)) {
if (this.client.isOwner(msg.author)) {
return msg.say(`${user.username}, you're the best owner a bot could ask for! ❤`);
}
return msg.say(`Don't tell them I said this but I think ${user.username} ${levels[levels.length - 1]}`);
}
return msg.say(`${user.username} ${levels[Math.min(coolness, levels.length - 1)]}`);
}
};
+8 -9
View File
@@ -28,22 +28,21 @@ module.exports = class IllegalCommand extends Command {
parse: text => text.toUpperCase()
},
{
key: 'isOrAre',
label: 'is or are',
prompt: 'Should the text use is or are?',
key: 'verb',
prompt: 'Should the text use is, are, or am?',
type: 'string',
default: 'IS',
validate: isOrAre => {
if (['is', 'are'].includes(isOrAre.toLowerCase())) return true;
return 'Invalid is or are, please enter either is or are.';
validate: verb => {
if (['is', 'are', 'am'].includes(verb.toLowerCase())) return true;
return 'Invalid verb, please enter either is, are, or am.';
},
parse: isOrAre => isOrAre.toUpperCase()
parse: verb => verb.toUpperCase()
}
]
});
}
async run(msg, { text, isOrAre }) {
async run(msg, { text, verb }) {
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'illegal.png'));
const canvas = createCanvas(base.width, base.height);
const ctx = canvas.getContext('2d');
@@ -52,7 +51,7 @@ module.exports = class IllegalCommand extends Command {
ctx.font = '45px Noto';
ctx.fillText(stripIndents`
${shortenText(ctx, text, 200)}
${isOrAre} NOW
${verb} NOW
ILLEGAL.
`, 750, 290);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'illegal.png' }] });
+31
View File
@@ -0,0 +1,31 @@
const { Command } = require('discord.js-commando');
module.exports = class BlacklistCommand extends Command {
constructor(client) {
super(client, {
name: 'blacklist',
aliases: ['blacklist-add'],
group: 'util',
memberName: 'blacklist',
description: 'Blacklists a user from using commands.',
ownerOnly: true,
args: [
{
key: 'user',
prompt: 'What user do you want to blacklist?',
type: 'user'
}
]
});
}
run(msg, { user }) {
if (this.client.isOwner(msg.author)) return msg.reply('The bot owner cannot be blacklisted.');
if (user.bot) return msg.reply('Bots cannot be blacklisted.');
const blacklist = this.client.provider.get('global', 'blacklist', []);
if (blacklist.includes(user.id)) return msg.reply(`${user.tag} is already blacklisted!`);
blacklist.push(blacklist.id);
this.client.provider.set('global', 'blacklist', blacklist);
return msg.say(`${user.tag} has been blacklisted.`);
}
};
+32
View File
@@ -0,0 +1,32 @@
const { Command } = require('discord.js-commando');
module.exports = class WhitelistCommand extends Command {
constructor(client) {
super(client, {
name: 'whitelist',
aliases: ['blacklist-remove', 'blacklist-delete'],
group: 'util',
memberName: 'whitelist',
description: 'Removes a user from the blacklist.',
ownerOnly: true,
args: [
{
key: 'user',
prompt: 'What user do you want to whitelist?',
type: 'user'
}
]
});
}
run(msg, { user }) {
if (this.client.isOwner(msg.author)) return msg.reply('The bot owner cannot be blacklisted.');
if (user.bot) return msg.reply('Bots cannot be blacklisted.');
const blacklist = this.client.provider.get('global', 'blacklist', []);
if (!blacklist.includes(user.id)) return msg.reply(`${user.tag} is not blacklisted!`);
blacklist.splice(blacklist.indexOf(user.id), 1);
if (!blacklist.length) this.client.provider.remove('global', 'blacklist');
else this.client.provider.set('global', 'blacklist', blacklist);
return msg.say(`${user.tag} has been whitelisted.`);
}
};