diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/bot.ts | 4 | ||||
| -rw-r--r-- | src/commands/dev/eval.ts (renamed from src/commands/owner/eval.ts) | 61 | ||||
| -rw-r--r-- | src/commands/dev/reload.ts (renamed from src/commands/owner/reload.ts) | 5 | ||||
| -rw-r--r-- | src/commands/dev/setLevel.ts (renamed from src/commands/owner/setlevel.ts) | 23 | ||||
| -rw-r--r-- | src/commands/info/botInfo.ts (renamed from src/commands/info/botinfo.ts) | 26 | ||||
| -rw-r--r-- | src/commands/info/help.ts | 52 | ||||
| -rw-r--r-- | src/commands/info/ping.ts | 35 | ||||
| -rw-r--r-- | src/commands/info/pronouns.ts | 6 | ||||
| -rw-r--r-- | src/commands/moderation/ban.ts | 84 | ||||
| -rw-r--r-- | src/commands/moderation/kick.ts | 40 | ||||
| -rw-r--r-- | src/commands/moderation/modlog.ts | 26 | ||||
| -rw-r--r-- | src/commands/moderation/role.ts | 112 | ||||
| -rw-r--r-- | src/commands/moderation/warn.ts | 22 | ||||
| -rw-r--r-- | src/commands/moulberry-bush/capePerms.ts (renamed from src/commands/moulberry-bush/capeperms.ts) | 34 | ||||
| -rw-r--r-- | src/commands/moulberry-bush/giveawayPing.ts (renamed from src/commands/moulberry-bush/giveawayping.ts) | 34 | ||||
| -rw-r--r-- | src/commands/moulberry-bush/level.ts | 8 | ||||
| -rw-r--r-- | src/commands/moulberry-bush/rule.ts | 67 | ||||
| -rw-r--r-- | src/commands/server-config/prefix.ts (renamed from src/commands/admin/prefix.ts) | 28 | ||||
| -rw-r--r-- | src/config/example-options.ts | 7 | ||||
| -rw-r--r-- | src/inhibitors/blacklist/blacklist.ts (renamed from src/inhibitors/blacklist/BlacklistInhibitor.ts) | 4 | ||||
| -rw-r--r-- | src/lib/extensions/BotInhibitor.ts | 6 | ||||
| -rw-r--r-- | src/lib/extensions/BotListener.ts | 6 | ||||
| -rw-r--r-- | src/lib/extensions/BotTask.ts | 6 | ||||
| -rw-r--r-- | src/lib/extensions/BushClient.ts (renamed from src/lib/extensions/BotClient.ts) | 37 | ||||
| -rw-r--r-- | src/lib/extensions/BushCommand.ts (renamed from src/lib/extensions/BotCommand.ts) | 10 | ||||
| -rw-r--r-- | src/lib/extensions/BushInhibitor.ts | 6 | ||||
| -rw-r--r-- | src/lib/extensions/BushListener.ts | 6 | ||||
| -rw-r--r-- | src/lib/extensions/BushTask.ts | 6 | ||||
| -rw-r--r-- | src/lib/extensions/Util.ts | 37 | ||||
| -rw-r--r-- | src/lib/models/Ban.ts | 5 | ||||
| -rw-r--r-- | src/lib/models/Guild.ts | 9 | ||||
| -rw-r--r-- | src/lib/models/Modlog.ts | 14 | ||||
| -rw-r--r-- | src/lib/utils/AllowedMentions.ts | 6 | ||||
| -rw-r--r-- | src/lib/utils/Console.ts | 93 | ||||
| -rw-r--r-- | src/lib/utils/Logger.ts | 12 | ||||
| -rw-r--r-- | src/listeners/client/ready.ts | 9 | ||||
| -rw-r--r-- | src/listeners/client/syncSlashCommands.ts (renamed from src/listeners/client/syncslashcommands.ts) | 6 | ||||
| -rw-r--r-- | src/listeners/commands/commandBlocked.ts (renamed from src/listeners/commands/commandblocked.ts) | 14 | ||||
| -rw-r--r-- | src/listeners/commands/commandError.ts (renamed from src/listeners/commands/error.ts) | 16 | ||||
| -rw-r--r-- | src/listeners/commands/commandStarted.ts | 20 | ||||
| -rw-r--r-- | src/listeners/commands/commandstarted.ts | 24 | ||||
| -rw-r--r-- | src/listeners/commands/slashCommandError.ts (renamed from src/listeners/commands/slashError.ts) | 16 | ||||
| -rw-r--r-- | src/listeners/guild/syncUnban.ts (renamed from src/listeners/guild/syncunban.ts) | 4 | ||||
| -rw-r--r-- | src/listeners/message/level.ts (renamed from src/listeners/message/levels.ts) | 12 | ||||
| -rw-r--r-- | src/tasks/unban.ts (renamed from src/tasks/Unban.ts) | 13 |
45 files changed, 390 insertions, 681 deletions
@@ -1,5 +1,5 @@ -import { BotClient } from './lib/extensions/BotClient'; +import { BushClient } from './lib/extensions/BushClient'; import * as config from './config/options'; -const client: BotClient = new BotClient(config); +const client: BushClient = new BushClient(config); client.start(); diff --git a/src/commands/owner/eval.ts b/src/commands/dev/eval.ts index a63b977..cfe75cc 100644 --- a/src/commands/owner/eval.ts +++ b/src/commands/dev/eval.ts @@ -1,18 +1,15 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; import { MessageEmbed, Message } from 'discord.js'; import { inspect, promisify } from 'util'; import { exec } from 'child_process'; const clean = (text) => { - if (typeof text === 'string') - return text - .replace(/`/g, '`' + String.fromCharCode(8203)) - .replace(/@/g, '@' + String.fromCharCode(8203)); + if (typeof text === 'string') return text.replace(/`/g, '`' + String.fromCharCode(8203)).replace(/@/g, '@' + String.fromCharCode(8203)); else return text; }; -export default class EvalCommand extends BotCommand { +export default class EvalCommand extends BushCommand { public constructor() { super('eval', { aliases: ['eval', 'ev'], @@ -50,10 +47,7 @@ export default class EvalCommand extends BotCommand { }); } - public async exec( - message: Message, - { depth, code, silent }: { depth: number; code: string; silent: boolean } - ): Promise<void> { + public async exec(message: Message, { depth, code, silent }: { depth: number; code: string; silent: boolean }): Promise<void> { const embed: MessageEmbed = new MessageEmbed(); try { @@ -70,58 +64,27 @@ export default class EvalCommand extends BotCommand { output = eval(code); output = await output; if (typeof output !== 'string') output = inspect(output, { depth }); - output = output.replace( - new RegExp(this.client.token, 'g'), - '[token omitted]' - ); + output = output.replace(new RegExp(this.client.token, 'g'), '[token omitted]'); output = clean(output); embed .setTitle('✅ Evaled code successfully') - .addField( - '📥 Input', - code.length > 1012 - ? 'Too large to display. Hastebin: ' + - (await this.client.util.haste(code)) - : '```js\n' + code + '```' - ) - .addField( - '📤 Output', - output.length > 1012 - ? 'Too large to display. Hastebin: ' + - (await this.client.util.haste(output)) - : '```js\n' + output + '```' - ) + .addField('📥 Input', code.length > 1012 ? 'Too large to display. Hastebin: ' + (await this.client.util.haste(code)) : '```js\n' + code + '```') + .addField('📤 Output', output.length > 1012 ? 'Too large to display. Hastebin: ' + (await this.client.util.haste(output)) : '```js\n' + output + '```') .setColor('#66FF00') - .setFooter( - message.author.username, - message.author.displayAvatarURL({ dynamic: true }) - ) + .setFooter(message.author.username, message.author.displayAvatarURL({ dynamic: true })) .setTimestamp(); } catch (e) { embed .setTitle('❌ Code was not able to be evaled') - .addField( - '📥 Input', - code.length > 1012 - ? 'Too large to display. Hastebin: ' + - (await this.client.util.haste(code)) - : '```js\n' + code + '```' - ) + .addField('📥 Input', code.length > 1012 ? 'Too large to display. Hastebin: ' + (await this.client.util.haste(code)) : '```js\n' + code + '```') .addField( '📤 Output', e.length > 1012 - ? 'Too large to display. Hastebin: ' + - (await this.client.util.haste(e)) - : '```js\n' + - e + - '```Full stack:' + - (await this.client.util.haste(e.stack)) + ? 'Too large to display. Hastebin: ' + (await this.client.util.haste(e)) + : '```js\n' + e + '```Full stack:' + (await this.client.util.haste(e.stack)) ) .setColor('#FF0000') - .setFooter( - message.author.username, - message.author.displayAvatarURL({ dynamic: true }) - ) + .setFooter(message.author.username, message.author.displayAvatarURL({ dynamic: true })) .setTimestamp(); } if (!silent) { diff --git a/src/commands/owner/reload.ts b/src/commands/dev/reload.ts index 8ba6160..36c6fd7 100644 --- a/src/commands/owner/reload.ts +++ b/src/commands/dev/reload.ts @@ -1,14 +1,15 @@ -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; import { stripIndent } from 'common-tags'; import { Message } from 'discord.js'; import { CommandInteraction } from 'discord.js'; import { SlashCommandOption } from '../../lib/extensions/Util'; import { ApplicationCommandOptionType } from 'discord-api-types'; -export default class ReloadCommand extends BotCommand { +export default class ReloadCommand extends BushCommand { constructor() { super('reload', { aliases: ['reload'], + category: 'dev', description: { content: 'Reloads the bot', usage: 'reload', diff --git a/src/commands/owner/setlevel.ts b/src/commands/dev/setLevel.ts index 6987385..3a1bc85 100644 --- a/src/commands/owner/setlevel.ts +++ b/src/commands/dev/setLevel.ts @@ -2,19 +2,20 @@ import { ApplicationCommandOptionType } from 'discord-api-types'; import { CommandInteraction } from 'discord.js'; import { User } from 'discord.js'; import { Message } from 'discord.js'; -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; import { SlashCommandOption } from '../../lib/extensions/Util'; import { Level } from '../../lib/models'; import AllowedMentions from '../../lib/utils/AllowedMentions'; -export default class SetLevelCommand extends BotCommand { +export default class SetLevelCommand extends BushCommand { constructor() { super('setlevel', { aliases: ['setlevel'], + category: 'dev', description: { content: 'Sets the level of a user', usage: 'setlevel <user> <level>', - examples: ['setlevel @Moulberry 69'] + examples: ['setlevel @Moulberry 69'] //nice }, args: [ { @@ -22,8 +23,7 @@ export default class SetLevelCommand extends BotCommand { type: 'user', prompt: { start: 'What user would you like to change the level of?', - retry: - 'Invalid user. What user would you like to change the level of?' + retry: 'Invalid user. What user would you like to change the level of?' } }, { @@ -67,22 +67,13 @@ export default class SetLevelCommand extends BotCommand { return `Successfully set level of <@${user.id}> to \`${level}\` (\`${levelEntry.xp}\` XP)`; } - async exec( - message: Message, - { user, level }: { user: User; level: number } - ): Promise<void> { + async exec(message: Message, { user, level }: { user: User; level: number }): Promise<void> { await message.util.send(await this.setLevel(user, level), { allowedMentions: AllowedMentions.none() }); } - async execSlash( - message: CommandInteraction, - { - user, - level - }: { user: SlashCommandOption<void>; level: SlashCommandOption<number> } - ): Promise<void> { + async execSlash(message: CommandInteraction, { user, level }: { user: SlashCommandOption<void>; level: SlashCommandOption<number> }): Promise<void> { await message.reply(await this.setLevel(user.user, level.value), { allowedMentions: AllowedMentions.none() }); diff --git a/src/commands/info/botinfo.ts b/src/commands/info/botInfo.ts index 8f5f055..ebbd0c9 100644 --- a/src/commands/info/botinfo.ts +++ b/src/commands/info/botInfo.ts @@ -1,11 +1,12 @@ import { MessageEmbed, Message, CommandInteraction } from 'discord.js'; -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; import { duration } from 'moment'; -export default class BotInfoCommand extends BotCommand { +export default class BotInfoCommand extends BushCommand { constructor() { super('botinfo', { aliases: ['botinfo'], + category: 'info', description: { content: 'Shows information about the bot', usage: 'botinfo', @@ -15,15 +16,9 @@ export default class BotInfoCommand extends BotCommand { } private async generateEmbed(): Promise<MessageEmbed> { - const owners = (await this.client.util.mapIDs(this.client.ownerID)) - .map((u) => u.tag) - .join('\n'); - const currentCommit = ( - await this.client.util.shell('git rev-parse HEAD') - ).stdout.replace('\n', ''); - const repoUrl = ( - await this.client.util.shell('git remote get-url origin') - ).stdout.replace('\n', ''); + const owners = (await this.client.util.mapIDs(this.client.ownerID)).map((u) => u.tag).join('\n'); + const currentCommit = (await this.client.util.shell('git rev-parse HEAD')).stdout.replace('\n', ''); + const repoUrl = (await this.client.util.shell('git remote get-url origin')).stdout.replace('\n', ''); const embed = new MessageEmbed() .setTitle('Bot Info:') .addFields([ @@ -34,9 +29,7 @@ export default class BotInfoCommand extends BotCommand { }, { name: 'Uptime', - value: this.client.util.capitalize( - duration(this.client.uptime, 'milliseconds').humanize() - ) + value: this.client.util.capitalize(duration(this.client.uptime, 'milliseconds').humanize()) }, { name: 'User count', @@ -45,10 +38,7 @@ export default class BotInfoCommand extends BotCommand { }, { name: 'Current commit', - value: `[${currentCommit.substring( - 0, - 7 - )}](${repoUrl}/commit/${currentCommit})` + value: `[${currentCommit.substring(0, 7)}](${repoUrl}/commit/${currentCommit})` } ]) .setTimestamp(); diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts index 116669c..7f6c8f4 100644 --- a/src/commands/info/help.ts +++ b/src/commands/info/help.ts @@ -1,14 +1,15 @@ import { Message, MessageEmbed } from 'discord.js'; -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; import { stripIndent } from 'common-tags'; import { ApplicationCommandOptionType } from 'discord-api-types'; import { CommandInteraction } from 'discord.js'; import { SlashCommandOption } from '../../lib/extensions/Util'; -export default class HelpCommand extends BotCommand { +export default class HelpCommand extends BushCommand { constructor() { super('help', { aliases: ['help'], + category: 'info', description: { content: 'Shows the commands of the bot', usage: 'help', @@ -32,7 +33,7 @@ export default class HelpCommand extends BotCommand { }); } - private generateEmbed(command?: BotCommand): MessageEmbed { + private generateEmbed(command?: BushCommand): MessageEmbed { const prefix = this.handler.prefix; if (!command) { const embed = new MessageEmbed() @@ -42,15 +43,11 @@ export default class HelpCommand extends BotCommand { For additional info on a command, type \`${prefix}help <command>\` ` ) - .setFooter( - `For more information about a command use "${this.client.config.prefix}help <command>"` - ) + .setFooter(`For more information about a command use "${this.client.config.prefix}help <command>"`) .setTimestamp(); for (const category of this.handler.categories.values()) { embed.addField( - `${category.id.replace(/(\b\w)/gi, (lc): string => - lc.toUpperCase() - )}`, + `${category.id.replace(/(\b\w)/gi, (lc): string => lc.toUpperCase())}`, `${category .filter((cmd): boolean => cmd.aliases.length > 0) .map((cmd): string => `\`${cmd.aliases[0]}\``) @@ -61,45 +58,22 @@ export default class HelpCommand extends BotCommand { } else { const embed = new MessageEmbed() .setColor([155, 200, 200]) - .setTitle( - `\`${command.description.usage ? command.description.usage : ''}\`` - ) - .addField( - 'Description', - `${command.description.content ? command.description.content : ''} ${ - command.ownerOnly ? '\n__Owner Only__' : '' - }` - ); + .setTitle(`\`${command.description.usage ? command.description.usage : ''}\``) + .addField('Description', `${command.description.content ? command.description.content : ''} ${command.ownerOnly ? '\n__Owner Only__' : ''}`); - if (command.aliases.length > 1) - embed.addField('Aliases', `\`${command.aliases.join('` `')}\``, true); - if (command.description.examples && command.description.examples.length) - embed.addField( - 'Examples', - `\`${command.description.examples.join('`\n`')}\``, - true - ); + if (command.aliases.length > 1) embed.addField('Aliases', `\`${command.aliases.join('` `')}\``, true); + if (command.description.examples && command.description.examples.length) embed.addField('Examples', `\`${command.description.examples.join('`\n`')}\``, true); return embed; } } - public async exec( - message: Message, - { command }: { command: BotCommand } - ): Promise<void> { + public async exec(message: Message, { command }: { command: BushCommand }): Promise<void> { await message.util.send(this.generateEmbed(command)); } - public async execSlash( - message: CommandInteraction, - { command }: { command: SlashCommandOption<string> } - ): Promise<void> { + public async execSlash(message: CommandInteraction, { command }: { command: SlashCommandOption<string> }): Promise<void> { if (command) { - await message.reply( - this.generateEmbed( - this.handler.findCommand(command.value) as BotCommand - ) - ); + await message.reply(this.generateEmbed(this.handler.findCommand(command.value) as BushCommand)); } else { await message.reply(this.generateEmbed()); } diff --git a/src/commands/info/ping.ts b/src/commands/info/ping.ts index e51867f..b130e6d 100644 --- a/src/commands/info/ping.ts +++ b/src/commands/info/ping.ts @@ -1,12 +1,13 @@ import { CommandInteraction } from 'discord.js'; import { Message } from 'discord.js'; import { MessageEmbed } from 'discord.js'; -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; -export default class PingCommand extends BotCommand { +export default class PingCommand extends BushCommand { constructor() { super('ping', { aliases: ['ping'], + category: 'info', description: { content: 'Gets the latency of the bot', usage: 'ping', @@ -17,23 +18,14 @@ export default class PingCommand extends BotCommand { public async exec(message: Message): Promise<void> { const sentMessage = await message.util.send('Pong!'); - const timestamp: number = message.editedTimestamp - ? message.editedTimestamp - : message.createdTimestamp; - const botLatency = `\`\`\`\n ${Math.floor( - sentMessage.createdTimestamp - timestamp - )}ms \`\`\``; - const apiLatency = `\`\`\`\n ${Math.round( - message.client.ws.ping - )}ms \`\`\``; + const timestamp: number = message.editedTimestamp ? message.editedTimestamp : message.createdTimestamp; + const botLatency = `\`\`\`\n ${Math.floor(sentMessage.createdTimestamp - timestamp)}ms \`\`\``; + const apiLatency = `\`\`\`\n ${Math.round(message.client.ws.ping)}ms \`\`\``; const embed = new MessageEmbed() .setTitle('Pong! 🏓') .addField('Bot Latency', botLatency, true) .addField('API Latency', apiLatency, true) - .setFooter( - message.author.username, - message.author.displayAvatarURL({ dynamic: true }) - ) + .setFooter(message.author.username, message.author.displayAvatarURL({ dynamic: true })) .setTimestamp(); await sentMessage.edit({ content: null, @@ -44,21 +36,14 @@ export default class PingCommand extends BotCommand { public async execSlash(message: CommandInteraction): Promise<void> { const timestamp1 = message.createdTimestamp; await message.reply('Pong!'); - const timestamp2 = await message - .fetchReply() - .then((m) => (m as Message).createdTimestamp); - const botLatency = `\`\`\`\n ${Math.floor( - timestamp2 - timestamp1 - )}ms \`\`\``; + const timestamp2 = await message.fetchReply().then((m) => (m as Message).createdTimestamp); + const botLatency = `\`\`\`\n ${Math.floor(timestamp2 - timestamp1)}ms \`\`\``; const apiLatency = `\`\`\`\n ${Math.round(this.client.ws.ping)}ms \`\`\``; const embed = new MessageEmbed() .setTitle('Pong! 🏓') .addField('Bot Latency', botLatency, true) .addField('API Latency', apiLatency, true) - .setFooter( - message.user.username, - message.user.displayAvatarURL({ dynamic: true }) - ) + .setFooter(message.user.username, message.user.displayAvatarURL({ dynamic: true })) .setTimestamp(); await message.editReply({ content: null, diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts index 97cca34..2c1d5f2 100644 --- a/src/commands/info/pronouns.ts +++ b/src/commands/info/pronouns.ts @@ -1,4 +1,4 @@ -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; import { User, Message, MessageEmbed } from 'discord.js'; import got, { HTTPError } from 'got'; import { CommandInteraction } from 'discord.js'; @@ -30,11 +30,11 @@ export const pronounMapping = { }; export type pronounsType = keyof typeof pronounMapping; -export default class PronounsCommand extends BotCommand { +export default class PronounsCommand extends BushCommand { constructor() { super('pronouns', { aliases: ['pronouns', 'pronoun'], - category: 'utilities', + category: 'info', description: { usage: 'pronouns <user>', examples: ['pronouns IRONM00N'], diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index 556dd6b..e59a528 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -1,6 +1,6 @@ import { User } from 'discord.js'; import { Guild } from '../../lib/models'; -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; import { Ban, Modlog, ModlogType } from '../../lib/models'; import moment from 'moment'; import { Message } from 'discord.js'; @@ -15,13 +15,13 @@ const durationAliases: Record<string, string[]> = { minutes: ['m', 'min', 'mins', 'minutes', 'minute'], months: ['mo', 'month', 'months'] }; -const durationRegex = - /(?:(\d+)(d(?:ays?)?|h(?:ours?|rs?)?|m(?:inutes?|ins?)?|mo(?:nths?)?|w(?:eeks?|ks?)?)(?: |$))/g; +const durationRegex = /(?:(\d+)(d(?:ays?)?|h(?:ours?|rs?)?|m(?:inutes?|ins?)?|mo(?:nths?)?|w(?:eeks?|ks?)?)(?: |$))/g; -export default class PrefixCommand extends BotCommand { +export default class BanCommand extends BushCommand { constructor() { super('ban', { aliases: ['ban'], + category: 'moderation', args: [ { id: 'user', @@ -44,13 +44,9 @@ export default class PrefixCommand extends BotCommand { clientPermissions: ['BAN_MEMBERS'], userPermissions: ['BAN_MEMBERS'], description: { - content: - 'Ban a member and log it in modlogs (with optional time to unban)', + content: 'Ban a member and log it in modlogs (with optional time to unban)', usage: 'ban <member> <reason> [--time]', - examples: [ - 'ban @Tyman being cool', - 'ban @Tyman being cool --time 7days' - ] + examples: ['ban @Tyman being cool', 'ban @Tyman being cool --time 7days'] }, slashCommandOptions: [ { @@ -68,19 +64,13 @@ export default class PrefixCommand extends BotCommand { { type: ApplicationCommandOptionType.STRING, name: 'time', - description: - 'The time the user should be banned for (default permanent)', + description: 'The time the user should be banned for (default permanent)', required: false } ] }); } - async *genResponses( - message: Message | CommandInteraction, - user: User, - reason?: string, - time?: string - ): AsyncIterable<string> { + async *genResponses(message: Message | CommandInteraction, user: User, reason?: string, time?: string): AsyncIterable<string> { const duration = moment.duration(); let modlogEnry: Modlog; let banEntry: Ban; @@ -103,14 +93,9 @@ export default class PrefixCommand extends BotCommand { return; } for (const part of parsed) { - const translated = Object.keys(durationAliases).find((k) => - durationAliases[k].includes(part[2]) - ); + const translated = Object.keys(durationAliases).find((k) => durationAliases[k].includes(part[2])); translatedTime.push(part[1] + ' ' + translated); - duration.add( - Number(part[1]), - translated as 'weeks' | 'days' | 'hours' | 'months' | 'minutes' - ); + duration.add(Number(part[1]), translated as 'weeks' | 'days' | 'hours' | 'months' | 'minutes'); } modlogEnry = Modlog.build({ user: user.id, @@ -118,10 +103,7 @@ export default class PrefixCommand extends BotCommand { reason, type: ModlogType.TEMPBAN, duration: duration.asMilliseconds(), - moderator: - message instanceof CommandInteraction - ? message.user.id - : message.author.id + moderator: message instanceof CommandInteraction ? message.user.id : message.author.id }); banEntry = Ban.build({ user: user.id, @@ -136,10 +118,7 @@ export default class PrefixCommand extends BotCommand { guild: message.guild.id, reason, type: ModlogType.BAN, - moderator: - message instanceof CommandInteraction - ? message.user.id - : message.author.id + moderator: message instanceof CommandInteraction ? message.user.id : message.author.id }); banEntry = Ban.build({ user: user.id, @@ -157,27 +136,17 @@ export default class PrefixCommand extends BotCommand { } try { await user.send( - `You were banned in ${message.guild.name} ${ - translatedTime.length >= 1 - ? `for ${translatedTime.join(', ')}` - : 'permanently' - } with reason \`${reason || 'No reason given'}\`` + `You were banned in ${message.guild.name} ${translatedTime.length >= 1 ? `for ${translatedTime.join(', ')}` : 'permanently'} with reason \`${ + reason || 'No reason given' + }\`` ); } catch (e) { yield 'Error sending message to user'; } await message.guild.members.ban(user, { - reason: `Banned by ${ - message instanceof CommandInteraction - ? message.user.tag - : message.author.tag - } with ${reason ? `reason ${reason}` : 'no reason'}` + reason: `Banned by ${message instanceof CommandInteraction ? message.user.tag : message.author.tag} with ${reason ? `reason ${reason}` : 'no reason'}` }); - yield `Banned <@!${user.id}> ${ - translatedTime.length >= 1 - ? `for ${translatedTime.join(', ')}` - : 'permanently' - } with reason \`${reason || 'No reason given'}\``; + yield `Banned <@!${user.id}> ${translatedTime.length >= 1 ? `for ${translatedTime.join(', ')}` : 'permanently'} with reason \`${reason || 'No reason given'}\``; } catch { yield 'Error banning :/'; await banEntry.destroy(); @@ -185,16 +154,8 @@ export default class PrefixCommand extends BotCommand { return; } } - async exec( - message: Message, - { user, reason, time }: { user: User; reason?: string; time?: string } - ): Promise<void> { - for await (const response of this.genResponses( - message, - user, - reason, - time - )) { + async exec(message: Message, { user, reason, time }: { user: User; reason?: string; time?: string }): Promise<void> { + for await (const response of this.genResponses(message, user, reason, time)) { await message.util.send(response); } } @@ -211,12 +172,7 @@ export default class PrefixCommand extends BotCommand { time: SlashCommandOption<string>; } ): Promise<void> { - for await (const response of this.genResponses( - message, - user.user, - reason?.value, - time?.value - )) { + for await (const response of this.genResponses(message, user.user, reason?.value, time?.value)) { await message.reply(response); } } diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts index f31047e..182485a 100644 --- a/src/comman |
