mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-18 21:40:49 +02:00
Fix lint
This commit is contained in:
@@ -1,35 +1,35 @@
|
|||||||
{
|
{
|
||||||
"ADMINISTRATOR": "",
|
"ADMINISTRATOR": "Administrator",
|
||||||
"CREATE_INSTANT_INVITE": "",
|
"CREATE_INSTANT_INVITE": "Create Invite",
|
||||||
"KICK_MEMBERS": "",
|
"KICK_MEMBERS": "Kick Members",
|
||||||
"BAN_MEMBERS": "",
|
"BAN_MEMBERS": "Ban Members",
|
||||||
"MANAGE_CHANNELS": "",
|
"MANAGE_CHANNELS": "Manage Channels",
|
||||||
"MANAGE_GUILD": "",
|
"MANAGE_GUILD": "Manage Server",
|
||||||
"ADD_REACTIONS": "",
|
"ADD_REACTIONS": "Add Reactions",
|
||||||
"VIEW_AUDIT_LOG": "",
|
"VIEW_AUDIT_LOG": "View Audit Log",
|
||||||
"PRIORITY_SPEAKER": "",
|
"PRIORITY_SPEAKER": "Priority Speaker",
|
||||||
"STREAM": "",
|
"STREAM": "Video",
|
||||||
"VIEW_CHANNEL": "",
|
"VIEW_CHANNEL": "View Channels",
|
||||||
"SEND_MESSAGES": "",
|
"SEND_MESSAGES": "Send Messages",
|
||||||
"SEND_TTS_MESSAGES": "",
|
"SEND_TTS_MESSAGES": "Send Text-to-Speech Messages",
|
||||||
"MANAGE_MESSAGES": "",
|
"MANAGE_MESSAGES": "Manage Messages",
|
||||||
"EMBED_LINKS": "",
|
"EMBED_LINKS": "Embed Links",
|
||||||
"ATTACH_FILES": "",
|
"ATTACH_FILES": "Attach Files",
|
||||||
"READ_MESSAGE_HISTORY": "",
|
"READ_MESSAGE_HISTORY": "Read Message History",
|
||||||
"MENTION_EVERYONE": "",
|
"MENTION_EVERYONE": "Mention everyone, here, and All Roles",
|
||||||
"USE_EXTERNAL_EMOJIS": "",
|
"USE_EXTERNAL_EMOJIS": "Use External Emoji",
|
||||||
"VIEW_GUILD_INSIGHTS": "",
|
"VIEW_GUILD_INSIGHTS": "View Server Insights",
|
||||||
"CONNECT": "",
|
"CONNECT": "Connect",
|
||||||
"SPEAK": "",
|
"SPEAK": "Speak",
|
||||||
"MUTE_MEMBERS": "",
|
"MUTE_MEMBERS": "Mute Members",
|
||||||
"DEAFEN_MEMBERS": "",
|
"DEAFEN_MEMBERS": "Deafen Members",
|
||||||
"MOVE_MEMBERS": "",
|
"MOVE_MEMBERS": "Move Members",
|
||||||
"USE_VAD": "",
|
"USE_VAD": "Use Voice Activity",
|
||||||
"CHANGE_NICKNAME": "",
|
"CHANGE_NICKNAME": "Change Nickname",
|
||||||
"MANAGE_NICKNAMES": "",
|
"MANAGE_NICKNAMES": "Manage Nicknames",
|
||||||
"MANAGE_ROLES": "",
|
"MANAGE_ROLES": "Manage Roles",
|
||||||
"MANAGE_WEBHOOKS": "",
|
"MANAGE_WEBHOOKS": "Manage Webhooks",
|
||||||
"MANAGE_EMOJIS": "",
|
"MANAGE_EMOJIS": "Manage Emojis",
|
||||||
"USE_APPLICATION_COMMANDS": "",
|
"USE_APPLICATION_COMMANDS": "Use Slash Commands",
|
||||||
"REQUEST_TO_SPEAK": ""
|
"REQUEST_TO_SPEAK": "Request to Speak"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ module.exports = class EvalCommand extends Command {
|
|||||||
|
|
||||||
run(msg, args) {
|
run(msg, args) {
|
||||||
// Make a bunch of helpers
|
// Make a bunch of helpers
|
||||||
/* eslint-disable no-unused-vars */
|
/* eslint-disable no-unused-vars destructuring */
|
||||||
const message = msg;
|
const message = msg;
|
||||||
const client = msg.client;
|
const client = msg.client;
|
||||||
const lastResult = this.lastResult;
|
const lastResult = this.lastResult;
|
||||||
@@ -42,13 +42,13 @@ module.exports = class EvalCommand extends Command {
|
|||||||
} else {
|
} else {
|
||||||
const result = this.makeResultMessages(val, process.hrtime(this.hrStart));
|
const result = this.makeResultMessages(val, process.hrtime(this.hrStart));
|
||||||
if (Array.isArray(result)) {
|
if (Array.isArray(result)) {
|
||||||
for(const item of result) msg.reply(item);
|
for (const item of result) msg.reply(item);
|
||||||
} else {
|
} else {
|
||||||
msg.reply(result);
|
msg.reply(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/* eslint-enable no-unused-vars */
|
/* eslint-enable no-unused-vars destructuring */
|
||||||
|
|
||||||
// Remove any surrounding code blocks before evaluation
|
// Remove any surrounding code blocks before evaluation
|
||||||
if (args.script.startsWith('```') && args.script.endsWith('```')) {
|
if (args.script.startsWith('```') && args.script.endsWith('```')) {
|
||||||
@@ -81,10 +81,10 @@ module.exports = class EvalCommand extends Command {
|
|||||||
.replace(this.sensitivePattern, '--snip--');
|
.replace(this.sensitivePattern, '--snip--');
|
||||||
const split = inspected.split('\n');
|
const split = inspected.split('\n');
|
||||||
const last = inspected.length - 1;
|
const last = inspected.length - 1;
|
||||||
const prependPart = inspected[0] !== '{' && inspected[0] !== '[' && inspected[0] !== "'" ? split[0] : inspected[0];
|
const prependPart = inspected[0] !== '{' && inspected[0] !== '[' && inspected[0] !== '\'' ? split[0] : inspected[0];
|
||||||
const appendPart = inspected[last] !== '}' && inspected[last] !== ']' && inspected[last] !== "'" ?
|
const appendPart = inspected[last] !== '}' && inspected[last] !== ']' && inspected[last] !== '\''
|
||||||
split[split.length - 1] :
|
? split[split.length - 1]
|
||||||
inspected[last];
|
: inspected[last];
|
||||||
const prepend = `\`\`\`javascript\n${prependPart}\n`;
|
const prepend = `\`\`\`javascript\n${prependPart}\n`;
|
||||||
const append = `\n${appendPart}\n\`\`\``;
|
const append = `\n${appendPart}\n\`\`\``;
|
||||||
if (input) {
|
if (input) {
|
||||||
@@ -106,9 +106,8 @@ module.exports = class EvalCommand extends Command {
|
|||||||
|
|
||||||
get sensitivePattern() {
|
get sensitivePattern() {
|
||||||
if (!this._sensitivePattern) {
|
if (!this._sensitivePattern) {
|
||||||
const client = this.client;
|
|
||||||
let pattern = '';
|
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 });
|
Object.defineProperty(this, '_sensitivePattern', { value: new RegExp(pattern, 'gi'), configurable: false });
|
||||||
}
|
}
|
||||||
return this._sensitivePattern;
|
return this._sensitivePattern;
|
||||||
|
|||||||
+5
-2
@@ -1,5 +1,6 @@
|
|||||||
const { Client } = require('discord.js');
|
const { Client } = require('discord.js');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
const { stripIndents } = require('common-tags');
|
const { stripIndents } = require('common-tags');
|
||||||
const Registry = require('./Registry');
|
const Registry = require('./Registry');
|
||||||
const Dispatcher = require('./Dispatcher');
|
const Dispatcher = require('./Dispatcher');
|
||||||
@@ -95,7 +96,9 @@ module.exports = class CommandClient extends Client {
|
|||||||
const throttleAmount = command.throttles.get(msg.author.id) || 0;
|
const throttleAmount = command.throttles.get(msg.author.id) || 0;
|
||||||
if (throttleAmount >= command.throttling.uses) {
|
if (throttleAmount >= command.throttling.uses) {
|
||||||
const timeout = command._timeouts.get(msg.author.id);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
command.throttles.set(msg.author.id, throttleAmount + 1);
|
command.throttles.set(msg.author.id, throttleAmount + 1);
|
||||||
@@ -224,5 +227,5 @@ module.exports = class CommandClient extends Client {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function getTimeLeft(timeout) {
|
function getTimeLeft(timeout) {
|
||||||
return Math.ceil((timeout._idleStart + timeout._idleTimeout - Date.now()) / 1000);
|
return Math.ceil((timeout._idleStart + timeout._idleTimeout - Date.now()) / 1000);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ module.exports = class CommandDispatcher {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
const content = msg.content.replace(this.commandPattern, '').trim();
|
const content = msg.content.replace(this.commandPattern, '').trim();
|
||||||
const result = (content.match(argRegex) || []).map(m => m.replace(argRegex, '$1$2'));
|
const firstResult = (content.match(argRegex) || []).map(m => m.replace(argRegex, '$1$2'));
|
||||||
const parsed = minimist(result);
|
const parsed = minimist(firstResult);
|
||||||
const result = { flags: [...parsed] };
|
const result = { flags: [...parsed] };
|
||||||
for (let i = 0; i > command.args.length; i++) {
|
for (let i = 0; i > command.args.length; i++) {
|
||||||
const arg = command.args[i];
|
const arg = command.args[i];
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
const { Structures } = require('discord.js');
|
const { Structures } = require('discord.js');
|
||||||
|
|
||||||
module.exports = Structures.extend('Message', Message => {
|
module.exports = Structures.extend('Message', Message => {
|
||||||
return class CommandMessage extends Message {
|
class CommandMessage extends Message {
|
||||||
constructor(...args) {
|
|
||||||
super(...args);
|
|
||||||
}
|
|
||||||
|
|
||||||
say(content, options) {
|
say(content, options) {
|
||||||
return this.channel.send(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 this.channel.send(content, { code: lang, ...options });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return CommandMessage;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ module.exports = class Registry {
|
|||||||
const commands = fs.readdirSync(path.join(dir, group));
|
const commands = fs.readdirSync(path.join(dir, group));
|
||||||
for (const command of commands) {
|
for (const command of commands) {
|
||||||
if (!command.endsWith('.js')) continue;
|
if (!command.endsWith('.js')) continue;
|
||||||
const required = require(path.join(dir, group, command));
|
const Required = require(path.join(dir, group, command));
|
||||||
this.registerCommand(new required(this.client));
|
this.registerCommand(new Required(this.client));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
@@ -62,8 +62,8 @@ module.exports = class Registry {
|
|||||||
const types = fs.readdirSync(dir);
|
const types = fs.readdirSync(dir);
|
||||||
for (const type of types) {
|
for (const type of types) {
|
||||||
if (!type.endsWith('.js')) continue;
|
if (!type.endsWith('.js')) continue;
|
||||||
const required = require(path.join(dir, type));
|
const Required = require(path.join(dir, type));
|
||||||
this.registerType(new required(this.client));
|
this.registerType(new Required(this.client));
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,4 +18,4 @@ module.exports = class BooleanArgumentType extends ArgumentType {
|
|||||||
if (this.falsy.has(lc)) return false;
|
if (this.falsy.has(lc)) return false;
|
||||||
throw new RangeError('Unknown boolean value.');
|
throw new RangeError('Unknown boolean value.');
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ module.exports = class ChannelArgumentType extends ArgumentType {
|
|||||||
if (exactChannels.size === 1) return exactChannels.first();
|
if (exactChannels.size === 1) return exactChannels.first();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
function nameFilterExact(search) {
|
function nameFilterExact(search) {
|
||||||
return thing => thing.name.toLowerCase() === search;
|
return thing => thing.name.toLowerCase() === search;
|
||||||
|
|||||||
@@ -14,4 +14,4 @@ module.exports = class CommandArgumentType extends ArgumentType {
|
|||||||
parse(val) {
|
parse(val) {
|
||||||
return this.client.registry.findCommands(val).first();
|
return this.client.registry.findCommands(val).first();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ module.exports = class CustomEmojiArgumentType extends ArgumentType {
|
|||||||
if (exactEmojis.size === 1) return exactEmojis.first();
|
if (exactEmojis.size === 1) return exactEmojis.first();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
function nameFilterExact(search) {
|
function nameFilterExact(search) {
|
||||||
return emoji => emoji.name.toLowerCase() === search;
|
return emoji => emoji.name.toLowerCase() === search;
|
||||||
|
|||||||
@@ -15,4 +15,4 @@ module.exports = class DefaultEmojiArgumentType extends ArgumentType {
|
|||||||
parse(value) {
|
parse(value) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -17,4 +17,4 @@ module.exports = class FloatArgumentType extends ArgumentType {
|
|||||||
parse(val) {
|
parse(val) {
|
||||||
return Number.parseFloat(val);
|
return Number.parseFloat(val);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -14,4 +14,4 @@ module.exports = class GroupArgumentType extends ArgumentType {
|
|||||||
parse(val) {
|
parse(val) {
|
||||||
return this.client.registry.findGroups(val).first();
|
return this.client.registry.findGroups(val).first();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ module.exports = class IntegerArgumentType extends ArgumentType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
validate(val, msg, arg) {
|
validate(val, msg, arg) {
|
||||||
const int = Number.parseInt(val);
|
const int = Number.parseInt(val, 10);
|
||||||
if (Number.isNaN(int)) return false;
|
if (Number.isNaN(int)) return false;
|
||||||
if (arg.oneOf && !arg.oneOf.includes(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;
|
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) {
|
parse(val) {
|
||||||
return Number.parseInt(val);
|
return Number.parseInt(val, 10);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -36,16 +36,16 @@ module.exports = class MemberArgumentType extends ArgumentType {
|
|||||||
if (exactMembers.size === 1) return exactMembers.first();
|
if (exactMembers.size === 1) return exactMembers.first();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
function memberFilterExact(search) {
|
function memberFilterExact(search) {
|
||||||
return mem => mem.user.username.toLowerCase() === search ||
|
return mem => mem.user.username.toLowerCase() === search
|
||||||
(mem.nickname && mem.nickname.toLowerCase() === search) ||
|
|| (mem.nickname && mem.nickname.toLowerCase() === search)
|
||||||
mem.tag.toLowerCase() === search;
|
|| mem.tag.toLowerCase() === search;
|
||||||
}
|
}
|
||||||
|
|
||||||
function memberFilterInexact(search) {
|
function memberFilterInexact(search) {
|
||||||
return mem => mem.user.username.toLowerCase().includes(search) ||
|
return mem => mem.user.username.toLowerCase().includes(search)
|
||||||
(mem.nickname && mem.nickname.toLowerCase().includes(search)) ||
|
|| (mem.nickname && mem.nickname.toLowerCase().includes(search))
|
||||||
mem.tag.toLowerCase().includes(search);
|
|| mem.tag.toLowerCase().includes(search);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,4 +13,4 @@ module.exports = class MessageArgumentType extends ArgumentType {
|
|||||||
parse(val, msg) {
|
parse(val, msg) {
|
||||||
return msg.channel.messages.cache.get(val);
|
return msg.channel.messages.cache.get(val);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ module.exports = class RoleArgumentType extends ArgumentType {
|
|||||||
if (exactRoles.size === 1) return exactRoles.first();
|
if (exactRoles.size === 1) return exactRoles.first();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
function nameFilterExact(search) {
|
function nameFilterExact(search) {
|
||||||
return thing => thing.name.toLowerCase() === search;
|
return thing => thing.name.toLowerCase() === search;
|
||||||
|
|||||||
@@ -15,4 +15,4 @@ module.exports = class StringArgumentType extends ArgumentType {
|
|||||||
parse(val) {
|
parse(val) {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ module.exports = class UserArgumentType extends ArgumentType {
|
|||||||
super(client, 'user');
|
super(client, 'user');
|
||||||
}
|
}
|
||||||
|
|
||||||
async validate(val, msg, arg) {
|
async validate(val, msg) {
|
||||||
const matches = val.match(/^(?:<@!?)?([0-9]+)>?$/);
|
const matches = val.match(/^(?:<@!?)?([0-9]+)>?$/);
|
||||||
if (matches) {
|
if (matches) {
|
||||||
try {
|
try {
|
||||||
@@ -38,16 +38,16 @@ module.exports = class UserArgumentType extends ArgumentType {
|
|||||||
if (exactMembers.size === 1) return exactMembers.first().user;
|
if (exactMembers.size === 1) return exactMembers.first().user;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
function memberFilterExact(search) {
|
function memberFilterExact(search) {
|
||||||
return mem => mem.user.username.toLowerCase() === search ||
|
return mem => mem.user.username.toLowerCase() === search
|
||||||
(mem.nickname && mem.nickname.toLowerCase() === search) ||
|
|| (mem.nickname && mem.nickname.toLowerCase() === search)
|
||||||
mem.tag.toLowerCase() === search;
|
|| mem.tag.toLowerCase() === search;
|
||||||
}
|
}
|
||||||
|
|
||||||
function memberFilterInexact(search) {
|
function memberFilterInexact(search) {
|
||||||
return mem => mem.user.username.toLowerCase().includes(search) ||
|
return mem => mem.user.username.toLowerCase().includes(search)
|
||||||
(mem.nickname && mem.nickname.toLowerCase().includes(search)) ||
|
|| (mem.nickname && mem.nickname.toLowerCase().includes(search))
|
||||||
mem.tag.toLowerCase().includes(search);
|
|| mem.tag.toLowerCase().includes(search);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user