diff --git a/.gitignore b/.gitignore index 5dfafe18..4e3d1e5f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,6 @@ -# Logs -logs +# Packages +node_modules/ + +# Log Files +logs/ *.log -npm-debug.log* - -# Compiled binary addons (http://nodejs.org/api/addons.html) -build/Release - -# Dependency directory -# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git -node_modules diff --git a/XiaoBot.js b/XiaoBot.js index 595c62a6..47b6e296 100644 --- a/XiaoBot.js +++ b/XiaoBot.js @@ -56,18 +56,19 @@ client.dispatcher.addInhibitor((msg) => { if (msg.channel.type === 'dm') return false; const role = msg.guild.settings.get('singleRole'); if (!msg.guild.roles.has(role) || msg.member.hasPermission('ADMINISTRATOR')) return false; - if (!msg.member.roles.has(role)) { - return ['singleRole', msg.reply(`Only the ${msg.guild.roles.get(role).name} role may use commands.`)]; - } else { - return false; - } + if (!msg.member.roles.has(role)) return 'single role'; + else return false; }); client.on('message', (msg) => { - if (!msg.guild || !msg.guild.settings.get('inviteGuard')) return; + if (!msg.channel.permissionsFor(client.user).has('SEND_MESSAGES')) return; if (/(discord(\.gg\/|app\.com\/invite\/|\.me\/))/gi.test(msg.content)) { + if (!msg.guild || !msg.guild.settings.get('inviteGuard')) return; if (msg.author.bot || msg.member.hasPermission('ADMINISTRATOR')) return; - if (!msg.channel.permissionsFor(client.user).has(['SEND_MESSAGES', 'MANAGE_MESSAGES'])) return; + if (!msg.channel.permissionsFor(client.user).has('MANAGE_MESSAGES')) { + msg.say('Could not delete invite, missing permissions.'); + return; + } msg.delete(); msg.reply('Invites are prohibited from being posted here.'); } @@ -75,23 +76,20 @@ client.on('message', (msg) => { client.on('messageReactionAdd', (reaction, user) => { if (reaction.emoji.name !== '⭐') return; - const { message } = reaction; - const channel = message.guild.channels.get(message.guild.settings.get('starboard')); - if (!channel) return; - if (!message.channel.permissionsFor(client.user).has(['SEND_MESSAGES', 'MANAGE_MESSAGES'])) return; - if (user.id === message.author.id) { + const msg = reaction.message; + const channel = msg.guild.channels.get(msg.guild.settings.get('starboard')); + if (!channel || !msg.channel.permissionsFor(client.user).has(['SEND_MESSAGES', 'MANAGE_MESSAGES'])) return; + if (user.id === msg.author.id) { reaction.remove(user); - message.reply('You cannot star your own messages, baka.'); + msg.reply('You cannot star your own messages, baka.'); return; } - client.registry.resolveCommand('random:star').run(message, { id: message.id }, true); + client.registry.resolveCommand('random:star').run(msg, { id: msg.id }, true); }); client.on('guildMemberAdd', (member) => { const role = member.guild.roles.get(member.guild.settings.get('joinRole')); - if (role && member.guild.me.hasPermission('MANAGE_ROLES')) { - member.addRole(role).catch(() => null); - } + if (role && member.guild.me.hasPermission('MANAGE_ROLES')) member.addRole(role).catch(() => null); const channel = member.guild.channels.get(member.guild.settings.get('memberLog')); if (!channel || !channel.permissionsFor(client.user).has('SEND_MESSAGES')) return; const msg = member.guild.settings.get('joinMsg', 'Welcome !') diff --git a/assets/fonts/NotoEmoji-Regular.ttf b/assets/fonts/NotoEmoji-Regular.ttf new file mode 100644 index 00000000..19b7badf Binary files /dev/null and b/assets/fonts/NotoEmoji-Regular.ttf differ diff --git a/assets/fonts/OpenSans.ttf b/assets/fonts/OpenSans.ttf deleted file mode 100644 index db433349..00000000 Binary files a/assets/fonts/OpenSans.ttf and /dev/null differ diff --git a/assets/fonts/Roboto.ttf b/assets/fonts/Roboto.ttf new file mode 100644 index 00000000..8c082c8d Binary files /dev/null and b/assets/fonts/Roboto.ttf differ diff --git a/assets/images/spam.png b/assets/images/spam.png deleted file mode 100644 index cf2d7f1d..00000000 Binary files a/assets/images/spam.png and /dev/null differ diff --git a/assets/json/user-info.json b/assets/json/user-info.json new file mode 100644 index 00000000..73ccf3e2 --- /dev/null +++ b/assets/json/user-info.json @@ -0,0 +1,18 @@ +{ + "online": { + "text": "<:online:313956277808005120> Online", + "color": "#00AE86" + }, + "idle": { + "text": "<:away:313956277220802560> Idle", + "color": "#FFFF00" + }, + "dnd": { + "text": "<:dnd:313956276893646850> Do Not Disturb", + "color": "#FF0000" + }, + "offline": { + "text": "<:offline:313956277237710868> Offline", + "color": "#808080" + } +}; diff --git a/commands/avataredit/3000-years.js b/commands/avataredit/3000-years.js index f566cb2f..e136b45c 100644 --- a/commands/avataredit/3000-years.js +++ b/commands/avataredit/3000-years.js @@ -31,8 +31,10 @@ module.exports = class YearsCommand extends Command { async run(msg, args) { const user = args.user || msg.author; - const avatarURL = user.avatarURL('png', 256); - if (!avatarURL) return msg.say('The User Provided has No Avatar.'); + const avatarURL = user.displayAvatarURL({ + format: 'png', + size: 256 + }); const Image = Canvas.Image; const canvas = new Canvas(856, 569); const ctx = canvas.getContext('2d'); diff --git a/commands/avataredit/beautiful.js b/commands/avataredit/beautiful.js index fd30bbaa..5c9db62f 100644 --- a/commands/avataredit/beautiful.js +++ b/commands/avataredit/beautiful.js @@ -31,8 +31,10 @@ module.exports = class BeautifulCommand extends Command { async run(msg, args) { const user = args.user || msg.author; - const avatarURL = user.avatarURL('png', 256); - if (!avatarURL) return msg.say('The User Provided has No Avatar.'); + const avatarURL = user.displayAvatarURL({ + format: 'png', + size: 256 + }); const Image = Canvas.Image; const canvas = new Canvas(500, 532); const ctx = canvas.getContext('2d'); diff --git a/commands/avataredit/bob-ross.js b/commands/avataredit/bob-ross.js index 8dd12b85..380be550 100644 --- a/commands/avataredit/bob-ross.js +++ b/commands/avataredit/bob-ross.js @@ -31,8 +31,10 @@ module.exports = class BobRossCommand extends Command { async run(msg, args) { const user = args.user || msg.author; - const avatarURL = user.avatarURL('png', 256); - if (!avatarURL) return msg.say('The User Provided has No Avatar.'); + const avatarURL = user.displayAvatarURL({ + format: 'png', + size: 256 + }); const Image = Canvas.Image; const canvas = new Canvas(600, 775); const ctx = canvas.getContext('2d'); diff --git a/commands/avataredit/card.js b/commands/avataredit/card.js index e0292df6..70ae6b08 100644 --- a/commands/avataredit/card.js +++ b/commands/avataredit/card.js @@ -34,15 +34,18 @@ module.exports = class CardCommand extends Command { async run(msg, args) { const member = args.member || msg.member; - const avatarURL = member.user.avatarURL('png', 256); - if (!avatarURL) return msg.say('The User Provided has No Avatar.'); + const avatarURL = member.displayAvatarURL({ + format: 'png', + size: 256 + }); const cardID = Math.floor(Math.random() * (9999 - 1000 + 1)) + 1000; let rarity; if (cardID < 5000) rarity = 'C'; else if (cardID < 8000) rarity = 'U'; else rarity = 'R'; const Image = Canvas.Image; - Canvas.registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'OpenSans.ttf'), { family: 'Open Sans' }); // eslint-disable-line max-len + Canvas.registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Roboto.ttf'), { family: 'Roboto' }); // eslint-disable-line max-len + Canvas.registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'NotoEmoji-Regular.ttf'), { family: 'Roboto' }); // eslint-disable-line max-len const canvas = new Canvas(390, 544); const ctx = canvas.getContext('2d'); const base = new Image(); @@ -52,7 +55,7 @@ module.exports = class CardCommand extends Command { ctx.fillRect(0, 0, 390, 544); ctx.drawImage(avatar, 11, 11, 370, 370); ctx.drawImage(base, 0, 0); - ctx.font = '18px Open Sans'; + ctx.font = '18px Roboto'; ctx.fillStyle = 'black'; ctx.fillText(member.displayName, 30, 62); ctx.fillText('Discord Join Date:', 148, 400); diff --git a/commands/avataredit/challenger.js b/commands/avataredit/challenger.js index 89698a34..c88b53cf 100644 --- a/commands/avataredit/challenger.js +++ b/commands/avataredit/challenger.js @@ -30,8 +30,10 @@ module.exports = class ChallengerCommand extends Command { async run(msg, args) { const user = args.user || msg.author; - const avatarURL = user.avatarURL('png', 256); - if (!avatarURL) return msg.say('The User Provided has No Avatar.'); + const avatarURL = user.displayAvatarURL({ + format: 'png', + size: 256 + }); const Image = Canvas.Image; const canvas = new Canvas(500, 500); const ctx = canvas.getContext('2d'); diff --git a/commands/avataredit/dexter.js b/commands/avataredit/dexter.js index 8c708678..448d4148 100644 --- a/commands/avataredit/dexter.js +++ b/commands/avataredit/dexter.js @@ -30,8 +30,10 @@ module.exports = class DexterCommand extends Command { async run(msg, args) { const user = args.user || msg.author; - const avatarURL = user.avatarURL('png', 256); - if (!avatarURL) return msg.say('The User Provided has No Avatar.'); + const avatarURL = user.displayAvatarURL({ + format: 'png', + size: 256 + }); const Image = Canvas.Image; const canvas = new Canvas(744, 554); const ctx = canvas.getContext('2d'); diff --git a/commands/avataredit/greyscale.js b/commands/avataredit/greyscale.js index 449ef2c2..2588d532 100644 --- a/commands/avataredit/greyscale.js +++ b/commands/avataredit/greyscale.js @@ -28,8 +28,10 @@ module.exports = class GreyscaleCommand extends Command { async run(msg, args) { const user = args.user || msg.author; - const avatarURL = user.avatarURL('png', 256); - if (!avatarURL) return msg.say('The User Provided has No Avatar.'); + const avatarURL = user.displayAvatarURL({ + format: 'png', + size: 256 + }); const Image = Canvas.Image; const canvas = new Canvas(256, 256); const ctx = canvas.getContext('2d'); diff --git a/commands/avataredit/invert.js b/commands/avataredit/invert.js index 63efb9e0..6ba9a5e8 100644 --- a/commands/avataredit/invert.js +++ b/commands/avataredit/invert.js @@ -27,8 +27,10 @@ module.exports = class InvertCommand extends Command { async run(msg, args) { const user = args.user || msg.author; - const avatarURL = user.avatarURL('png', 256); - if (!avatarURL) return msg.say('The User Provided has No Avatar.'); + const avatarURL = user.displayAvatarURL({ + format: 'png', + size: 256 + }); const Image = Canvas.Image; const canvas = new Canvas(256, 256); const ctx = canvas.getContext('2d'); diff --git a/commands/avataredit/rip.js b/commands/avataredit/rip.js index 22328ef9..2b96fc68 100644 --- a/commands/avataredit/rip.js +++ b/commands/avataredit/rip.js @@ -31,8 +31,10 @@ module.exports = class RIPCommand extends Command { async run(msg, args) { const user = args.user || msg.author; - const avatarURL = user.avatarURL('png', 256); - if (!avatarURL) return msg.say('The User Provided has No Avatar.'); + const avatarURL = user.displayAvatarURL({ + format: 'png', + size: 256 + }); const Image = Canvas.Image; const canvas = new Canvas(507, 338); const ctx = canvas.getContext('2d'); diff --git a/commands/avataredit/simba.js b/commands/avataredit/simba.js index d813153c..ea65e9c0 100644 --- a/commands/avataredit/simba.js +++ b/commands/avataredit/simba.js @@ -30,8 +30,10 @@ module.exports = class SimbaCommand extends Command { async run(msg, args) { const user = args.user || msg.author; - const avatarURL = user.avatarURL('png', 256); - if (!avatarURL) return msg.say('The User Provided has No Avatar.'); + const avatarURL = user.displayAvatarURL({ + format: 'png', + size: 256 + }); const Image = Canvas.Image; const canvas = new Canvas(500, 281); const ctx = canvas.getContext('2d'); diff --git a/commands/avataredit/steam-card.js b/commands/avataredit/steam-card.js index 4e42a210..65c97db2 100644 --- a/commands/avataredit/steam-card.js +++ b/commands/avataredit/steam-card.js @@ -30,10 +30,13 @@ module.exports = class SteamCardCommand extends Command { async run(msg, args) { const user = args.user || msg.author; - const avatarURL = user.avatarURL('png', 512); - if (!avatarURL) return msg.say('The User Provided has No Avatar.'); + const avatarURL = user.displayAvatarURL({ + format: 'png', + size: 256 + }); const Image = Canvas.Image; - Canvas.registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'OpenSans.ttf'), { family: 'Open Sans' }); // eslint-disable-line max-len + Canvas.registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Roboto.ttf'), { family: 'Roboto' }); // eslint-disable-line max-len + Canvas.registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'NotoEmoji-Regular.ttf'), { family: 'Roboto' }); // eslint-disable-line max-len const canvas = new Canvas(494, 568); const ctx = canvas.getContext('2d'); const base = new Image(); @@ -43,7 +46,7 @@ module.exports = class SteamCardCommand extends Command { ctx.fillRect(0, 0, 494, 568); ctx.drawImage(avatar, 25, 25, 450, 450); ctx.drawImage(base, 0, 0); - ctx.font = '30px Open Sans'; + ctx.font = '30px Roboto'; ctx.fillText(user.username, 35, 48); }; base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'steam-card.png')); diff --git a/commands/avataredit/triggered.js b/commands/avataredit/triggered.js index e3fe663c..0827aeca 100644 --- a/commands/avataredit/triggered.js +++ b/commands/avataredit/triggered.js @@ -30,8 +30,10 @@ module.exports = class TriggeredCommand extends Command { async run(msg, args) { const user = args.user || msg.author; - const avatarURL = user.avatarURL('png', 512); - if (!avatarURL) return msg.say('The User Provided has No Avatar.'); + const avatarURL = user.displayAvatarURL({ + format: 'png', + size: 256 + }); const Image = Canvas.Image; const canvas = new Canvas(320, 371); const ctx = canvas.getContext('2d'); diff --git a/commands/avataredit/wanted.js b/commands/avataredit/wanted.js index c84f7128..29661611 100644 --- a/commands/avataredit/wanted.js +++ b/commands/avataredit/wanted.js @@ -30,8 +30,10 @@ module.exports = class WantedCommand extends Command { async run(msg, args) { const user = args.user || msg.author; - const avatarURL = user.avatarURL('png', 512); - if (!avatarURL) return msg.say('The User Provided has No Avatar.'); + const avatarURL = user.displayAvatarURL({ + format: 'png', + size: 256 + }); const Image = Canvas.Image; const canvas = new Canvas(741, 1000); const ctx = canvas.getContext('2d'); diff --git a/commands/games/battle.js b/commands/games/battle.js index 7b4bb025..dbaeb4a4 100644 --- a/commands/games/battle.js +++ b/commands/games/battle.js @@ -22,91 +22,87 @@ module.exports = class BattleCommand extends Command { this.fighting = new Set(); } - async run(msg, args) { // eslint-disable-line complexity + async run(msg, args) { const { opponent } = args; if (opponent.bot) return msg.say('Bots cannot be fought.'); if (opponent.id === msg.author.id) return msg.say('You may not fight yourself.'); if (this.fighting.has(msg.guild.id)) return msg.say('Only one fight may be occurring per server.'); this.fighting.add(msg.guild.id); await msg.say(`**${opponent.username}**, do you accept this challenge? **__Y__es** or **No**?`); - try { - const verify = await msg.channel.awaitMessages((res) => res.author.id === opponent.id, { - max: 1, - time: 15000, - errors: ['time'] - }); - if (!['yes', 'y'].includes(verify.first().content.toLowerCase())) { - this.fighting.delete(msg.guild.id); - return msg.say('Guess that was a no then...'); - } - let userHP = 500; - let oppoHP = 500; - let userTurn = false; - let guard = false; - const reset = () => { - if (userTurn) userTurn = false; - else userTurn = true; - if (guard) guard = false; - }; - const dealDamage = (damage) => { - if (userTurn) oppoHP -= damage; - else userHP -= damage; - }; - while (userHP > 0 && oppoHP > 0) { // eslint-disable-line no-unmodified-loop-condition - const username = userTurn ? msg.author.username : opponent.username; - const id = userTurn ? msg.author.id : opponent.id; - await msg.say(stripIndents` - **${username}**, do you **fight**, **guard**, **special**, or **run**? - **${msg.author.username}**: ${userHP}HP - **${opponent.username}**: ${oppoHP}HP - `); - try { - const turn = await msg.channel.awaitMessages((res) => res.author.id === id, { - max: 1, - time: 15000, - errors: ['time'] - }); - const choice = turn.first().content.toLowerCase(); - if (choice === 'fight') { - const damage = Math.floor(Math.random() * (guard ? 10 : 100)) + 1; - await msg.say(`**${username}** deals **${damage}** damage!`); - dealDamage(damage); - reset(); - } else if (choice === 'guard') { - await msg.say(`**${username}** guards!`); - reset(); - guard = true; - } else if (choice === 'special') { - const hit = Math.floor(Math.random() * 4) + 1; - if (hit === 1) { - const damage = Math.floor(Math.random() * ((guard ? 300 : 150) - 100 + 1) + 100); - await msg.say(`**${username}** deals **${damage}** damage!`); - dealDamage(damage); - reset(); - } else { - await msg.say(`**${username}**'s attack missed!`); - reset(); - } - } else if (choice === 'run') { - await msg.say(`**${username}** flees!`); - break; - } else { - await msg.say('I do not understand what you want to do.'); - } - } catch (err) { - await msg.say('Time!'); - break; - } - } - this.fighting.delete(msg.guild.id); - return msg.say(stripIndents` - The match is over! - **Winner:** ${userHP > oppoHP ? msg.author.username : opponent.username} - **Loser:** ${userHP > oppoHP ? opponent.username : msg.author.username} - `); - } catch (err) { + const verify = await msg.channel.awaitMessages((res) => res.author.id === opponent.id, { + max: 1, + time: 30000 + }); + if (!verify.size || !['yes', 'y'].includes(verify.first().content.toLowerCase())) { this.fighting.delete(msg.guild.id); return msg.say('Looks like they declined...'); } + let userHP = 500; + let oppoHP = 500; + let userTurn = false; + let guard = false; + const reset = (changeGuard = true) => { + if (userTurn) userTurn = false; + else userTurn = true; + if (changeGuard && guard) guard = false; + }; + const dealDamage = (damage) => { + if (userTurn) oppoHP -= damage; + else userHP -= damage; + }; + const forfeit = () => { + if (userTurn) userHP -= 500 - userHP; + else oppoHP -= 500 - oppoHP; + }; + while (userHP > 0 && oppoHP > 0) { // eslint-disable-line no-unmodified-loop-condition + const username = userTurn ? msg.author.username : opponent.username; + const id = userTurn ? msg.author.id : opponent.id; + await msg.say(stripIndents` + **${username}**, do you **fight**, **guard**, **special**, or **run**? + **${msg.author.username}**: ${userHP}HP + **${opponent.username}**: ${oppoHP}HP + `); + const turn = await msg.channel.awaitMessages((res) => res.author.id === id, { + max: 1, + time: 30000 + }); + if (!turn.size) { + await msg.say('Time!'); + forfeit(); + } + const choice = turn.first().content.toLowerCase(); + if (choice === 'fight') { + const damage = Math.floor(Math.random() * (guard ? 10 : 100)) + 1; + await msg.say(`**${username}** deals **${damage}** damage!`); + dealDamage(damage); + reset(); + } else if (choice === 'guard') { + await msg.say(`**${username}** guards!`); + guard = true; + reset(false); + } else if (choice === 'special') { + const hit = Math.floor(Math.random() * 4) + 1; + if (hit === 1) { + const damage = Math.floor(Math.random() * ((guard ? 300 : 150) - 100 + 1) + 100); + await msg.say(`**${username}** deals **${damage}** damage!`); + dealDamage(damage); + reset(); + } else { + await msg.say(`**${username}**'s attack missed!`); + reset(); + } + } else if (choice === 'run') { + await msg.say(`**${username}** flees!`); + forfeit(); + } else { + await msg.say('I do not understand what you want to do.'); + } + } + this.fighting.delete(msg.guild.id); + return msg.say(stripIndents` + The match is over! + **Winner:** ${userHP > oppoHP ? `${msg.author.username} (${userHP}HP)` : `${opponent.username} (${oppoHP}HP)`} + **Loser:** ${userHP > oppoHP ? `${opponent.username} (${oppoHP}HP)` : `${msg.author.username} (${userHP}HP)`} + `); } }; diff --git a/commands/games/math-game.js b/commands/games/math-game.js index 47c7a0ee..768ef39b 100644 --- a/commands/games/math-game.js +++ b/commands/games/math-game.js @@ -38,16 +38,13 @@ module.exports = class MathGameCommand extends Command { .setTitle('You have 10 seconds to answer:') .setDescription(expression); await msg.embed(embed); - try { - const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, { - max: 1, - time: 10000, - errors: ['time'] - }); - if (collected.first().content !== answer) return msg.say(`Nope, sorry, it's ${answer}.`); - else return msg.say('Nice job! 10/10! You deserve some cake!'); - } catch (err) { - return msg.say(`Time! It was ${answer}, sorry!`); - } + const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, { + max: 1, + time: 10000 + }); + if (!collected.size) return msg.say(`Time! It was ${answer}, sorry!`); + if (collected.first().content !== answer) return msg.say(`Nope, sorry, it's ${answer}.`); + else return msg.say('Nice job! 10/10! You deserve some cake!'); + } }; diff --git a/commands/games/quiz.js b/commands/games/quiz.js index ca0a6f53..563c1543 100644 --- a/commands/games/quiz.js +++ b/commands/games/quiz.js @@ -31,16 +31,12 @@ module.exports = class QuizCommand extends Command { True or False: ${decodeURIComponent(body.results[0].question)} `); await msg.embed(embed); - try { - const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, { - max: 1, - time: 15000, - errors: ['time'] - }); - if (collected.first().content.toLowerCase() !== answer) return msg.say(`Nope, sorry, it's ${answer}.`); - else return msg.say('Nice job! 10/10! You deserve some cake!'); - } catch (err) { - return msg.say(`Time! It was ${answer}, sorry!`); - } + const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, { + max: 1, + time: 15000 + }); + if (!collected.size) return msg.say(`Time! It was ${answer}, sorry!`); + if (collected.first().content.toLowerCase() !== answer) return msg.say(`Nope, sorry, it's ${answer}.`); + else return msg.say('Nice job! 10/10! You deserve some cake!'); } }; diff --git a/commands/games/typing-game.js b/commands/games/typing-game.js index 77b29d67..fa7e045b 100644 --- a/commands/games/typing-game.js +++ b/commands/games/typing-game.js @@ -33,16 +33,12 @@ module.exports = class TypingGameCommand extends Command { .setTitle(`You have ${time / 1000} seconds to type:`) .setDescription(sentence); await msg.embed(embed); - try { - const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, { - max: 1, - time: time, - errors: ['time'] - }); - if (collected.first().content !== sentence) return msg.say('Nope, sorry!'); - else return msg.say('Nice job! 10/10! You deserve some cake!'); - } catch (err) { - return msg.say('Time! Sorry!'); - } + const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, { + max: 1, + time + }); + if (!collected.size) return msg.say('Time! Sorry!'); + if (collected.first().content !== sentence) return msg.say('Nope, sorry!'); + else return msg.say('Nice job! 10/10! You deserve some cake!'); } }; diff --git a/commands/moderation/ban.js b/commands/moderation/ban.js index 1ae0b3df..be38a5db 100644 --- a/commands/moderation/ban.js +++ b/commands/moderation/ban.js @@ -36,50 +36,45 @@ module.exports = class BanCommand extends Command { const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog')); const { member, reason } = args; if (!member.bannable) return msg.say('This member is not bannable. Perhaps they have a higher role than me?'); + await msg.say(`Are you sure you want to ban ${member.user.tag} (${member.id})?`); + const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, { + max: 1, + time: 15000 + }); + if (!collected.size || !['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting.'); try { - await msg.say(`Are you sure you want to ban ${member.user.tag} (${member.id})?`); - const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, { - max: 1, - time: 15000, - errors: ['time'] - }); - if (!['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting Ban.'); - try { - await member.user.send(stripIndents` - You were banned from ${msg.guild.name}! - Reason: ${reason} - `); - } catch (err) { - await msg.say('Failed to Send DM.'); - } - await member.ban({ - days: 7, - reason: `${msg.author.tag}: ${reason}` - }); - await msg.say(`Successfully banned ${member.user.tag}.`); - if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) { - return msg.say('Could not log the ban to the mod logs.'); - } else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) { - return modlogs.send(stripIndents` + await member.send(stripIndents` + You were banned from ${msg.guild.name}! + Reason: ${reason} + `); + } catch (err) { + await msg.say('Failed to Send DM.'); + } + await member.ban({ + days: 7, + reason: `${msg.author.tag}: ${reason}` + }); + await msg.say(`Successfully banned ${member.user.tag}.`); + if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) { + return msg.say('Could not log the ban to the mod logs.'); + } else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) { + return modlogs.send(stripIndents` + **Member:** ${member.user.tag} (${member.id}) + **Action:** Ban + **Reason:** ${reason} + **Moderator:** ${msg.author.tag} + `); + } else { + const embed = new RichEmbed() + .setAuthor(msg.author.tag, msg.author.displayAvatarURL()) + .setColor(0xFF0000) + .setTimestamp() + .setDescription(stripIndents` **Member:** ${member.user.tag} (${member.id}) **Action:** Ban **Reason:** ${reason} - **Moderator:** ${msg.author.tag} `); - } else { - const embed = new RichEmbed() - .setAuthor(msg.author.tag, msg.author.displayAvatarURL) - .setColor(0xFF0000) - .setTimestamp() - .setDescription(stripIndents` - **Member:** ${member.user.tag} (${member.id}) - **Action:** Ban - **Reason:** ${reason} - `); - return modlogs.send({ embed }); - } - } catch (err) { - return msg.say('Aborting Ban.'); + return modlogs.send({ embed }); } } }; diff --git a/commands/moderation/kick.js b/commands/moderation/kick.js index 7b57639a..41ac69ff 100644 --- a/commands/moderation/kick.js +++ b/commands/moderation/kick.js @@ -36,47 +36,42 @@ module.exports = class KickCommand extends Command { const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog')); const { member, reason } = args; if (!member.kickable) return msg.say('This member is not kickable. Perhaps they have a higher role than me?'); + await msg.say(`Are you sure you want to kick ${member.user.tag} (${member.id})?`); + const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, { + max: 1, + time: 15000 + }); + if (!collected.size || !['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting.'); try { - await msg.say(`Are you sure you want to kick ${member.user.tag} (${member.id})?`); - const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, { - max: 1, - time: 15000, - errors: ['time'] - }); - if (!['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting Kick.'); - try { - await member.user.send(stripIndents` - You were kicked from ${msg.guild.name}! - Reason: ${reason} - `); - } catch (err) { - await msg.say('Failed to Send DM.'); - } - await member.kick({ reason: `${msg.author.tag}: ${reason}` }); - await msg.say(`Successfully kicked ${member.user.tag}.`); - if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) { - return msg.say('Could not log the kick to the mod logs.'); - } else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) { - return modlogs.send(stripIndents` + await member.send(stripIndents` + You were kicked from ${msg.guild.name}! + Reason: ${reason} + `); + } catch (err) { + await msg.say('Failed to Send DM.'); + } + await member.kick({ reason: `${msg.author.tag}: ${reason}` }); + await msg.say(`Successfully kicked ${member.user.tag}.`); + if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) { + return msg.say('Could not log the kick to the mod logs.'); + } else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) { + return modlogs.send(stripIndents` + **Member:** ${member.user.tag} (${member.id}) + **Action:** Kick + **Reason:** ${reason} + **Moderator:** ${msg.author.tag} + `); + } else { + const embed = new RichEmbed() + .setAuthor(msg.author.tag, msg.author.displayAvatarURL()) + .setColor(0xFFA500) + .setTimestamp() + .setDescription(stripIndents` **Member:** ${member.user.tag} (${member.id}) **Action:** Kick **Reason:** ${reason} - **Moderator:** ${msg.author.tag} `); - } else { - const embed = new RichEmbed() - .setAuthor(msg.author.tag, msg.author.displayAvatarURL) - .setColor(0xFFA500) - .setTimestamp() - .setDescription(stripIndents` - **Member:** ${member.user.tag} (${member.id}) - **Action:** Kick - **Reason:** ${reason} - `); - return modlogs.send({ embed }); - } - } catch (err) { - return msg.say('Aborting Kick.'); + return modlogs.send({ embed }); } } }; diff --git a/commands/moderation/softban.js b/commands/moderation/softban.js index 03d30423..61a3bedd 100644 --- a/commands/moderation/softban.js +++ b/commands/moderation/softban.js @@ -36,51 +36,46 @@ module.exports = class SoftbanCommand extends Command { const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog')); const { member, reason } = args; if (!member.bannable) return msg.say('This member is not bannable. Perhaps they have a higher role than me?'); + await msg.say(`Are you sure you want to softban ${member.user.tag} (${member.id})?`); + const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, { + max: 1, + time: 15000 + }); + if (!collected.size || !['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting.'); try { - await msg.say(`Are you sure you want to softban ${member.user.tag} (${member.id})?`); - const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, { - max: 1, - time: 15000, - errors: ['time'] - }); - if (!['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting Softban.'); - try { - await member.user.send(stripIndents` - You were softbanned from ${msg.guild.name}! - Reason: ${reason} - `); - } catch (err) { - await msg.say('Failed to Send DM.'); - } - await member.ban({ - days: 7, - reason: `${msg.author.tag}: ${reason} (Softban)` - }); - await msg.guild.unban(member.user, 'Softban'); - await msg.say(`Successfully softbanned ${member.user.tag}.`); - if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) { - return msg.say('Could not log the softban to the mod logs.'); - } else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) { - return modlogs.send(stripIndents` + await member.send(stripIndents` + You were softbanned from ${msg.guild.name}! + Reason: ${reason} + `); + } catch (err) { + await msg.say('Failed to Send DM.'); + } + await member.ban({ + days: 7, + reason: `${msg.author.tag}: ${reason} (Softban)` + }); + await msg.guild.unban(member.user, 'Softban'); + await msg.say(`Successfully softbanned ${member.user.tag}.`); + if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) { + return msg.say('Could not log the softban to the mod logs.'); + } else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) { + return modlogs.send(stripIndents` + **Member:** ${member.user.tag} (${member.id}) + **Action:** Softban + **Reason:** ${reason} + **Moderator:** ${msg.author.tag} + `); + } else { + const embed = new RichEmbed() + .setAuthor(msg.author.tag, msg.author.displayAvatarURL()) + .setColor(0xFF4500) + .setTimestamp() + .setDescription(stripIndents` **Member:** ${member.user.tag} (${member.id}) **Action:** Softban **Reason:** ${reason} - **Moderator:** ${msg.author.tag} `); - } else { - const embed = new RichEmbed() - .setAuthor(msg.author.tag, msg.author.displayAvatarURL) - .setColor(0xFF4500) - .setTimestamp() - .setDescription(stripIndents` - **Member:** ${member.user.tag} (${member.id}) - **Action:** Softban - **Reason:** ${reason} - `); - return modlogs.send({ embed }); - } - } catch (err) { - return msg.say('Aborting Softban.'); + return modlogs.send({ embed }); } } }; diff --git a/commands/moderation/unban.js b/commands/moderation/unban.js index ee24a4fb..a8aaa180 100644 --- a/commands/moderation/unban.js +++ b/commands/moderation/unban.js @@ -38,39 +38,34 @@ module.exports = class UnbanCommand extends Command { const bans = await msg.guild.fetchBans(); if (!bans.has(id)) return msg.say('This ID is not in the Guild Banlist.'); const member = bans.get(id).user; - try { - await msg.say(`Are you sure you want to unban ${member.tag} (${member.id})?`); - const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, { - max: 1, - time: 15000, - errors: ['time'] - }); - if (!['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting Unban.'); - await msg.guild.unban(member, `${msg.author.tag}: ${reason}`); - await msg.say(`Successfully unbanned ${member.user.tag}.`); - if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) { - return msg.say('Could not log the unban to the mod logs.'); - } else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) { - return modlogs.send(stripIndents` + await msg.say(`Are you sure you want to unban ${member.tag} (${member.id})?`); + const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, { + max: 1, + time: 15000 + }); + if (!collected.size || !['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting.'); + await msg.guild.unban(member, `${msg.author.tag}: ${reason}`); + await msg.say(`Successfully unbanned ${member.user.tag}.`); + if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) { + return msg.say('Could not log the unban to the mod logs.'); + } else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) { + return modlogs.send(stripIndents` + **Member:** ${member.tag} (${member.id}) + **Action:** Unban + **Reason:** ${reason} + **Moderator:** ${msg.author.tag} + `); + } else { + const embed = new RichEmbed() + .setAuthor(msg.author.tag, msg.author.displayAvatarURL()) + .setColor(0x00AE86) + .setTimestamp() + .setDescription(stripIndents` **Member:** ${member.tag} (${member.id}) **Action:** Unban **Reason:** ${reason} - **Moderator:** ${msg.author.tag} `); - } else { - const embed = new RichEmbed() - .setAuthor(msg.author.tag, msg.author.displayAvatarURL) - .setColor(0x00AE86) - .setTimestamp() - .setDescription(stripIndents` - **Member:** ${member.tag} (${member.id}) - **Action:** Unban - **Reason:** ${reason} - `); - return modlogs.send({ embed }); - } - } catch (err) { - return msg.say('Aborting Unban.'); + return modlogs.send({ embed }); } } }; diff --git a/commands/moderation/warn.js b/commands/moderation/warn.js index be5e20e7..75d08aea 100644 --- a/commands/moderation/warn.js +++ b/commands/moderation/warn.js @@ -34,46 +34,41 @@ module.exports = class WarnCommand extends Command { async run(msg, args) { const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog')); const { member, reason } = args; + await msg.say(`Are you sure you want to warn ${member.user.tag} (${member.id})?`); + const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, { + max: 1, + time: 15000 + }); + if (!collected.size || !['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting.'); try { - await msg.say(`Are you sure you want to warn ${member.user.tag} (${member.id})?`); - const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, { - max: 1, - time: 15000, - errors: ['time'] - }); - if (!['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting Warn.'); - try { - await member.user.send(stripIndents` - You were warned in ${msg.guild.name}! - Reason: ${reason} - `); - } catch (err) { - await msg.say('Failed to Send DM.'); - } - await msg.say(`Successfully warned ${member.user.tag}.`); - if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) { - return msg.say('Could not log the warn to the mod logs.'); - } else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) { - return modlogs.send(stripIndents` + await member.user.send(stripIndents` + You were warned in ${msg.guild.name}! + Reason: ${reason} + `); + } catch (err) { + await msg.say('Failed to Send DM.'); + } + await msg.say(`Successfully warned ${member.user.tag}.`); + if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) { + return msg.say('Could not log the warn to the mod logs.'); + } else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) { + return modlogs.send(stripIndents` + **Member:** ${member.user.tag} (${member.id}) + **Action:** Warn + **Reason:** ${reason} + **Moderator:** ${msg.author.tag} + `); + } else { + const embed = new RichEmbed() + .setAuthor(msg.author.tag, msg.author.displayAvatarURL()) + .setColor(0xFFFF00) + .setTimestamp() + .setDescription(stripIndents` **Member:** ${member.user.tag} (${member.id}) **Action:** Warn **Reason:** ${reason} - **Moderator:** ${msg.author.tag} `); - } else { - const embed = new RichEmbed() - .setAuthor(msg.author.tag, msg.author.displayAvatarURL) - .setColor(0xFFFF00) - .setTimestamp() - .setDescription(stripIndents` - **Member:** ${member.user.tag} (${member.id}) - **Action:** Warn - **Reason:** ${reason} - `); - return modlogs.send({ embed }); - } - } catch (err) { - return msg.say('Aborting Warn.'); + return modlogs.send({ embed }); } } }; diff --git a/commands/random/cleverbot.js b/commands/random/cleverbot.js index 77ee1e31..1637038a 100644 --- a/commands/random/cleverbot.js +++ b/commands/random/cleverbot.js @@ -19,7 +19,7 @@ module.exports = class CleverbotCommand extends Command { ] }); - this.clevs = new Cleverbot.Client({ + this.clevs = new Cleverbot({ key: CLEVS_KEY, user: CLEVS_USER, nick: CLEVS_NICK diff --git a/commands/random/meme.js b/commands/random/meme.js index d034385c..65f905f4 100644 --- a/commands/random/meme.js +++ b/commands/random/meme.js @@ -39,6 +39,6 @@ module.exports = class MemeCommand extends Command { run(msg, args) { const { type, top, bottom } = args; - return msg.say({ files: [`https://memegen.link/${type}/${top}/${bottom}.jpg`] }); + return msg.say(`https://memegen.link/${type}/${top}/${bottom}.jpg`); } }; diff --git a/commands/random/spam.js b/commands/random/spam.js index b5c3338e..7e8a8f5c 100644 --- a/commands/random/spam.js +++ b/commands/random/spam.js @@ -1,5 +1,4 @@ const Command = require('../../structures/Command'); -const path = require('path'); module.exports = class SpamCommand extends Command { constructor(client) { @@ -13,6 +12,6 @@ module.exports = class SpamCommand extends Command { } run(msg) { - return msg.say({ files: [path.join(__dirname, '..', '..', 'assets', 'images', 'spam.png')] }); + return msg.say('https://i.imgur.com/arx7GJV.jpg'); } }; diff --git a/commands/random/star.js b/commands/random/star.js index 243a1622..fa568149 100644 --- a/commands/random/star.js +++ b/commands/random/star.js @@ -25,12 +25,9 @@ module.exports = class StarCommand extends Command { async run(msg, args, reaction) { const { id } = args; const channel = msg.guild.channels.get(msg.guild.settings.get('starboard')); - if (!channel || this.starred.includes(id)) return null; - if (!channel.permissionsFor(this.client.user).has('SEND_MESSAGES')) return null; + if (!channel || !channel.permissionsFor(this.client.user).has('SEND_MESSAGES') || this.starred.includes(id)) return null; const message = await msg.channel.fetchMessage(id); - if (!reaction && msg.author.id === message.author.id) { - return msg.reply('You cannot star your own messages, baka.'); - } + if (!reaction && msg.author.id === message.author.id) return msg.reply('You cannot star your own messages, baka.'); this.starred.push(id); if (!channel.permissionsFor(this.client.user).has('EMBED_LINKS')) { return msg.say(stripIndents` diff --git a/commands/response/fishy.js b/commands/response/fishy.js index 6e7b75bd..5bb8a613 100644 --- a/commands/response/fishy.js +++ b/commands/response/fishy.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const fishes = [':fish:', ':tropical_fish:', ':blowfish:']; +const fishes = [':fish:', ':tropical_fish:', ':blowfish:', ':wrench:']; module.exports = class FishyCommand extends Command { constructor(client) { diff --git a/commands/search/anime.js b/commands/search/anime.js index 266a9eaf..bf150762 100644 --- a/commands/search/anime.js +++ b/commands/search/anime.js @@ -1,7 +1,7 @@ const Command = require('../../structures/Command'); const { RichEmbed } = require('discord.js'); const snekfetch = require('snekfetch'); -const { cleanXML } = require('../../util/Util'); +const { cleanXML } = require('../../structures/Util'); const { promisifyAll } = require('tsubaki'); const xml = promisifyAll(require('xml2js')); const { ANIMELIST_LOGIN } = process.env; @@ -49,7 +49,8 @@ module.exports = class AnimeCommand extends Command { anime.entry[0].end_date[0], true); return msg.embed(embed); } catch (err) { - return msg.say('No Results.'); + if (err.message === 'Parse Error') return msg.say('No Results.'); + else throw err; } } }; diff --git a/commands/search/bot-info.js b/commands/search/bot-info.js index 597ba970..d93148e0 100644 --- a/commands/search/bot-info.js +++ b/commands/search/bot-info.js @@ -41,7 +41,8 @@ module.exports = class BotSearchCommand extends Command { body.prefix, true); return msg.embed(embed); } catch (err) { - return msg.say(err.message); + if (err.message === '404 Not Found') return msg.say('Bot Not Found.'); + else throw err; } } }; diff --git a/commands/search/github.js b/commands/search/github.js index bce9e9ed..b6d62246 100644 --- a/commands/search/github.js +++ b/commands/search/github.js @@ -48,7 +48,8 @@ module.exports = class GithubCommand extends Command { body.language, true); return msg.embed(embed); } catch (err) { - return msg.say(err.message); + if (err.message === '404 Not Found') return msg.say('Repo Not Found.'); + else throw err; } } }; diff --git a/commands/search/google.js b/commands/search/google.js index f9c9e629..5e1928f9 100644 --- a/commands/search/google.js +++ b/commands/search/google.js @@ -28,7 +28,7 @@ module.exports = class GoogleCommand extends Command { .query({ q: query }); const $ = cheerio.load(text); let href = $('.r').first().find('a').first().attr('href'); - if (!href) return msg.say('No Results.'); + if (!href) return message.edit('No Results.'); href = querystring.parse(href.replace('/url?', '')); return message.edit(href.q); } diff --git a/commands/search/manga.js b/commands/search/manga.js index 6f642677..ed1c0f5f 100644 --- a/commands/search/manga.js +++ b/commands/search/manga.js @@ -1,7 +1,7 @@ const Command = require('../../structures/Command'); const { RichEmbed } = require('discord.js'); const snekfetch = require('snekfetch'); -const { cleanXML } = require('../../util/Util'); +const { cleanXML } = require('../../structures/Util'); const { promisifyAll } = require('tsubaki'); const xml = promisifyAll(require('xml2js')); const { ANIMELIST_LOGIN } = process.env; @@ -49,7 +49,8 @@ module.exports = class MangaCommand extends Command { manga.entry[0].end_date[0], true); return msg.embed(embed); } catch (err) { - return msg.say('No Results.'); + if (err.message === 'Parse Error') return msg.say('No Results.'); + else throw err; } } }; diff --git a/commands/textedit/cow-say.js b/commands/textedit/cow-say.js index 244013dd..6511f64f 100644 --- a/commands/textedit/cow-say.js +++ b/commands/textedit/cow-say.js @@ -15,7 +15,7 @@ module.exports = class CowsayCommand extends Command { type: 'string', validate: (text) => { if (text.length < 1500) return true; - else return 'Invalid Text. Text must be under 1500 characters.'; + else return 'Text must be under 1500 characters.'; } } ] diff --git a/commands/textedit/mocking.js b/commands/textedit/mocking.js index d187cae7..86ccf0fe 100644 --- a/commands/textedit/mocking.js +++ b/commands/textedit/mocking.js @@ -16,9 +16,9 @@ module.exports = class MockingCommand extends Command { type: 'string', validate: (text) => { if (text.length < 1950) return true; - else return 'Invalid Text. Text must be under 1950 characters.'; + else return 'Text must be under 1950 characters.'; }, - parse: (text) => text.split('') + parse: (text) => text.toLowerCase().split('') } ] }); diff --git a/commands/textedit/zalgo.js b/commands/textedit/zalgo.js index 631ea89c..900e6f06 100644 --- a/commands/textedit/zalgo.js +++ b/commands/textedit/zalgo.js @@ -15,7 +15,7 @@ module.exports = class ZalgoCommand extends Command { type: 'string', validate: (text) => { if (text.length < 500) return true; - else return 'Invalid Text. Text must be under 500 characters.'; + else return 'Text must be under 500 characters.'; } } ] diff --git a/commands/userinfo/avatar.js b/commands/userinfo/avatar.js index 98a9f772..9126348f 100644 --- a/commands/userinfo/avatar.js +++ b/commands/userinfo/avatar.js @@ -20,6 +20,6 @@ module.exports = class AvatarCommand extends Command { run(msg, args) { const user = args.user || msg.author; - return msg.say(user.avatarURL('webp', 2048) || user.displayAvatarURL); + return msg.say(user.displayAvatarURL({ size: 2048 })); } }; diff --git a/commands/userinfo/user-info.js b/commands/userinfo/user-info.js index 678f16d0..7ef14405 100644 --- a/commands/userinfo/user-info.js +++ b/commands/userinfo/user-info.js @@ -1,18 +1,7 @@ const Command = require('../../structures/Command'); const { RichEmbed } = require('discord.js'); const moment = require('moment'); -const statuses = { - online: '<:online:313956277808005120> Online', - idle: '<:away:313956277220802560> Idle', - dnd: '<:dnd:313956276893646850> Do Not Disturb', - offline: '<:offline:313956277237710868> Offline' -}; -const colors = { - online: 0x00AE86, - idle: 0xFFFF00, - dnd: 0xFF0000, - offline: 0x808080 -}; +const statuses = require('../../assets/json/user-info'); module.exports = class UserInfoCommand extends Command { constructor(client) { @@ -39,8 +28,8 @@ module.exports = class UserInfoCommand extends Command { const member = args.member || msg.member; const status = member.user.presence.status; const embed = new RichEmbed() - .setColor(colors[status]) - .setThumbnail(member.user.displayAvatarURL) + .setColor(statuses[status].color) + .setThumbnail(member.user.displayAvatarURL()) .addField('❯ Name', member.user.tag, true) .addField('❯ ID', @@ -50,7 +39,7 @@ module.exports = class UserInfoCommand extends Command { .addField('❯ Server Join Date', moment(member.joinedTimestamp).format('MMMM Do YYYY h:mm:ss A')) .addField('❯ Status', - statuses[status], true) + statuses[status].text, true) .addField('❯ Playing', member.user.presence.game ? member.user.presence.game.name : 'None', true); return msg.embed(embed); diff --git a/commands/util/help.js b/commands/util/help.js index 5f9b67a3..2cc918cb 100644 --- a/commands/util/help.js +++ b/commands/util/help.js @@ -1,6 +1,5 @@ const Command = require('../../structures/Command'); const { RichEmbed } = require('discord.js'); -const { stripIndents } = require('common-tags'); module.exports = class HelpCommand extends Command { constructor(client) { @@ -29,14 +28,18 @@ module.exports = class HelpCommand extends Command { const showAll = command && command.toLowerCase() === 'all'; if (command && !showAll) { if (commands.length === 1) { - return msg.say(stripIndents` - __Command **${commands[0].name}**:__ *${commands[0].description}* - ${commands[0].guildOnly ? 'Usable Only in Servers' : 'Usable in Servers and DM'} - **Format:** ${msg.anyUsage(`${commands[0].name} ${commands[0].format ? commands[0].format : ''}`)} - **Aliases:** ${commands[0].aliases.join(', ') || 'None'} - **Group:** ${commands[0].group.name} - ${commands[0].details || ''} - `); + const embed = new RichEmbed() + .setTitle(`Command ${commands[0].name}`) + .setDescription(commands[0].description) + .addField('❯ Format', + msg.anyUsage(`${commands[0].name} ${commands[0].format ? commands[0].format : ''}`)) + .addField('❯ Aliases', + commands[0].aliases.join(', ') || 'None') + .addField('❯ Group', + commands[0].group.name); + return msg.embed(embed); + } else if (commands.length > 1) { + return msg.say(`Multiple commands found, please be more specific: ${commands.map((c) => c.name).join(', ')}`); } else { return msg.say(`Could not identify command. Use \`${msg.usage(null)}\` to view a list of commands.`); } @@ -48,7 +51,7 @@ module.exports = class HelpCommand extends Command { for (const group of this.client.registry.groups.values()) { embed.addField(`❯ ${group.name}`, showAll ? - group.commands.map((c) => c.name).join(', ') : + group.commands.map((c) => c.name).join(', ') || 'None' : group.commands.filter((c) => c.isUsable(msg)).map((c) => c.name).join(', ') || 'None'); } try { diff --git a/html/carbonuse.html b/html/carbonuse.html index dd2baaae..b6eeec13 100644 --- a/html/carbonuse.html +++ b/html/carbonuse.html @@ -14,7 +14,6 @@
  1. Moderation Commands Require a Channel set with x;modchannel to send Ban/Softban/Kick/Unban/Warn Logs
  2. To use Member Join/Leave Logging, set a channel with x;memberchannel, a custom message can be set with x;membermsg
  3. -
  4. You can set a special role that is able to use Moderation commands (excluding lockdown) with x;staffrole
  5. Use x;help to View a Command List
  6. Visit my Home Server for more support, or for updates, or if you just want to hang out.
diff --git a/html/discordbots.html b/html/discordbots.html index 3860b4c2..0e5a45df 100644 --- a/html/discordbots.html +++ b/html/discordbots.html @@ -72,7 +72,6 @@
  1. Moderation Commands Require a Channel set with x;modchannel to send Ban/Softban/Kick/Unban/Warn Logs
  2. To use Member Join/Leave Logging, set a channel with x;memberchannel, a custom message can be set with x;membermsg
  3. -
  4. You can set a special role that is able to use Moderation commands (excluding lockdown) with x;staffrole
  5. Use x;help to View a Command List
  6. Visit my Home Server for more support, or for updates, or if you just want to hang out.
diff --git a/package.json b/package.json index ab9f089f..ff798f1c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "22.1.4", + "version": "22.1.5", "description": "A Discord Bot", "main": "Shard.js", "scripts": { diff --git a/util/Util.js b/structures/Util.js similarity index 100% rename from util/Util.js rename to structures/Util.js