diff options
Diffstat (limited to 'src/commands')
46 files changed, 205 insertions, 231 deletions
diff --git a/src/commands/admin/channelPermissions.ts b/src/commands/admin/channelPermissions.ts index 249789d..00d37c3 100644 --- a/src/commands/admin/channelPermissions.ts +++ b/src/commands/admin/channelPermissions.ts @@ -89,7 +89,7 @@ export default class ChannelPermissionsCommand extends BushCommand { paginate.push(new MessageEmbed().setDescription(failure.substring(i, Math.min(failure.length, i + 2000)))); } const normalMessage = `Finished changing perms! Failed channels:`; - this.client.util.buttonPaginate(message, paginate, normalMessage); + util.buttonPaginate(message, paginate, normalMessage); } else { await message.util.reply({ content: `Finished changing perms! Failed channels:`, embeds: [{ description: failure }] }); } diff --git a/src/commands/config/autoPublishChannel.ts b/src/commands/config/autoPublishChannel.ts index a2692e2..8fa987b 100644 --- a/src/commands/config/autoPublishChannel.ts +++ b/src/commands/config/autoPublishChannel.ts @@ -40,14 +40,14 @@ export default class AutoPublishChannelCommand extends BushCommand { public async exec(message: BushMessage, { channel }: { channel: Channel }): Promise<unknown> { const autoPublishChannels = await message.guild.getSetting('autoPublishChannels'); - const newValue = this.client.util.addOrRemoveFromArray( + const newValue = util.addOrRemoveFromArray( autoPublishChannels.includes(channel.id) ? 'remove' : 'add', autoPublishChannels, channel.id ); await message.guild.setSetting('autoPublishChannels', newValue); return await message.util.reply({ - content: `${this.client.util.emojis.success} Successfully ${ + content: `${util.emojis.success} Successfully ${ autoPublishChannels.includes(channel.id) ? 'disabled' : 'enabled' } auto publishing in <#${channel.id}>.`, allowedMentions: AllowedMentions.none() diff --git a/src/commands/config/blacklist.ts b/src/commands/config/blacklist.ts index 5696c40..33bff35 100644 --- a/src/commands/config/blacklist.ts +++ b/src/commands/config/blacklist.ts @@ -72,7 +72,7 @@ export default class BlacklistCommand extends BushCommand { ? (await Argument.cast('channel', this.client.commandHandler.resolver, message as BushMessage, args.target)) ?? (await Argument.cast('user', this.client.commandHandler.resolver, message as BushMessage, args.target)) : args.target; - if (!target) return await message.util.reply(`${this.client.util.emojis.error} Choose a valid channel or user.`); + if (!target) return await message.util.reply(`${util.emojis.error} Choose a valid channel or user.`); const targetID = target.id; if (global) { @@ -81,7 +81,7 @@ export default class BlacklistCommand extends BushCommand { const blacklistedChannels = (await Global.findByPk(this.client.config.environment)).blacklistedChannels; action = blacklistedUsers.includes(targetID) || blacklistedChannels.includes(targetID) ? 'unblacklist' : 'blacklist'; } - const success = await this.client.util + const success = await util .insertOrRemoveFromGlobal( action === 'blacklist' ? 'add' : 'remove', target instanceof User ? 'blacklistedUsers' : 'blacklistedChannels', @@ -90,14 +90,12 @@ export default class BlacklistCommand extends BushCommand { .catch(() => false); if (!success) return await message.util.reply({ - content: `${this.client.util.emojis.error} There was an error globally **${action}ing** ${ - target?.tag ?? target.name - }.`, + content: `${util.emojis.error} There was an error globally **${action}ing** ${target?.tag ?? target.name}.`, allowedMentions: AllowedMentions.none() }); else return await message.util.reply({ - content: `${this.client.util.emojis.success} Successfully **${action}ed** ${target?.tag ?? target.name} globally.`, + content: `${util.emojis.success} Successfully **${action}ed** ${target?.tag ?? target.name} globally.`, allowedMentions: AllowedMentions.none() }); // guild disable @@ -107,7 +105,7 @@ export default class BlacklistCommand extends BushCommand { if (action === 'toggle') { action = blacklistedChannels.includes(targetID) ?? blacklistedUsers.includes(targetID) ? 'unblacklist' : 'blacklist'; } - const newValue = this.client.util.addOrRemoveFromArray( + const newValue = util.addOrRemoveFromArray( action === 'blacklist' ? 'add' : 'remove', target instanceof User ? blacklistedUsers : blacklistedChannels, targetID @@ -117,12 +115,12 @@ export default class BlacklistCommand extends BushCommand { .catch(() => false); if (!success) return await message.util.reply({ - content: `${this.client.util.emojis.error} There was an error **${action}ing** ${target?.tag ?? target.name}.`, + content: `${util.emojis.error} There was an error **${action}ing** ${target?.tag ?? target.name}.`, allowedMentions: AllowedMentions.none() }); else return await message.util.reply({ - content: `${this.client.util.emojis.success} Successfully **${action}ed** ${target?.tag ?? target.name}.`, + content: `${util.emojis.success} Successfully **${action}ed** ${target?.tag ?? target.name}.`, allowedMentions: AllowedMentions.none() }); } diff --git a/src/commands/config/disable.ts b/src/commands/config/disable.ts index 00d2561..27e7311 100644 --- a/src/commands/config/disable.ts +++ b/src/commands/config/disable.ts @@ -75,12 +75,12 @@ export default class DisableCommand extends BushCommand { const disabledCommands = (await Global.findByPk(this.client.config.environment)).disabledCommands; action = disabledCommands.includes(commandID) ? 'disable' : 'enable'; } - const success = await this.client.util + const success = await util .insertOrRemoveFromGlobal(action === 'disable' ? 'remove' : 'add', 'disabledCommands', commandID) .catch(() => false); if (!success) return await message.util.reply({ - content: `${this.client.util.emojis.error} There was an error globally **${action.substr( + content: `${util.emojis.error} There was an error globally **${action.substr( 0, action.length - 2 )}ing** the **${commandID}** command.`, @@ -88,7 +88,7 @@ export default class DisableCommand extends BushCommand { }); else return await message.util.reply({ - content: `${this.client.util.emojis.success} Successfully **${action.substr( + content: `${util.emojis.success} Successfully **${action.substr( 0, action.length - 2 )}ed** the **${commandID}** command globally.`, @@ -101,15 +101,11 @@ export default class DisableCommand extends BushCommand { if (action === 'toggle') { action = disabledCommands.includes(commandID) ? 'disable' : 'enable'; } - const newValue = this.client.util.addOrRemoveFromArray( - action === 'disable' ? 'remove' : 'add', - disabledCommands, - commandID - ); + const newValue = util.addOrRemoveFromArray(action === 'disable' ? 'remove' : 'add', disabledCommands, commandID); const success = await message.guild.setSetting('disabledCommands', newValue).catch(() => false); if (!success) return await message.util.reply({ - content: `${this.client.util.emojis.error} There was an error **${action.substr( + content: `${util.emojis.error} There was an error **${action.substr( 0, action.length - 2 )}ing** the **${commandID}** command.`, @@ -117,7 +113,7 @@ export default class DisableCommand extends BushCommand { }); else return await message.util.reply({ - content: `${this.client.util.emojis.success} Successfully **${action.substr( + content: `${util.emojis.success} Successfully **${action.substr( 0, action.length - 2 )}ed** the **${commandID}** command.`, diff --git a/src/commands/config/muteRole.ts b/src/commands/config/muteRole.ts index 9074a1d..b6e8a81 100644 --- a/src/commands/config/muteRole.ts +++ b/src/commands/config/muteRole.ts @@ -40,7 +40,7 @@ export default class MuteRoleCommand extends BushCommand { async exec(message: BushMessage | BushSlashMessage, args: { role: Role }): Promise<void> { await message.guild.setSetting('muteRole', args.role.id); await message.util.send({ - content: `${this.client.util.emojis.success} Changed the server's mute role to <@&${args.role.id}>.`, + content: `${util.emojis.success} Changed the server's mute role to <@&${args.role.id}>.`, allowedMentions: AllowedMentions.none() }); } diff --git a/src/commands/config/prefix.ts b/src/commands/config/prefix.ts index 380442b..26ae5c4 100644 --- a/src/commands/config/prefix.ts +++ b/src/commands/config/prefix.ts @@ -41,14 +41,14 @@ export default class PrefixCommand extends BushCommand { await message.guild.setSetting('prefix', args.prefix ?? this.client.config.prefix); if (args.prefix) { return await message.util.send({ - content: `${this.client.util.emojis.success} changed the server's prefix ${ - oldPrefix ? `from \`${oldPrefix}\`` : '' - } to \`${args.prefix}\`.`, + content: `${util.emojis.success} changed the server's prefix ${oldPrefix ? `from \`${oldPrefix}\`` : ''} to \`${ + args.prefix + }\`.`, allowedMentions: AllowedMentions.none() }); } else { return await message.util.send({ - content: `${this.client.util.emojis.success} reset the server's prefix to \`${this.client.config.prefix}\`.`, + content: `${util.emojis.success} reset the server's prefix to \`${this.client.config.prefix}\`.`, allowedMentions: AllowedMentions.none() }); } diff --git a/src/commands/config/punishmentFooter.ts b/src/commands/config/punishmentFooter.ts index 6b2759a..eeac6c1 100644 --- a/src/commands/config/punishmentFooter.ts +++ b/src/commands/config/punishmentFooter.ts @@ -42,11 +42,11 @@ export default class PunishmentFooterCommand extends BushCommand { await message.guild.setSetting('punishmentEnding', args.ending || null); if (args.ending) return await message.util.send({ - content: `${ - this.client.util.emojis.success - } Changed the server's punishment footer to \n\`\`\`${Util.cleanCodeBlockContent(args.ending)}\`\`\`.`, + content: `${util.emojis.success} Changed the server's punishment footer to \n\`\`\`${Util.cleanCodeBlockContent( + args.ending + )}\`\`\`.`, allowedMentions: AllowedMentions.none() }); - else return await message.util.send(`${this.client.util.emojis.success} Removed he server's punishment footer.`); + else return await message.util.send(`${util.emojis.success} Removed he server's punishment footer.`); } } diff --git a/src/commands/config/welcomeChannel.ts b/src/commands/config/welcomeChannel.ts index 488a0a9..3db9e74 100644 --- a/src/commands/config/welcomeChannel.ts +++ b/src/commands/config/welcomeChannel.ts @@ -41,12 +41,12 @@ export default class WelcomeChannelCommand extends BushCommand { await message.guild.setSetting('welcomeChannel', args.channel.id ?? undefined); if (args.channel) { return await message.util.send( - `${this.client.util.emojis.success} changed the server's welcome channel ${ - oldChannel ? `from <#${oldChannel}>` : '' - } to <#${args.channel.id}>.` + `${util.emojis.success} changed the server's welcome channel ${oldChannel ? `from <#${oldChannel}>` : ''} to <#${ + args.channel.id + }>.` ); } else { - return await message.util.send(`${this.client.util.emojis.success} removed the server's welcome channel.`); + return await message.util.send(`${util.emojis.success} removed the server's welcome channel.`); } } } diff --git a/src/commands/dev/__template.ts b/src/commands/dev/__template.ts index ffc67ae..1e65457 100644 --- a/src/commands/dev/__template.ts +++ b/src/commands/dev/__template.ts @@ -56,6 +56,6 @@ export default class TemplateCommand extends BushCommand { }); } public async exec(message: BushMessage | BushSlashMessage): Promise<unknown> { - return await message.util.reply(`${this.client.util.emojis.error} Do not use the template command.`); + return await message.util.reply(`${util.emojis.error} Do not use the template command.`); } } diff --git a/src/commands/dev/_testDuration.ts b/src/commands/dev/_testDuration.ts index 3ad9aff..0591518 100644 --- a/src/commands/dev/_testDuration.ts +++ b/src/commands/dev/_testDuration.ts @@ -44,7 +44,7 @@ // ): Promise<unknown> { // const rawDuration = reason.duration; // const text = reason.contentWithoutTime; -// const humanizedDuration = this.client.util.humanizeDuration(rawDuration); +// const humanizedDuration = util.humanizeDuration(rawDuration); // return await message.util.reply(stripIndents` // **rawDuration:** ${rawDuration} // **text:** ${text} diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts index ecac5f0..3966499 100644 --- a/src/commands/dev/eval.ts +++ b/src/commands/dev/eval.ts @@ -57,7 +57,7 @@ export default class EvalCommand extends BushCommand { } ): Promise<unknown> { if (!message.author.isOwner()) - return await message.util.reply(`${this.client.util.emojis.error} Only my developers can run this command.`); + return await message.util.reply(`${util.emojis.error} Only my developers can run this command.`); if (message.util.isSlash) { await (message as BushSlashMessage).interaction.defer({ ephemeral: args.silent }); } @@ -73,7 +73,7 @@ export default class EvalCommand extends BushCommand { const badPhrases = ['delete', 'destroy']; if (badPhrases.some((p) => code[code.lang].includes(p)) && !args.sudo) { - return await message.util.send(`${this.client.util.emojis.error} This eval was blocked by smooth brain protectionβ’.`); + return await message.util.send(`${util.emojis.error} This eval was blocked by smooth brain protectionβ’.`); } /* eslint-disable @typescript-eslint/no-unused-vars */ @@ -87,9 +87,9 @@ export default class EvalCommand extends BushCommand { members = message.guild?.members, roles = message.guild?.roles, client = this.client, - emojis = this.client.util.emojis, - colors = this.client.util.colors, - util = this.client.util, + emojis = util.emojis, + colors = util.colors, + util = util, { ActivePunishment, Global, Guild, Level, ModLog, StickyRole } = await import('@lib'), { ButtonInteraction, diff --git a/src/commands/dev/reload.ts b/src/commands/dev/reload.ts index 9501314..c930118 100644 --- a/src/commands/dev/reload.ts +++ b/src/commands/dev/reload.ts @@ -33,21 +33,19 @@ export default class ReloadCommand extends BushCommand { public async exec(message: BushMessage | BushSlashMessage, { fast }: { fast: boolean }): Promise<unknown> { if (!message.author.isOwner()) - return await message.util.reply(`${this.client.util.emojis.error} Only my developers can run this command.`); + return await message.util.reply(`${util.emojis.error} Only my developers can run this command.`); let output: { stdout: string; stderr: string }; try { const s = new Date(); - output = await this.client.util.shell(`yarn build-${fast ? 'esbuild' : 'tsc'}`); + output = await util.shell(`yarn build-${fast ? 'esbuild' : 'tsc'}`); this.client.commandHandler.reloadAll(); this.client.listenerHandler.reloadAll(); this.client.inhibitorHandler.reloadAll(); return message.util.send(`π Successfully reloaded! (${new Date().getTime() - s.getTime()}ms)`); } catch (e) { if (output) await this.client.logger.error('reloadCommand', output); - return message.util.send( - `An error occurred while reloading:\n${await this.client.util.codeblock(e?.stack || e, 2048 - 34, 'js')}` - ); + return message.util.send(`An error occurred while reloading:\n${await util.codeblock(e?.stack || e, 2048 - 34, 'js')}`); } } } diff --git a/src/commands/dev/say.ts b/src/commands/dev/say.ts index 9f16e9c..62ec96a 100644 --- a/src/commands/dev/say.ts +++ b/src/commands/dev/say.ts @@ -28,7 +28,7 @@ export default class SayCommand extends BushCommand { public async exec(message: BushMessage, { say }: { say: string }): Promise<unknown> { if (!message.author.isOwner()) - return await message.util.reply(`${this.client.util.emojis.error} Only my developers can run this command.`); + return await message.util.reply(`${util.emojis.error} Only my developers can run this command.`); if (message.deletable) { await message.delete(); @@ -39,7 +39,7 @@ export default class SayCommand extends BushCommand { public async execSlash(message: AkairoMessage, { content }: { content: string }): Promise<unknown> { if (!this.client.config.owners.includes(message.author.id)) { return await message.interaction.reply({ - content: `${this.client.util.emojis.error} Only my developers can run this command.`, + content: `${util.emojis.error} Only my developers can run this command.`, ephemeral: true }); } diff --git a/src/commands/dev/servers.ts b/src/commands/dev/servers.ts index 3986451..c1bfdb7 100644 --- a/src/commands/dev/servers.ts +++ b/src/commands/dev/servers.ts @@ -38,11 +38,11 @@ export default class ServersCommand extends BushCommand { false ) .setTitle(`Server List [${this.client.guilds.cache.size}]`) - .setColor(this.client.util.colors.default); + .setColor(util.colors.default); }); embeds.push(embed); }); - return await this.client.util.buttonPaginate(message, embeds); + return await util.buttonPaginate(message, embeds); } } diff --git a/src/commands/dev/setLevel.ts b/src/commands/dev/setLevel.ts index 4ec4c08..4d08345 100644 --- a/src/commands/dev/setLevel.ts +++ b/src/commands/dev/setLevel.ts @@ -50,7 +50,7 @@ export default class SetLevelCommand extends BushCommand { async exec(message: BushMessage | BushSlashMessage, { user, level }: { user: User; level: number }): Promise<unknown> { if (!message.author.isOwner()) - return await message.util.reply(`${this.client.util.emojis.error} Only my developers can run this command.`); + return await message.util.reply(`${util.emojis.error} Only my developers can run this command.`); const [levelEntry] = await Level.findOrBuild({ where: { diff --git a/src/commands/dev/sh.ts b/src/commands/dev/sh.ts index d53e500..acbbfdc 100644 --- a/src/commands/dev/sh.ts +++ b/src/commands/dev/sh.ts @@ -39,16 +39,16 @@ export default class ShCommand extends BushCommand { public async exec(message: BushMessage | BushSlashMessage, { command }: { command: string }): Promise<unknown> { if (!this.client.config.owners.includes(message.author.id)) - return await message.util.reply(`${this.client.util.emojis.error} Only my developers can run this command.`); + return await message.util.reply(`${util.emojis.error} Only my developers can run this command.`); const input = clean(command); const embed = new MessageEmbed() - .setColor(this.client.util.colors.gray) + .setColor(util.colors.gray) .setFooter(message.author.tag, message.author.avatarURL({ dynamic: true })) .setTimestamp() .setTitle('Shell Command') - .addField('π₯ Input', await this.client.util.codeblock(input, 1024, 'sh')) - .addField('Running', this.client.util.emojis.loading); + .addField('π₯ Input', await util.codeblock(input, 1024, 'sh')) + .addField('Running', util.emojis.loading); await message.util.reply({ embeds: [embed] }); @@ -65,19 +65,19 @@ export default class ShCommand extends BushCommand { const stderr = strip(clean(output.stderr)); embed - .setTitle(`${this.client.util.emojis.successFull} Executed command successfully.`) - .setColor(this.client.util.colors.success) + .setTitle(`${util.emojis.successFull} Executed command successfully.`) + .setColor(util.colors.success) .spliceFields(1, 1); - if (stdout) embed.addField('π€ stdout', await this.client.util.codeblock(stdout, 1024, 'json')); - if (stderr) embed.addField('π€ stderr', await this.client.util.codeblock(stderr, 1024, 'json')); + if (stdout) embed.addField('π€ stdout', await util.codeblock(stdout, 1024, 'json')); + if (stderr) embed.addField('π€ stderr', await util.codeblock(stderr, 1024, 'json')); } catch (e) { embed - .setTitle(`${this.client.util.emojis.errorFull} An error occurred while executing.`) - .setColor(this.client.util.colors.error) + .setTitle(`${util.emojis.errorFull} An error occurred while executing.`) + .setColor(util.colors.error) .spliceFields(1, 1); - embed.addField('π€ Output', await this.client.util.codeblock(e?.stack, 1024, 'js')); + embed.addField('π€ Output', await util.codeblock(e?.stack, 1024, 'js')); } await message.util.edit({ embeds: [embed] }); } diff --git a/src/commands/dev/superUser.ts b/src/commands/dev/superUser.ts index e06d064..cc1519f 100644 --- a/src/commands/dev/superUser.ts +++ b/src/commands/dev/superUser.ts @@ -41,30 +41,28 @@ export default class SuperUserCommand extends BushCommand { } public async exec(message: BushMessage | BushSlashMessage, args: { action: 'add' | 'remove'; user: User }): Promise<unknown> { if (!message.author.isOwner()) - return await message.util.reply(`${this.client.util.emojis.error} Only my developers can run this command.`); + return await message.util.reply(`${util.emojis.error} Only my developers can run this command.`); const superUsers = (await Global.findByPk(this.client.config.environment)).superUsers; let success; if (args.action === 'add') { if (superUsers.includes(args.user.id)) { - return message.util.reply(`${this.client.util.emojis.warn} \`${args.user.tag}\` is already a superuser.`); + return message.util.reply(`${util.emojis.warn} \`${args.user.tag}\` is already a superuser.`); } - success = await this.client.util.insertOrRemoveFromGlobal('add', 'superUsers', args.user.id).catch(() => false); + success = await util.insertOrRemoveFromGlobal('add', 'superUsers', args.user.id).catch(() => false); } else { if (!superUsers.includes(args.user.id)) { - return message.util.reply(`${this.client.util.emojis.warn} \`${args.user.tag}\` is not superuser.`); + return message.util.reply(`${util.emojis.warn} \`${args.user.tag}\` is not superuser.`); } - success = await this.client.util.insertOrRemoveFromGlobal('remove', 'superUsers', args.user.id).catch(() => false); + success = await util.insertOrRemoveFromGlobal('remove', 'superUsers', args.user.id).catch(() => false); } if (success) { const responses = [args.action == 'remove' ? '' : 'made', args.action == 'remove' ? 'is no longer' : '']; - return message.util.reply( - `${this.client.util.emojis.success} ${responses[0]} \`${args.user.tag}\` ${responses[1]} a superuser.` - ); + return message.util.reply(`${util.emojis.success} ${responses[0]} \`${args.user.tag}\` ${responses[1]} a superuser.`); } else { const response = [args.action == 'remove' ? `removing` : 'making', args.action == 'remove' ? `from` : 'to']; return message.util.reply( - `${this.client.util.emojis.error} There was an error ${response[0]} \`${args.user.tag}\` ${response[1]} the superuser list.` + `${util.emojis.error} There was an error ${response[0]} \`${args.user.tag}\` ${response[1]} the superuser list.` ); } } diff --git a/src/commands/dev/test.ts b/src/commands/dev/test.ts index 858e34b..f7edda2 100644 --- a/src/commands/dev/test.ts +++ b/src/commands/dev/test.ts @@ -90,7 +90,7 @@ export default class TestCommand extends BushCommand { for (let i = 1; i <= 5; i++) { embeds.push(new MessageEmbed().setDescription(i.toString())); } - return await this.client.util.buttonPaginate(message, embeds); + return await util.buttonPaginate(message, embeds); } else if (['lots of embeds'].includes(args?.feature?.toLowerCase())) { const description = 'This is a description.'; const author = { name: 'This is a author', iconURL: message.author.avatarURL({ dynamic: true }) }; @@ -99,7 +99,7 @@ export default class TestCommand extends BushCommand { for (let i = 0; i < 25; i++) { fields.push({ name: 'Field ' + i, value: 'Field Value ' + i }); } - const c = this.client.util.colors; + const c = util.colors; const o = { description, author, footer, fields }; const embeds = [ @@ -142,7 +142,7 @@ export default class TestCommand extends BushCommand { globalCommands.forEach(async (command) => await command.delete()); return await message.util.reply( - `${this.client.util.emojis.success} Removed **${/* guildCommandCount */ guildCommands.size}** guild commands and **${ + `${util.emojis.success} Removed **${/* guildCommandCount */ guildCommands.size}** guild commands and **${ globalCommands.size }** global commands.` ); diff --git a/src/commands/info/avatar.ts b/src/commands/info/avatar.ts index 3d1776f..dc10f7d 100644 --- a/src/commands/info/avatar.ts +++ b/src/commands/info/avatar.ts @@ -42,7 +42,7 @@ export default class AvatarCommand extends BushCommand { const embed = new MessageEmbed() .setTimestamp() - .setColor(this.client.util.colors.default) + .setColor(util.colors.default) .setTitle(user.tag) .setImage(user.avatarURL({ size: 2048, format: 'png', dynamic: true })); diff --git a/src/commands/info/botInfo.ts b/src/commands/info/botInfo.ts index 9d8ab4c..29ed29a 100644 --- a/src/commands/info/botInfo.ts +++ b/src/commands/info/botInfo.ts @@ -18,13 +18,13 @@ export default class BotInfoCommand extends BushCommand { } public async exec(message: BushMessage | BushSlashMessage): Promise<void> { - const developers = (await this.client.util.mapIDs(this.client.config.owners)).map((u) => u?.tag).join('\n'); - const currentCommit = (await this.client.util.shell('git rev-parse HEAD')).stdout.replace('\n', ''); - let repoUrl = (await this.client.util.shell('git remote get-url origin')).stdout.replace('\n', ''); + const developers = (await util.mapIDs(this.client.config.owners)).map((u) => u?.tag).join('\n'); + const currentCommit = (await util.shell('git rev-parse HEAD')).stdout.replace('\n', ''); + let repoUrl = (await util.shell('git remote get-url origin')).stdout.replace('\n', ''); repoUrl = repoUrl.substring(0, repoUrl.length - 4); const embed = new MessageEmbed() .setTitle('Bot Info:') - .addField('**Uptime**', this.client.util.humanizeDuration(this.client.uptime), true) + .addField('**Uptime**', util.humanizeDuration(this.client.uptime), true) .addField('**Servers**', this.client.guilds.cache.size.toLocaleString(), true) .addField('**Users**', this.client.users.cache.size.toLocaleString(), true) .addField('**Discord.js Version**', discordJSVersion, true) @@ -36,7 +36,7 @@ export default class BotInfoCommand extends BushCommand { .addField('**Current Commit**', `[${currentCommit.substring(0, 7)}](${repoUrl}/commit/${currentCommit})`, true) .addField('**Developers**', developers, true) .setTimestamp() - .setColor(this.client.util.colors.default); + .setColor(util.colors.default); await message.util.reply({ embeds: [embed] }); } } diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts index a3e7405..2e541f3 100644 --- a/src/commands/info/guildInfo.ts +++ b/src/commands/info/guildInfo.ts @@ -42,7 +42,7 @@ export default class GuildInfoCommand extends BushCommand { public async exec(message: BushMessage | BushSlashMessage, args: { guild: Guild | bigint | GuildPreview }): Promise<unknown> { if (!args?.guild && !message.guild) { return await message.util.reply( - `${this.client.util.emojis.error} You must either provide an server to provide info about or run this command in a server.` + `${util.emojis.error} You must either provide an server to provide info about or run this command in a server.` ); } let isPreview = false; @@ -52,7 +52,7 @@ export default class GuildInfoCommand extends BushCommand { args.guild = preview; isPreview = true; } else { - return await message.util.reply(`${this.client.util.emojis.error} That guild is not discoverable or does not exist.`); + return await message.util.reply(`${util.emojis.error} That guild is not discoverable or does not exist.`); } } const guild: Guild | GuildPreview = (args?.guild as Guild | GuildPreview) || (message.guild as Guild); @@ -154,7 +154,7 @@ export default class GuildInfoCommand extends BushCommand { const guildInfoEmbed = new MessageEmbed() .setTitle(guild.name) - .setColor(this.client.util.colors.default) + .setColor(util.colors.default) .addField('Β» About', guildAbout.join('\n')); const guildIcon = guild.iconURL({ size: 2048, format: 'png', dynamic: true }); if (guildIcon) { diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts index 3c75645..a644755 100644 --- a/src/commands/info/help.ts +++ b/src/commands/info/help.ts @@ -61,11 +61,11 @@ export default class HelpCommand extends BushCommand { } if (!this.client.guilds.cache.get(this.client.config.supportGuild.id).members.cache.has(message.author.id)) { row.addComponents( - new MessageButton({ - style: 'LINK', - label: 'Support Server', - url: this.client.config.supportGuild.invite - }) + new MessageButton({ + style: 'LINK', + label: 'Support Server', + url: this.client.config.supportGuild.invite + }) ); } row.addComponents( @@ -74,8 +74,8 @@ export default class HelpCommand extends BushCommand { label: 'GitHub', url: packageDotJSON.repository }) - ) - + ); + const isOwner = this.client.isOwner(message.author); const isSuperUser = this.client.isSuperUser(message.author); const command = args.command @@ -85,7 +85,7 @@ export default class HelpCommand extends BushCommand { : null; if (!isOwner) args.showHidden = false; if (!command || command.completelyHide) { - const embed = new MessageEmbed().setColor(this.client.util.colors.default).setTimestamp(); + const embed = new MessageEmbed().setColor(util.colors.default).setTimestamp(); if (message.guild) { embed.setFooter(`For more information about a command use ${prefix}help <command>`); } @@ -114,11 +114,11 @@ export default class HelpCommand extends BushCommand { } const embed = new MessageEmbed() - .setColor(this.client.util.colors.default) - .setTitle(`\`${command.description?.usage || `${this.client.util.emojis.error} This command does not have usages.`}\``) + .setColor(util.colors.default) + .setTitle(`\`${command.description?.usage || `${util.emojis.error} This command does not have usages.`}\``) .addField( 'Description', - `${command.description?.content || `${this.client.util.emojis.error} This command does not have a description.`} ${ + `${command.description?.content || `${util.emojis.error} This command does not have a description.`} ${ command.ownerOnly ? '\n__Developer Only__' : '' } ${command.superUserOnly ? '\n__Super User Only__' : ''}` ); diff --git a/src/commands/info/icon.ts b/src/commands/info/icon.ts index bd1cdf4..598cd14 100644 --- a/src/commands/info/icon.ts +++ b/src/commands/info/icon.ts @@ -20,7 +20,7 @@ export default class IconCommand extends BushCommand { async exec(message: BushMessage | BushSlashMessage): Promise<void> { const embed = new MessageEmbed() .setTimestamp() - .setColor(this.client.util.colors.default) + .setColor(util.colors.default) .setImage( message.guild?.iconURL({ size: 2048, diff --git a/src/commands/info/invite.ts b/src/commands/info/invite.ts index 79251dc..1f65cdc 100644 --- a/src/commands/info/invite.ts +++ b/src/commands/info/invite.ts @@ -20,7 +20,7 @@ export default class InviteCommand extends BushCommand { public async exec(message: BushMessage | BushSlashMessage): Promise<unknown> { if (this.client.config.isDevelopment) - return await message.util.reply(`${this.client.util.emojis.error} The dev bot cannot be invited.`); + return await message.util.reply(`${util.emojis.error} The dev bot cannot be invited.`); const ButtonRow = new MessageActionRow().addComponents( new MessageButton({ style: 'LINK', diff --git a/src/commands/info/ping.ts b/src/commands/info/ping.ts index d1f406d..36f3bc7 100644 --- a/src/commands/info/ping.ts +++ b/src/commands/info/ping.ts @@ -27,7 +27,7 @@ export default class PingCommand extends BushCommand { .addField('Bot Latency', botLatency, true) .addField('API Latency', apiLatency, true) .setFooter(message.author.username, message.author.displayAvatarURL({ dynamic: true })) - .setColor(this.client.util.colors.default) + .setColor(util.colors.default) .setTimestamp(); await sentMessage.edit({ content: null, @@ -46,7 +46,7 @@ export default class PingCommand extends BushCommand { .addField('Bot Latency', botLatency, true) .addField('API Latency', apiLatency, true) .setFooter(message.interaction.user.username, message.interaction.user.displayAvatarURL({ dynamic: true })) - .setColor(this.client.util.colors.default) + .setColor(util.colors.default) .setTimestamp(); await message.interaction.editReply({ content: null, diff --git a/src/commands/info/snowflakeInfo.ts b/src/commands/info/snowflakeInfo.ts index e234cc2..b32245c 100644 --- a/src/commands/info/snowflakeInfo.ts +++ b/src/commands/info/snowflakeInfo.ts @@ -54,7 +54,7 @@ export default class SnowflakeInfoCommand extends BushCommand { } public async exec(message: BushMessage | BushSlashMessage, args: { snowflake: bigint }): Promise<unknown> { const snowflake = `${args.snowflake}` as Snowflake; - const snowflakeEmbed = new MessageEmbed().setTitle('Unknown :snowflake:').setColor(this.client.util.colors.default); + const snowflakeEmbed = new MessageEmbed().setTitle('Unknown :snowflake:').setColor(util.colors.default); // Channel if (this.client.channels.cache.has(snowflake)) { diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts index 7172c75..5cfc6f0 100644 --- a/src/commands/info/userInfo.ts +++ b/src/commands/info/userInfo.ts @@ -109,9 +109,7 @@ export default class UserInfoCommand extends BushCommand { serverUserInfo.push(`**General Deletions:** 1`); if (user.nickname) serverUserInfo.push(`**Nickname** ${user.nickname}`); if (serverUserInfo.length) - userEmbed - .addField('Β» Server Info', serverUserInfo.join('\n')) - .setColor(user.displayColor || this.client.util.colors.default); + userEmbed.addField('Β» Server Info', serverUserInfo.join('\n')).setColor(user.displayColor || util.colors.default); // User Presence Info if (user.presence?.status || user.presence?.clientStatus || user.presence?.activities) { @@ -130,12 +128,9 @@ export default class UserInfoCommand extends BushCommand { if (user.presence.clientStatus) devices = Object.keys(user.presence.clientStatus); const presenceInfo = []; if (user.presence.status) presenceInfo.push(`**Status:** ${user.presence.status}`); - if (devices) - presenceInfo.push(`**${devices.length - 1 ? 'Devices' : 'Device'}:** ${this.client.util.oxford(devices, 'and', '')}`); + if (devices) presenceInfo.push(`**${devices.length - 1 ? 'Devices' : 'Device'}:** ${util.oxford(devices, 'and', '')}`); if (activitiesNames.length) - presenceInfo.push( - `**Activit${activitiesNames.length - 1 ? 'ies' : 'y'}:** ${this.client.util.oxford(activitiesNames, 'and', '')}` - ); + presenceInfo.push(`**Activit${activitiesNames.length - 1 ? 'ies' : 'y'}:** ${util.oxford(activitiesNames, 'and', '')}`); if (customStatus) presenceInfo.push(`**Custom Status:** ${customStatus}`); userEmbed.addField('Β» Presence', presenceInfo.join('\n')); } diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index 874d5ed..27a0ffc 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -5,7 +5,7 @@ import { User } from 'discord.js'; export default class BanCommand extends BushCommand { public constructor() { super('ban', { - aliases: ['ban'], + aliases: ['ban', 'forceban'], category: 'moderation', description: { content: 'Ban a member from the server.', @@ -91,14 +91,14 @@ export default class BanCommand extends BushCommand { ): Promise<unknown> { const member = message.guild.members.cache.get(user.id) as BushGuildMember; const useForce = force && message.author.isOwner(); - const canModerateResponse = this.client.util.moderationPermissionCheck(message.member, member, 'ban', true, useForce); + const canModerateResponse = util.moderationPermissionCheck(message.member, member, 'ban', true, useForce); if (canModerateResponse !== true) { return message.util.reply(canModerateResponse); } if (!Number.isInteger(days) || days < 0 || days > 7) { - return message.util.reply(`${this.client.util.emojis.error} The delete days must be an integer between 0 and 7.`); + return message.util.reply(`${util.emojis.error} The delete days must be an integer between 0 and 7.`); } let time: number; @@ -120,17 +120,17 @@ export default class BanCommand extends BushCommand { const responseMessage = () => { switch (responseCode) { case 'missing permissions': - return `${this.client.util.emojis.error} Could not ban **${member.user.tag}** because I do not have permissions`; + return `${util.emojis.error} Could not ban **${member.user.tag}** because I do not have permissions`; case 'error banning': - return `${this.client.util.emojis.error} An error occurred while trying to ban **${member.user.tag}**.`; + return `${util.emojis.error} An error occurred while trying to ban **${member.user.tag}**.`; case 'error creating ban entry': - return `${this.client.util.emojis.error} While banning **${member.user.tag}**, there was an error creating a ban entry, please report this to my developers.`; + return `${util.emojis.error} While banning **${member.user.tag}**, there was an error creating a ban entry, please report this to my developers.`; case 'error creating modlog entry': - return `${this.client.util.emojis.error} While banning **${member.user.tag}**, there was an error creating a modlog entry, please report this to my developers.`; + return `${util.emojis.error} While banning **${member.user.tag}**, there was an error creating a modlog entry, please report this to my developers.`; case 'failed to dm': - return `${this.client.util.emojis.warn} Banned **${member.user.tag}** however I could not send them a dm.`; + return `${util.emojis.warn} Banned **${member.user.tag}** however I could not send them a dm.`; case 'success': - return `${this.client.util.emojis.success} Successfully banned **${member.user.tag}**.`; + return `${util.emojis.success} Successfully banned **${member.user.tag}**.`; } }; return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() }); diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts index 74ace94..bc7d9d2 100644 --- a/src/commands/moderation/kick.ts +++ b/src/commands/moderation/kick.ts @@ -60,8 +60,11 @@ export default class KickCommand extends BushCommand { { user, reason, force }: { user: BushUser; reason?: string; force: boolean } ): Promise<unknown> { const member = message.guild.members.cache.get(user.id) as BushGuildMember; + + if (!member) message.util.reply(`${util.emojis.error} You cannot kick members that are not in the server.`); + const useForce = force && message.author.isOwner(); - const canModerateResponse = this.client.util.moderationPermissionCheck(message.member, member, 'kick', true, useForce); + const canModerateResponse = util.moderationPermissionCheck(message.member, member, 'kick', true, useForce); if (canModerateResponse !== true) { return message.util.reply(canModerateResponse); @@ -75,15 +78,15 @@ export default class KickCommand extends BushCommand { const responseMessage = () => { switch (responseCode) { case 'missing permissions': - return `${this.client.util.emojis.error} Could not kick **${member.user.tag}** because I am missing the \`Kick Members\` permission.`; + return `${util.emojis.error} Could not kick **${member.user.tag}** because I am missing the \`Kick Members\` permission.`; case 'error kicking': - return `${this.client.util.emojis.error} An error occurred while trying to kick **${member.user.tag}**.`; + return `${util.emojis.error} An error occurred while trying to kick **${member.user.tag}**.`; case 'error creating modlog entry': - return `${this.client.util.emojis.error} While muting **${member.user.tag}**, there was an error creating a modlog entry, please report this to my developers.`; + return `${util.emojis.error} While muting **${member.user.tag}**, there was an error creating a modlog entry, please report this to my developers.`; case 'failed to dm': - return `${this.client.util.emojis.warn} Kicked **${member.user.tag}** however I could not send them a dm.`; + return `${util.emojis.warn} Kicked **${member.user.tag}** however I could not send them a dm.`; case 'success': - return `${this.client.util.emojis.success} Successfully kicked **${member.user.tag}**.`; + return `${util.emojis.success} Successfully kicked **${member.user.tag}**.`; } }; return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() }); diff --git a/src/commands/moderation/lockdown.ts b/src/commands/moderation/lockdown.ts index e67d110..4eaeceb 100644 --- a/src/commands/moderation/lockdown.ts +++ b/src/commands/moderation/lockdown.ts @@ -35,8 +35,8 @@ export default class LockdownCommand extends BushCommand { return await message.util.reply('no'); if (!all) { if (!['GUILD_TEXT', 'GUILD_NEWS'].includes(message.channel.type)) - return message.util.reply(`${this.client.util.emojis.error} You can only lock down text and announcement channels.`); - const lockdownSuccess = await this.client.util.lockdownChannel({ + return message.util.reply(`${util.emojis.error} You can only lock down text and announcement channels.`); + const lockdownSuccess = await util.lockdownChannel({ channel: message.channel as BushTextChannel | BushNewsChannel, moderator: message.author }); diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts index e3da45f..c55b9a3 100644 --- a/src/commands/moderation/modlog.ts +++ b/src/commands/moderation/modlog.ts @@ -42,13 +42,13 @@ export default class ModlogCommand extends BushCommand { `**User**: <@!${log.user}> (${log.user})`, `**Moderator**: <@!${log.moderator}> (${log.moderator})` ]; - if (log.duration) modLog.push(`**Duration**: ${this.client.util.humanizeDuration(log.duration)}`); + if (log.duration) modLog.push(`**Duration**: ${util.humanizeDuration(log.duration)}`); modLog.push(`**Reason**: ${log.reason || 'No Reason Specified.'}`); return modLog.join(`\n`); } async exec(message: BushMessage | BushSlashMessage, { search }: { search: BushUser | string }): Promise<unknown> { - const foundUser = search instanceof User ? search : await this.client.util.resolveUserAsync(search); + const foundUser = search instanceof User ? search : await util.resolveUserAsync(search); if (foundUser) { const logs = await ModLog.findAll({ where: { @@ -57,31 +57,30 @@ export default class ModlogCommand extends BushCommand { }, order: [['createdAt', 'ASC']] }); - if (!logs.length) - return message.util.reply(`${this.client.util.emojis.error} **${foundUser.tag}** does not have any modlogs.`); + if (!logs.length) return message.util.reply(`${util.emojis.error} **${foundUser.tag}** does not have any modlogs.`); const niceLogs: string[] = []; for (const log of logs) { niceLogs.push(this.generateModlogInfo(log)); } - const chunked: string[][] = this.client.util.chunk(niceLogs, 3); + const chunked: string[][] = util.chunk(niceLogs, 3); const embedPages = chunked.map( (chunk) => new MessageEmbed({ title: `${foundUser.tag}'s Mod Logs`, description: chunk.join('\n**βββββββββββββββββββββββββββ**\n'), - color: this.client.util.colors.default + color: util.colors.default }) ); - return await this.client.util.buttonPaginate(message, embedPages, '', true); + return await util.buttonPaginate(message, embedPages, '', true); } else if (search) { const entry = await ModLog.findByPk(search as string); - if (!entry) return message.util.send(`${this.client.util.emojis.error} That modlog does not exist.`); + if (!entry) return message.util.send(`${util.emojis.error} That modlog does not exist.`); const embed = new MessageEmbed({ title: `Case ${entry.id}`, description: this.generateModlogInfo(entry), - color: this.client.util.colors.default + color: util.colors.default }); - return await this.client.util.buttonPaginate(message, [embed]); + return await util.buttonPaginate(message, [embed]); } } } diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts index 2004eb8..0b10ee1 100644 --- a/src/commands/moderation/mute.ts +++ b/src/commands/moderation/mute.ts @@ -60,10 +60,11 @@ export default class MuteCommand extends BushCommand { message: BushMessage | BushSlashMessage, { user, reason, force }: { user: BushUser; reason?: { duration: number; contentWithoutTime: string }; force: boolean } ): Promise<unknown> { - const error = this.client.util.emojis.error; const member = message.guild.members.cache.get(user.id) as BushGuildMember; + if (!member) message.util.reply(`${util.emojis.error} You cannot kick members that are not in the server.`); + const useForce = force && message.author.isOwner(); - const canModerateResponse = this.client.util.moderationPermissionCheck(message.member, member, 'mute', true, useForce); + const canModerateResponse = util.moderationPermissionCheck(message.member, member, 'mute', true, useForce); const victimBoldTag = `**${member.user.tag}**`; if (canModerateResponse !== true) { @@ -85,29 +86,29 @@ export default class MuteCommand extends BushCommand { duration: time }); - const responseMessage = () => { - const prefix = message.guild.getSetting('prefix'); + const responseMessage = async () => { + const prefix = await message.guild.getSetting('prefix'); switch (responseCode) { case 'missing permissions': - return `${error} Could not mute ${victimBoldTag} because I am missing the \`Manage Roles\` permission.`; + return `${util.emojis.error} Could not mute ${victimBoldTag} because I am missing the \`Manage Roles\` permission.`; case 'no mute role': - return `${error} Could not mute ${victimBoldTag}, you must set a mute role with \`${prefix}muterole\`.`; + return `${util.emojis.error} Could not mute ${victimBoldTag}, you must set a mute role with \`${prefix}muterole\`.`; case 'invalid mute role': - return `${error} Could not mute ${victimBoldTag} because the current mute role no longer exists. Please set a new mute role with \`${prefix}muterole\`.`; + return `${util.emojis.error} Could not mute ${victimBoldTag} because the current mute role no longer exists. Please set a new mute role with \`${prefix}muterole\`.`; case 'mute role not manageable': - return `${error} Could not mute ${victimBoldTag} because I cannot assign the current mute role, either change the role's position or set a new mute role with \`${prefix}muterole\`.`; + return `${util.emojis.error} Could not mute ${victimBoldTag} because I cannot assign the current mute role, either change the role's position or set a new mute role with \`${prefix}muterole\`.`; case 'error giving mute role': - return `${error} Could not mute ${victimBoldTag}, there was an error assigning them the mute role.`; + return `${util.emojis.error} Could not mute ${victimBoldTag}, there was an error assigning them the mute role.`; case 'error creating modlog entry': - return `${error} There was an error creating a modlog entry, please report this to my developers.`; + return `${util.emojis.error} There was an error creating a modlog entry, please report this to my developers.`; case 'error creating mute entry': - return `${error} There was an error creating a punishment entry, please report this to my developers.`; + return `${util.emojis.error} There was an error creating a punishment entry, please report this to my developers.`; case 'failed to dm': - return `${this.client.util.emojis.warn} Muted **${member.user.tag}** however I could not send them a dm.`; + return `${util.emojis.warn} Muted **${member.user.tag}** however I could not send them a dm.`; case 'success': - return `${this.client.util.emojis.success} Successfully muted **${member.user.tag}**.`; + return `${util.emojis.success} Successfully muted **${member.user.tag}**.`; } }; - return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() }); + return await message.util.reply({ content: await responseMessage(), allowedMentions: AllowedMentions.none() }); } } diff --git a/src/commands/moderation/removeReactionEmoji.ts b/src/commands/moderation/removeReactionEmoji.ts index b0079c6..cb1be04 100644 --- a/src/commands/moderation/removeReactionEmoji.ts +++ b/src/commands/moderation/removeReactionEmoji.ts @@ -49,13 +49,13 @@ export default class RemoveReactionEmojiCommand extends BushCommand { .catch(() => {}); if (success) { return await message.util.reply( - `${this.client.util.emojis.success} Removed all reactions of \`${ - id ? emojiID : emoji - }\` from the message with the id of \`${messageToRemoveFrom.id}\`.` + `${util.emojis.success} Removed all reactions of \`${id ? emojiID : emoji}\` from the message with the id of \`${ + messageToRemoveFrom.id + }\`.` ); } else { return await message.util.reply( - `${this.client.util.emojis.error} There was an error removing all reactions of \`${ + `${util.emojis.error} There was an error removing all reactions of \`${ id ? emojiID : emoji }\` from the message with the id of \`${messageToRemoveFrom.id}\`.` ); diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts index 3470ab9..63fb3a2 100644 --- a/src/commands/moderation/role.ts +++ b/src/commands/moderation/role.ts @@ -103,7 +103,7 @@ export default class RoleCommand extends BushCommand { } if (!mappedRole || !mappings.roleWhitelist[mappedRole.name]) { return await message.util.reply({ - content: `${this.client.util.emojis.error} <@&${role.id}> is not whitelisted, and you do not have manage roles permission.`, + content: `${util.emojis.error} <@&${role.id}> is not whitelisted, and you do not have manage roles permission.`, allowedMentions: AllowedMentions.none() }); } @@ -115,7 +115,7 @@ export default class RoleCommand extends BushCommand { }); if (!message.member.roles.cache.some((role) => allowedRoles.includes(role.id))) { return await message.util.reply({ - content: `${this.client.util.emojis.error} <@&${role.id}> is whitelisted, but you do not have any of the roles required to manage it.`, + content: `${util.emojis.error} <@&${role.id}> is whitelisted, but you do not have any of the roles required to manage it.`, allowedMentions: AllowedMentions.none() }); } @@ -131,25 +131,25 @@ export default class RoleCommand extends BushCommand { const responseMessage = () => { switch (responseCode) { case 'user hierarchy': - return `${this.client.util.emojis.error} <@&${role.id}> is higher or equal to your highest role.`; + return `${util.emojis.error} <@&${role.id}> is higher or equal to your highest role.`; case 'role managed': - return `${this.client.util.emojis.error} <@&${role.id}> is managed by an integration and cannot be managed.`; + return `${util.emojis.error} <@&${role.id}> is managed by an integration and cannot be managed.`; case 'client hierarchy': - return `${this.client.util.emojis.error} <@&${role.id}> is higher or equal to my highest role.`; + return `${util.emojis.error} <@&${role.id}> is higher or equal to my highest role.`; case 'error creating modlog entry': - return `${this.client.util.emojis.error} There was an error creating a modlog entry, please report this to my developers.`; + return `${util.emojis.error} There was an error creating a modlog entry, please report this to my developers.`; case 'error creating role entry' || 'error removing role entry': - return `${this.client.util.emojis.error} There was an error ${ + return `${util.emojis.error} There was an error ${ action === 'add' ? 'creating' : 'removing' } a punishment entry, please report this to my developers.`; case 'error adding role' || 'error removing role': - return `${this.client.util.emojis.error} An error occurred while trying to ${action} <@&${role.id}> ${ + return `${util.emojis.error} An error occurred while trying to ${action} <@&${role.id}> ${ action === 'add' ? 'to' : 'from' } **${user.user.tag}**.`; case 'success': - return `${this.client.util.emojis.success} Successfully ${action === 'add' ? 'added' : 'removed'} <@&${role.id}> ${ + return `${util.emojis.success} Successfully ${action === 'add' ? 'added' : 'removed'} <@&${role.id}> ${ action === 'add' ? 'to' : 'from' - } **${user.user.tag}**${duration ? ` for ${this.client.util.humanizeDuration(duration)}` : ''}.`; + } **${user.user.tag}**${duration ? ` for ${util.humanizeDuration(duration)}` : ''}.`; } }; diff --git a/src/commands/moderation/slowmode.ts b/src/commands/moderation/slowmode.ts index 8384562..019e545 100644 --- a/src/commands/moderation/slowmode.ts +++ b/src/commands/moderation/slowmode.ts @@ -54,10 +54,10 @@ export default class SlowModeCommand extends BushCommand { { length, channel }: { length: number | 'off' | 'none' | 'disable'; channel: TextChannel | ThreadChannel } ): Promise<unknown> { if (message.channel.type === 'DM') - return await message.util.reply(`${this.client.util.emojis.error} This command cannot be run in dms.`); + return await message.util.reply(`${util.emojis.error} This command cannot be run in dms.`); if (!channel) channel = message.channel as ThreadChannel | TextChannel; if (!(channel instanceof TextChannel) || !(channel instanceof ThreadChannel)) - return await message.util.reply(`${this.client.util.emojis.error} <#${channel.id}> is not a text or thread channel.`); + return await message.util.reply(`${util.emojis.error} <#${channel.id}> is not a text or thread channel.`); if (length) { length = typeof length === 'string' && !['off', 'none', 'disable'].includes(length) @@ -73,14 +73,12 @@ export default class SlowModeCommand extends BushCommand { .catch(() => {}); if (!setSlowmode) return await message.util.reply( - `${this.client.util.emojis.error} There was an error changing the slowmode of <#${ - (channel as ThreadChannel | TextChannel).id - }>.` + `${util.emojis.error} There was an error changing the slowmode of <#${(channel as ThreadChannel | TextChannel).id}>.` ); else return await message.util.reply( - `${this.client.util.emojis.success} Successfully changed the slowmode of ${channel} ${ - length2 ? `to \`${this.client.util.humanizeDuration(length2)}` : '`off' + `${util.emojis.success} Successfully changed the slowmode of ${channel} ${ + length2 ? `to \`${util.humanizeDuration(length2)}` : '`off' }\`.` ); } diff --git a/src/commands/moderation/unban.ts b/src/commands/moderation/unban.ts index 0de2489..26878d9 100644 --- a/src/commands/moderation/unban.ts +++ b/src/commands/moderation/unban.ts @@ -53,7 +53,7 @@ export default class UnbanCommand extends BushCommand { } async exec(message: BushMessage | BushSlashMessage, { user, reason }: { user: User; reason?: string }): Promise<unknown> { if (!(user instanceof User)) { - user = this.client.util.resolveUser(user, this.client.users.cache); + user = util.resolveUser(user, this.client.users.cache); } const responseCode = await message.guild.unban({ user, @@ -64,17 +64,17 @@ export default class UnbanCommand extends BushCommand { const responseMessage = () => { switch (responseCode) { case 'missing permissions': - return `${this.client.util.emojis.error} Could not unban **${user.tag}** because I do not have permissions`; + return `${util.emojis.error} Could not unban **${user.tag}** because I do not have permissions`; case 'error unbanning': - return `${this.client.util.emojis.error} An error occurred while trying to unban **${user.tag}**.`; + return `${util.emojis.error} An error occurred while trying to unban **${user.tag}**.`; case 'error removing ban entry': - return `${this.client.util.emojis.error} While unbanning **${user.tag}**, there was an error removing their ban entry, please report this to my developers.`; + return `${util.emojis.error} While unbanning **${user.tag}**, there was an error removing their ban entry, please report this to my developers.`; case 'error creating modlog entry': - return `${this.client.util.emojis.error} While unbanning **${user.tag}**, there was an error creating a modlog entry, please report this to my developers.`; + return `${util.emojis.error} While unbanning **${user.tag}**, there was an error creating a modlog entry, please report this to my developers.`; case 'user not banned': - return `${this.client.util.emojis.warn} **${user.tag}** but I tried to unban them anyways.`; + return `${util.emojis.warn} **${user.tag}** but I tried to unban them anyways.`; case 'success': - return `${this.client.util.emojis.success} Successfully unbanned **${user.tag}**.`; + return `${util.emojis.success} Successfully unbanned **${user.tag}**.`; } }; return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() }); diff --git a/src/commands/moderation/unmute.ts b/src/commands/moderation/unmute.ts index 277ca91..807cf2c 100644 --- a/src/commands/moderation/unmute.ts +++ b/src/commands/moderation/unmute.ts @@ -51,9 +51,9 @@ export default class UnmuteCommand extends BushCommand { }); } async exec(message: BushMessage | BushSlashMessage, { user, reason }: { user: BushUser; reason?: string }): Promise<unknown> { - const error = this.client.util.emojis.error; + const error = util.emojis.error; const member = message.guild.members.cache.get(user.id) as BushGuildMember; - const canModerateResponse = this.client.util.moderationPermissionCheck(message.member, member, 'unmute'); + const canModerateResponse = util.moderationPermissionCheck(message.member, member, 'unmute'); const victimBoldTag = `**${member.user.tag}**`; if (canModerateResponse !== true) { @@ -83,9 +83,9 @@ export default class UnmuteCommand extends BushCommand { case 'error removing mute entry': return `${error} While muting ${victimBoldTag}, there was an error removing their mute entry, please report this to my developers.`; case 'failed to dm': - return `${this.client.util.emojis.warn} unmuted **${member.user.tag}** however I could not send them a dm.`; + return `${util.emojis.warn} unmuted **${member.user.tag}** however I could not send them a dm.`; case 'success': - return `${this.client.util.emojis.success} Successfully unmuted **${member.user.tag}**.`; + return `${util.emojis.success} Successfully unmuted **${member.user.tag}**.`; } }; return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() }); diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts index d5bf009..c5b4f43 100644 --- a/src/commands/moderation/warn.ts +++ b/src/commands/moderation/warn.ts @@ -61,7 +61,7 @@ export default class WarnCommand extends BushCommand { ): Promise<unknown> { const member = message.guild.members.cache.get(user.id) as BushGuildMember; const useForce = force && message.author.isOwner(); - const canModerateResponse = this.client.util.moderationPermissionCheck(message.member, member, 'warn', true, useForce); + const canModerateResponse = util.moderationPermissionCheck(message.member, member, 'warn', true, useForce); const victimBoldTag = `**${member.user.tag}**`; if (canModerateResponse !== true) { @@ -76,19 +76,17 @@ export default class WarnCommand extends BushCommand { switch (response) { case 'error creating modlog entry': return message.util.reply( - `${this.client.util.emojis.error} While warning ${victimBoldTag}, there was an error creating a modlog entry, please report this to my developers.` + `${util.emojis.error} While warning ${victimBoldTag}, there was an error creating a modlog entry, please report this to my developers.` ); case 'failed to dm': return message.util.reply( - `${this.client.util.emojis.warn} **${member.user.tag}** has been warned for the ${this.client.util.ordinal( + `${util.emojis.warn} **${member.user.tag}** has been warned for the ${util.ordinal( caseNum )} time, however I could not send them a dm.` ); case 'success': return message.util.reply( - `${this.client.util.emojis.success} Successfully warned **${member.user.tag}** for the ${this.client.util.ordinal( - caseNum - )} time.` + `${util.emojis.success} Successfully warned **${member.user.tag}** for the ${util.ordinal(caseNum)} time.` ); } } diff --git a/src/commands/moulberry-bush/capePerms.ts b/src/commands/moulberry-bush/capePerms.ts index 08b42ff..d613217 100644 --- a/src/commands/moulberry-bush/capePerms.ts +++ b/src/commands/moulberry-bush/capePerms.ts @@ -52,11 +52,9 @@ export default class CapePermissionsCommand extends BushCommand { let capeperms: Capeperms, uuid: string; try { - uuid = await this.client.util.findUUID(args.ign); + uuid = await util.findUUID(args.ign); } catch (e) { - return await message.util.reply( - `${this.client.util.emojis.error} \`${args.ign}\` doesn't appear to be a valid username.` - ); + return await message.util.reply(`${util.emojis.error} \`${args.ign}\` doesn't appear to be a valid username.`); } try { @@ -65,9 +63,7 @@ export default class CapePermissionsCommand extends BushCommand { capeperms = null; } if (capeperms == null) { - return await message.util.reply( - `${this.client.util.emojis.error} There was an error finding cape perms for \`${args.ign}\`.` - ); + return await message.util.reply(`${util.emojis.error} There was an error finding cape perms for \`${args.ign}\`.`); } else { if (capeperms?.perms) { let index = null; @@ -80,19 +76,15 @@ export default class CapePermissionsCommand extends BushCommand { continue; } if (index == null) - return await message.util.reply( - `${this.client.util.emojis.error} \`${args.ign}\` does not appear to have any capes.` - ); + return await message.util.reply(`${util.emojis.error} \`${args.ign}\` does not appear to have any capes.`); const userPerm: string[] = capeperms.perms[index].perms; const embed = new MessageEmbed() .setTitle(`${args.ign}'s Capes`) .setDescription(userPerm.join('\n')) - .setColor(this.client.util.colors.default); + .setColor(util.colors.default); await message.util.reply({ embeds: [embed] }); } else { - return await message.util.reply( - `${this.client.util.emojis.error} There was an error finding cape perms for ${args.ign}.` - ); + return await message.util.reply(`${util.emojis.error} There was an error finding cape perms for ${args.ign}.`); } } } diff --git a/src/commands/moulberry-bush/giveawayPing.ts b/src/commands/moulberry-bush/giveawayPing.ts index 93373b0..269c33f 100644 --- a/src/commands/moulberry-bush/giveawayPing.ts +++ b/src/commands/moulberry-bush/giveawayPing.ts @@ -25,7 +25,7 @@ export default class GiveawayPingCommand extends BushCommand { public async exec(message: BushMessage): Promise<unknown> { if (!message.member.permissions.has('MANAGE_GUILD')) - await message.util.reply(`${this.client.util.emojis.error} You are missing the \`manage server\` permission.`); + await message.util.reply(`${util.emojis.error} You are missing the \`manage server\` permission.`); await message.delete().catch(() => {}); diff --git a/src/commands/moulberry-bush/report.ts b/src/commands/moulberry-bush/report.ts index ebc8f1d..11ef269 100644 --- a/src/commands/moulberry-bush/report.ts +++ b/src/commands/moulberry-bush/report.ts @@ -59,17 +59,15 @@ export default class ReportCommand extends BushCommand { public async exec(message: BushMessage, { member, evidence }: { member: GuildMember; evidence: string }): Promise<unknown> { if (message.guild.id != this.client.consts.mappings.guilds.bush) - return await message.util.reply(`${this.client.util.emojis.error} This command can only be run in Moulberry's bush.`); - if (!member) return await message.util.reply(`${this.client.util.emojis.error} Choose someone to report`); + return await message.util.reply(`${util.emojis.error} This command can only be run in Moulberry's bush.`); + if (!member) return await message.util.reply(`${util.emojis.error} Choose someone to report`); if (member.user.id === '322862723090219008') return await message.util.reply({ content: `Thank you for your report! We take these allegations very seriously and have reported <@${member.user.id}> to the FBI!`, allowedMentions: AllowedMentions.none() }); if (member.user.bot) - return await message.util.reply( - `${this.client.util.emojis.error} You cannot report a bot <:WeirdChamp:756283321301860382>.` - ); + return await message.util.reply(`${util.emojis.error} You cannot report a bot <:WeirdChamp:756283321301860382>.`); //// if (!evidence) evidence = 'No Evidence.'; //todo: Add channel id to db instead of hard coding it & allow in any guild @@ -79,7 +77,7 @@ export default class ReportCommand extends BushCommand { .setTimestamp() .setAuthor(`Report From: ${message.author.tag}`, message.author.avatarURL({ dynamic: true })) .setTitle('New Report') - .setColor(this.client.util.colors.red) + .setColor(util.colors.red) .setDescription(evidence) .addField( 'Reporter', @@ -110,8 +108,8 @@ export default class ReportCommand extends BushCommand { const reportChannel = <TextChannel>this.client.channels.cache.get('782972723654688848'); await reportChannel.send({ embeds: [reportEmbed] }).then(async (ReportMessage) => { try { - await ReportMessage.react(this.client.util.emojis.success); - await ReportMessage.react(this.client.util.emojis.error); + await ReportMessage.react(util.emojis.success); + await ReportMessage.react(util.emojis.error); } catch { this.client.console.warn('ReportCommand', 'Could not react to report message.'); } diff --git a/src/commands/skyblock-reborn/chooseColorCommand.ts b/src/commands/skyblock-reborn/chooseColorCommand.ts index ce70419..f80d2ae 100644 --- a/src/commands/skyblock-reborn/chooseColorCommand.ts +++ b/src/commands/skyblock-reborn/chooseColorCommand.ts @@ -121,7 +121,7 @@ export default class ChooseColorCommand extends BushCommand { public async exec(message: BushMessage | BushSlashMessage, args: { color: Role | RoleResolvable }): Promise<unknown> { if (message.guild.id != this.client.consts.mappings.guilds.sbr) { - return await message.util.reply(`${this.client.util.emojis.error} This command can only be run in Skyblock: Reborn.`); + return await message.util.reply(`${util.emojis.error} This command can only be run in Skyblock: Reborn.`); } const allowedRoles: Snowflake[] = [ '839317526395879449', //Server Booster @@ -135,13 +135,13 @@ export default class ChooseColorCommand extends BushCommand { message.guild.ownerId === message.author.id ) ) { - const allowed = this.client.util.oxford( + const allowed = util.oxford( allowedRoles.map((id) => `<@&${id}>s`), 'and', '' ); return await message.util.reply({ - content: `${this.client.util.emojis.error} Only ${allowed} can use this command.`, + content: `${util.emojis.error} Only ${allowed} can use this command.`, allowedMentions: AllowedMentions.none(), ephemeral: true }); @@ -154,7 +154,7 @@ export default class ChooseColorCommand extends BushCommand { const colorID = message.util.isSlash ? (args.color as string) : (args.color as Role).id; if (!roleColorMap.map((obj) => obj.value).includes(colorID)) { return await message.util.reply({ - content: `${this.client.util.emojis.error} ${args.color} is not a whitelisted color role.`, + content: `${util.emojis.error} ${args.color} is not a whitelisted color role.`, allowedMentions: AllowedMentions.none() }); } @@ -172,7 +172,7 @@ export default class ChooseColorCommand extends BushCommand { } message.util.reply({ - content: `${this.client.util.emojis.success} Assigned you the <@&${colorID}> role.`, + content: `${util.emojis.success} Assigned you the <@&${colorID}> role.`, allowedMentions: AllowedMentions.none() }); } diff --git a/src/commands/utilities/serverStatus.ts b/src/commands/utilities/serverStatus.ts index a20f0b2..b9d6136 100644 --- a/src/commands/utilities/serverStatus.ts +++ b/src/commands/utilities/serverStatus.ts @@ -22,24 +22,24 @@ export default class ServerStatusCommand extends BushCommand { public async exec(message: BushMessage): Promise<void> { const msgEmbed: MessageEmbed = new MessageEmbed() .setTitle('Server status') - .setDescription(`Checking server:\n${this.client.util.emojis.loading}`) - .setColor(this.client.util.colors.default) + .setDescription(`Checking server:\n${util.emojis.loading}`) + .setColor(util.colors.default) .setFooter('Checking https://moulberry.codes/lowestbin.json'); await message.util.reply({ embeds: [msgEmbed] }); let main; try { await got.get('https://moulberry.codes/lowestbin.json').json(); - main = this.client.util.emojis.success; + main = util.emojis.success; } catch (e) { - main = this.client.util.emojis.error; + main = util.emojis.error; } await message.util.edit({ embeds: [msgEmbed.setDescription(`Checking server:\n${main}`)] }); - if (main == this.client.util.emojis.success) { + if (main == util.emojis.success) { await message.util.edit({ embeds: [ msgEmbed .addField('Status', 'The server is online, all features related to prices will likely work.') - .setColor(this.client.util.colors.success) + .setColor(util.colors.success) ] }); } else { @@ -50,7 +50,7 @@ export default class ServerStatusCommand extends BushCommand { 'Status', "It appears Moulberry's server is offline, this means that everything related to prices will likely not work." ) - .setColor(this.client.util.colors.error) + .setColor(util.colors.error) ] }); } diff --git a/src/commands/utilities/uuid.ts b/src/commands/utilities/uuid.ts index 0b96ce1..7ff80d2 100644 --- a/src/commands/utilities/uuid.ts +++ b/src/commands/utilities/uuid.ts @@ -31,13 +31,13 @@ export default class UuidCommand extends BushCommand { // eslint-disable-next-line @typescript-eslint/no-explicit-any public async exec(message: BushMessage, { ign }: { ign: { match: any[]; matches: any[] } }): Promise<unknown> { - if (!ign) return await message.util.reply(`${this.client.util.emojis.error} Please enter a valid ign.`); + if (!ign) return await message.util.reply(`${util.emojis.error} Please enter a valid ign.`); const readableIGN = ign.match[0]; try { - const uuid = await this.client.util.findUUID(readableIGN); + const uuid = await util.findUUID(readableIGN); return await message.util.reply(`The uuid for \`${readableIGN}\` is \`${uuid}\``); } catch (e) { - return await message.util.reply(`${this.client.util.emojis.error} Could not find an uuid for \`${readableIGN}\`.`); + return await message.util.reply(`${util.emojis.error} Could not find an uuid for \`${readableIGN}\`.`); } } } diff --git a/src/commands/utilities/viewraw.ts b/src/commands/utilities/viewraw.ts index 3658bde..ca5b2de 100644 --- a/src/commands/utilities/viewraw.ts +++ b/src/commands/utilities/viewraw.ts @@ -56,7 +56,7 @@ export default class ViewRawCommand extends BushCommand { }); if (!newMessage) { return await message.util.reply( - `${this.client.util.emojis.error} There was an error fetching that message, try supplying a channel.` + `${util.emojis.error} There was an error fetching that message, try supplying a channel.` ); } } else { @@ -66,9 +66,9 @@ export default class ViewRawCommand extends BushCommand { const messageEmbed = new MessageEmbed() .setFooter(newMessage.author.tag, newMessage.author.avatarURL({ dynamic: true })) .setTimestamp(newMessage.createdTimestamp) - .setColor(newMessage.member?.roles?.color?.color || this.client.util.colors.default) + .setColor(newMessage.member?.roles?.color?.color || util.colors.default) .setTitle('Raw Message Information') - .setDescription(await this.client.util.codeblock(content, 2048, 'js')); + .setDescription(await util.codeblock(content, 2048, 'js')); return await message.util.reply({ embeds: [messageEmbed] }); } diff --git a/src/commands/utilities/whoHasRole.ts b/src/commands/utilities/whoHasRole.ts index 1828c95..42e8fd5 100644 --- a/src/commands/utilities/whoHasRole.ts +++ b/src/commands/utilities/whoHasRole.ts @@ -39,15 +39,15 @@ export default class WhoHasRoleCommand extends BushCommand { public async exec(message: BushMessage | BushSlashMessage, args: { role: Role }): Promise<unknown> { const roleMembers = args.role.members.map((member) => `${member.user} (${Util.escapeMarkdown(member.user.tag)})`); - const chunkedRoleMembers = this.client.util.chunk(roleMembers, 30); + const chunkedRoleMembers = util.chunk(roleMembers, 30); const embedPages = chunkedRoleMembers.map( (chunk) => new MessageEmbed({ title: `${args.role.name}'s Members`, description: chunk.join('\n'), - color: this.client.util.colors.default + color: util.colors.default }) ); - return await this.client.util.buttonPaginate(message, embedPages, null, true); + return await util.buttonPaginate(message, embedPages, null, true); } } |