mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-05 13:53:12 +02:00
Fix lint
This commit is contained in:
+5
-2
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -18,4 +18,4 @@ module.exports = class BooleanArgumentType extends ArgumentType {
|
||||
if (this.falsy.has(lc)) return false;
|
||||
throw new RangeError('Unknown boolean value.');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -14,4 +14,4 @@ module.exports = class CommandArgumentType extends ArgumentType {
|
||||
parse(val) {
|
||||
return this.client.registry.findCommands(val).first();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -15,4 +15,4 @@ module.exports = class DefaultEmojiArgumentType extends ArgumentType {
|
||||
parse(value) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -17,4 +17,4 @@ module.exports = class FloatArgumentType extends ArgumentType {
|
||||
parse(val) {
|
||||
return Number.parseFloat(val);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -14,4 +14,4 @@ module.exports = class GroupArgumentType extends ArgumentType {
|
||||
parse(val) {
|
||||
return this.client.registry.findGroups(val).first();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -13,4 +13,4 @@ module.exports = class MessageArgumentType extends ArgumentType {
|
||||
parse(val, msg) {
|
||||
return msg.channel.messages.cache.get(val);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -15,4 +15,4 @@ module.exports = class StringArgumentType extends ArgumentType {
|
||||
parse(val) {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user