From 8809dee34c527cb7c237b5c10fb2e2367b9ebccb Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sat, 5 Jun 2021 12:31:10 -0400 Subject: [PATCH] Fix lint --- assets/json/permission-names.json | 66 +++++++++++++++---------------- commands/util/eval.js | 17 ++++---- framework/Client.js | 7 +++- framework/Dispatcher.js | 4 +- framework/Extensions.js | 7 +--- framework/Registry.js | 8 ++-- framework/types/boolean.js | 2 +- framework/types/channel.js | 2 +- framework/types/command.js | 2 +- framework/types/custom-emoji.js | 2 +- framework/types/default-emoji.js | 2 +- framework/types/float.js | 2 +- framework/types/group.js | 2 +- framework/types/integer.js | 6 +-- framework/types/member.js | 14 +++---- framework/types/message.js | 2 +- framework/types/role.js | 2 +- framework/types/string.js | 2 +- framework/types/user.js | 16 ++++---- 19 files changed, 82 insertions(+), 83 deletions(-) diff --git a/assets/json/permission-names.json b/assets/json/permission-names.json index dfc6d828..2350c369 100644 --- a/assets/json/permission-names.json +++ b/assets/json/permission-names.json @@ -1,35 +1,35 @@ { - "ADMINISTRATOR": "", - "CREATE_INSTANT_INVITE": "", - "KICK_MEMBERS": "", - "BAN_MEMBERS": "", - "MANAGE_CHANNELS": "", - "MANAGE_GUILD": "", - "ADD_REACTIONS": "", - "VIEW_AUDIT_LOG": "", - "PRIORITY_SPEAKER": "", - "STREAM": "", - "VIEW_CHANNEL": "", - "SEND_MESSAGES": "", - "SEND_TTS_MESSAGES": "", - "MANAGE_MESSAGES": "", - "EMBED_LINKS": "", - "ATTACH_FILES": "", - "READ_MESSAGE_HISTORY": "", - "MENTION_EVERYONE": "", - "USE_EXTERNAL_EMOJIS": "", - "VIEW_GUILD_INSIGHTS": "", - "CONNECT": "", - "SPEAK": "", - "MUTE_MEMBERS": "", - "DEAFEN_MEMBERS": "", - "MOVE_MEMBERS": "", - "USE_VAD": "", - "CHANGE_NICKNAME": "", - "MANAGE_NICKNAMES": "", - "MANAGE_ROLES": "", - "MANAGE_WEBHOOKS": "", - "MANAGE_EMOJIS": "", - "USE_APPLICATION_COMMANDS": "", - "REQUEST_TO_SPEAK": "" + "ADMINISTRATOR": "Administrator", + "CREATE_INSTANT_INVITE": "Create Invite", + "KICK_MEMBERS": "Kick Members", + "BAN_MEMBERS": "Ban Members", + "MANAGE_CHANNELS": "Manage Channels", + "MANAGE_GUILD": "Manage Server", + "ADD_REACTIONS": "Add Reactions", + "VIEW_AUDIT_LOG": "View Audit Log", + "PRIORITY_SPEAKER": "Priority Speaker", + "STREAM": "Video", + "VIEW_CHANNEL": "View Channels", + "SEND_MESSAGES": "Send Messages", + "SEND_TTS_MESSAGES": "Send Text-to-Speech Messages", + "MANAGE_MESSAGES": "Manage Messages", + "EMBED_LINKS": "Embed Links", + "ATTACH_FILES": "Attach Files", + "READ_MESSAGE_HISTORY": "Read Message History", + "MENTION_EVERYONE": "Mention everyone, here, and All Roles", + "USE_EXTERNAL_EMOJIS": "Use External Emoji", + "VIEW_GUILD_INSIGHTS": "View Server Insights", + "CONNECT": "Connect", + "SPEAK": "Speak", + "MUTE_MEMBERS": "Mute Members", + "DEAFEN_MEMBERS": "Deafen Members", + "MOVE_MEMBERS": "Move Members", + "USE_VAD": "Use Voice Activity", + "CHANGE_NICKNAME": "Change Nickname", + "MANAGE_NICKNAMES": "Manage Nicknames", + "MANAGE_ROLES": "Manage Roles", + "MANAGE_WEBHOOKS": "Manage Webhooks", + "MANAGE_EMOJIS": "Manage Emojis", + "USE_APPLICATION_COMMANDS": "Use Slash Commands", + "REQUEST_TO_SPEAK": "Request to Speak" } diff --git a/commands/util/eval.js b/commands/util/eval.js index a21c4d21..60a3ef97 100644 --- a/commands/util/eval.js +++ b/commands/util/eval.js @@ -32,7 +32,7 @@ module.exports = class EvalCommand extends Command { run(msg, args) { // Make a bunch of helpers - /* eslint-disable no-unused-vars */ + /* eslint-disable no-unused-vars destructuring */ const message = msg; const client = msg.client; const lastResult = this.lastResult; @@ -42,13 +42,13 @@ module.exports = class EvalCommand extends Command { } else { const result = this.makeResultMessages(val, process.hrtime(this.hrStart)); if (Array.isArray(result)) { - for(const item of result) msg.reply(item); + for (const item of result) msg.reply(item); } else { msg.reply(result); } } }; - /* eslint-enable no-unused-vars */ + /* eslint-enable no-unused-vars destructuring */ // Remove any surrounding code blocks before evaluation if (args.script.startsWith('```') && args.script.endsWith('```')) { @@ -81,10 +81,10 @@ module.exports = class EvalCommand extends Command { .replace(this.sensitivePattern, '--snip--'); const split = inspected.split('\n'); const last = inspected.length - 1; - const prependPart = inspected[0] !== '{' && inspected[0] !== '[' && inspected[0] !== "'" ? split[0] : inspected[0]; - const appendPart = inspected[last] !== '}' && inspected[last] !== ']' && inspected[last] !== "'" ? - split[split.length - 1] : - inspected[last]; + const prependPart = inspected[0] !== '{' && inspected[0] !== '[' && inspected[0] !== '\'' ? split[0] : inspected[0]; + const appendPart = inspected[last] !== '}' && inspected[last] !== ']' && inspected[last] !== '\'' + ? split[split.length - 1] + : inspected[last]; const prepend = `\`\`\`javascript\n${prependPart}\n`; const append = `\n${appendPart}\n\`\`\``; if (input) { @@ -106,9 +106,8 @@ module.exports = class EvalCommand extends Command { get sensitivePattern() { if (!this._sensitivePattern) { - const client = this.client; let pattern = ''; - if (client.token) pattern += escapeRegex(client.token); + if (this.client.token) pattern += escapeRegex(this.client.token); Object.defineProperty(this, '_sensitivePattern', { value: new RegExp(pattern, 'gi'), configurable: false }); } return this._sensitivePattern; diff --git a/framework/Client.js b/framework/Client.js index f6872fc2..f80a2e36 100644 --- a/framework/Client.js +++ b/framework/Client.js @@ -1,5 +1,6 @@ const { Client } = require('discord.js'); const fs = require('fs'); +const path = require('path'); const { stripIndents } = require('common-tags'); const Registry = require('./Registry'); const Dispatcher = require('./Dispatcher'); @@ -95,7 +96,9 @@ module.exports = class CommandClient extends Client { const throttleAmount = command.throttles.get(msg.author.id) || 0; if (throttleAmount >= command.throttling.uses) { const timeout = command._timeouts.get(msg.author.id); - await msg.reply(`Please wait ${getTimeLeft(timeout)} seconds before using the \`${command.name}\` command again.`); + await msg.reply( + `Please wait ${getTimeLeft(timeout)} seconds before using the \`${command.name}\` command again.` + ); return; } command.throttles.set(msg.author.id, throttleAmount + 1); @@ -224,5 +227,5 @@ module.exports = class CommandClient extends Client { }; function getTimeLeft(timeout) { - return Math.ceil((timeout._idleStart + timeout._idleTimeout - Date.now()) / 1000); + return Math.ceil((timeout._idleStart + timeout._idleTimeout - Date.now()) / 1000); } diff --git a/framework/Dispatcher.js b/framework/Dispatcher.js index fe47d989..a394cf17 100644 --- a/framework/Dispatcher.js +++ b/framework/Dispatcher.js @@ -31,8 +31,8 @@ module.exports = class CommandDispatcher { }; } const content = msg.content.replace(this.commandPattern, '').trim(); - const result = (content.match(argRegex) || []).map(m => m.replace(argRegex, '$1$2')); - const parsed = minimist(result); + const firstResult = (content.match(argRegex) || []).map(m => m.replace(argRegex, '$1$2')); + const parsed = minimist(firstResult); const result = { flags: [...parsed] }; for (let i = 0; i > command.args.length; i++) { const arg = command.args[i]; diff --git a/framework/Extensions.js b/framework/Extensions.js index 02d509e9..ca91fd42 100644 --- a/framework/Extensions.js +++ b/framework/Extensions.js @@ -1,11 +1,7 @@ const { Structures } = require('discord.js'); module.exports = Structures.extend('Message', Message => { - return class CommandMessage extends Message { - constructor(...args) { - super(...args); - } - + class CommandMessage extends Message { say(content, options) { return this.channel.send(content, options); } @@ -18,4 +14,5 @@ module.exports = Structures.extend('Message', Message => { return this.channel.send(content, { code: lang, ...options }); } } + return CommandMessage; }); diff --git a/framework/Registry.js b/framework/Registry.js index df0e6650..d0ac8ce3 100644 --- a/framework/Registry.js +++ b/framework/Registry.js @@ -28,8 +28,8 @@ module.exports = class Registry { const commands = fs.readdirSync(path.join(dir, group)); for (const command of commands) { if (!command.endsWith('.js')) continue; - const required = require(path.join(dir, group, command)); - this.registerCommand(new required(this.client)); + const Required = require(path.join(dir, group, command)); + this.registerCommand(new Required(this.client)); } } return this; @@ -62,8 +62,8 @@ module.exports = class Registry { const types = fs.readdirSync(dir); for (const type of types) { if (!type.endsWith('.js')) continue; - const required = require(path.join(dir, type)); - this.registerType(new required(this.client)); + const Required = require(path.join(dir, type)); + this.registerType(new Required(this.client)); } return this; } diff --git a/framework/types/boolean.js b/framework/types/boolean.js index f5b5c243..e1d880df 100644 --- a/framework/types/boolean.js +++ b/framework/types/boolean.js @@ -18,4 +18,4 @@ module.exports = class BooleanArgumentType extends ArgumentType { if (this.falsy.has(lc)) return false; throw new RangeError('Unknown boolean value.'); } -} +}; diff --git a/framework/types/channel.js b/framework/types/channel.js index 9ebfbca5..344b1bd0 100644 --- a/framework/types/channel.js +++ b/framework/types/channel.js @@ -28,7 +28,7 @@ module.exports = class ChannelArgumentType extends ArgumentType { if (exactChannels.size === 1) return exactChannels.first(); return null; } -} +}; function nameFilterExact(search) { return thing => thing.name.toLowerCase() === search; diff --git a/framework/types/command.js b/framework/types/command.js index 23a56271..a7e25160 100644 --- a/framework/types/command.js +++ b/framework/types/command.js @@ -14,4 +14,4 @@ module.exports = class CommandArgumentType extends ArgumentType { parse(val) { return this.client.registry.findCommands(val).first(); } -} +}; diff --git a/framework/types/custom-emoji.js b/framework/types/custom-emoji.js index fd302931..bb1e1257 100644 --- a/framework/types/custom-emoji.js +++ b/framework/types/custom-emoji.js @@ -29,7 +29,7 @@ module.exports = class CustomEmojiArgumentType extends ArgumentType { if (exactEmojis.size === 1) return exactEmojis.first(); return null; } -} +}; function nameFilterExact(search) { return emoji => emoji.name.toLowerCase() === search; diff --git a/framework/types/default-emoji.js b/framework/types/default-emoji.js index 76c62b7e..183cabca 100644 --- a/framework/types/default-emoji.js +++ b/framework/types/default-emoji.js @@ -15,4 +15,4 @@ module.exports = class DefaultEmojiArgumentType extends ArgumentType { parse(value) { return value; } -} +}; diff --git a/framework/types/float.js b/framework/types/float.js index e7fa1847..a1b4afdb 100644 --- a/framework/types/float.js +++ b/framework/types/float.js @@ -17,4 +17,4 @@ module.exports = class FloatArgumentType extends ArgumentType { parse(val) { return Number.parseFloat(val); } -} +}; diff --git a/framework/types/group.js b/framework/types/group.js index 74954ea0..252c9ec0 100644 --- a/framework/types/group.js +++ b/framework/types/group.js @@ -14,4 +14,4 @@ module.exports = class GroupArgumentType extends ArgumentType { parse(val) { return this.client.registry.findGroups(val).first(); } -} +}; diff --git a/framework/types/integer.js b/framework/types/integer.js index c04187ba..1745480d 100644 --- a/framework/types/integer.js +++ b/framework/types/integer.js @@ -6,7 +6,7 @@ module.exports = class IntegerArgumentType extends ArgumentType { } validate(val, msg, arg) { - const int = Number.parseInt(val); + const int = Number.parseInt(val, 10); if (Number.isNaN(int)) return false; if (arg.oneOf && !arg.oneOf.includes(int)) return false; if (arg.min !== null && typeof arg.min !== 'undefined' && int < arg.min) return false; @@ -15,6 +15,6 @@ module.exports = class IntegerArgumentType extends ArgumentType { } parse(val) { - return Number.parseInt(val); + return Number.parseInt(val, 10); } -} +}; diff --git a/framework/types/member.js b/framework/types/member.js index 031b2d18..259a4e28 100644 --- a/framework/types/member.js +++ b/framework/types/member.js @@ -36,16 +36,16 @@ module.exports = class MemberArgumentType extends ArgumentType { if (exactMembers.size === 1) return exactMembers.first(); return null; } -} +}; function memberFilterExact(search) { - return mem => mem.user.username.toLowerCase() === search || - (mem.nickname && mem.nickname.toLowerCase() === search) || - mem.tag.toLowerCase() === search; + return mem => mem.user.username.toLowerCase() === search + || (mem.nickname && mem.nickname.toLowerCase() === search) + || mem.tag.toLowerCase() === search; } function memberFilterInexact(search) { - return mem => mem.user.username.toLowerCase().includes(search) || - (mem.nickname && mem.nickname.toLowerCase().includes(search)) || - mem.tag.toLowerCase().includes(search); + return mem => mem.user.username.toLowerCase().includes(search) + || (mem.nickname && mem.nickname.toLowerCase().includes(search)) + || mem.tag.toLowerCase().includes(search); } diff --git a/framework/types/message.js b/framework/types/message.js index 6a1305f0..e08bc766 100644 --- a/framework/types/message.js +++ b/framework/types/message.js @@ -13,4 +13,4 @@ module.exports = class MessageArgumentType extends ArgumentType { parse(val, msg) { return msg.channel.messages.cache.get(val); } -} +}; diff --git a/framework/types/role.js b/framework/types/role.js index b1fab753..c615a51e 100644 --- a/framework/types/role.js +++ b/framework/types/role.js @@ -28,7 +28,7 @@ module.exports = class RoleArgumentType extends ArgumentType { if (exactRoles.size === 1) return exactRoles.first(); return null; } -} +}; function nameFilterExact(search) { return thing => thing.name.toLowerCase() === search; diff --git a/framework/types/string.js b/framework/types/string.js index 73523651..628c0755 100644 --- a/framework/types/string.js +++ b/framework/types/string.js @@ -15,4 +15,4 @@ module.exports = class StringArgumentType extends ArgumentType { parse(val) { return val; } -} +}; diff --git a/framework/types/user.js b/framework/types/user.js index ea851b8f..61271c00 100644 --- a/framework/types/user.js +++ b/framework/types/user.js @@ -5,7 +5,7 @@ module.exports = class UserArgumentType extends ArgumentType { super(client, 'user'); } - async validate(val, msg, arg) { + async validate(val, msg) { const matches = val.match(/^(?:<@!?)?([0-9]+)>?$/); if (matches) { try { @@ -38,16 +38,16 @@ module.exports = class UserArgumentType extends ArgumentType { if (exactMembers.size === 1) return exactMembers.first().user; return null; } -} +}; function memberFilterExact(search) { - return mem => mem.user.username.toLowerCase() === search || - (mem.nickname && mem.nickname.toLowerCase() === search) || - mem.tag.toLowerCase() === search; + return mem => mem.user.username.toLowerCase() === search + || (mem.nickname && mem.nickname.toLowerCase() === search) + || mem.tag.toLowerCase() === search; } function memberFilterInexact(search) { - return mem => mem.user.username.toLowerCase().includes(search) || - (mem.nickname && mem.nickname.toLowerCase().includes(search)) || - mem.tag.toLowerCase().includes(search); + return mem => mem.user.username.toLowerCase().includes(search) + || (mem.nickname && mem.nickname.toLowerCase().includes(search)) + || mem.tag.toLowerCase().includes(search); }