diff options
| author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-26 18:45:31 -0400 |
|---|---|---|
| committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-26 18:45:31 -0400 |
| commit | cca0b7a03bcd61af12b7f9bff51276f6c70beeb3 (patch) | |
| tree | 2b2adebc166ac033520e5b582773e63fbdc5ddb9 /src | |
| parent | 13ba1ad552047eb9386e91d542a975c4bef58b08 (diff) | |
| download | tanzanite-cca0b7a03bcd61af12b7f9bff51276f6c70beeb3.tar.gz tanzanite-cca0b7a03bcd61af12b7f9bff51276f6c70beeb3.tar.bz2 tanzanite-cca0b7a03bcd61af12b7f9bff51276f6c70beeb3.zip | |
refactor: this.client.util -> util
Diffstat (limited to 'src')
61 files changed, 278 insertions, 304 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', a |
