diff options
| author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-06-16 14:32:18 -0400 |
|---|---|---|
| committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-06-16 14:32:18 -0400 |
| commit | 0e87bbd3940d89defcb04926587b35c8f4d1947f (patch) | |
| tree | e50860d4dc25a11d4c3977b583284c4bcad1b077 /src/commands | |
| parent | 661e4c9935aeb8760dafc7ced4bbec6cc356a033 (diff) | |
| download | tanzanite-0e87bbd3940d89defcb04926587b35c8f4d1947f.tar.gz tanzanite-0e87bbd3940d89defcb04926587b35c8f4d1947f.tar.bz2 tanzanite-0e87bbd3940d89defcb04926587b35c8f4d1947f.zip | |
remove util classes, move config out of src
Diffstat (limited to 'src/commands')
91 files changed, 1267 insertions, 755 deletions
diff --git a/src/commands/admin/channelPermissions.ts b/src/commands/admin/channelPermissions.ts index f6240a5..12245a9 100644 --- a/src/commands/admin/channelPermissions.ts +++ b/src/commands/admin/channelPermissions.ts @@ -1,4 +1,14 @@ -import { BushCommand, ButtonPaginator, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; +import { + Arg, + BushCommand, + ButtonPaginator, + clientSendAndPermCheck, + emojis, + formatError, + type ArgType, + type CommandMessage, + type SlashMessage +} from '#lib'; import assert from 'assert'; import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits } from 'discord.js'; @@ -15,7 +25,7 @@ export default class ChannelPermissionsCommand extends BushCommand { { id: 'target', description: 'The user/role to change the permissions of.', - type: util.arg.union('member', 'role'), + type: Arg.union('member', 'role'), readableType: 'member|role', prompt: 'What user/role would you like to change?', retry: '{error} Choose a valid user/role to change.', @@ -48,7 +58,7 @@ export default class ChannelPermissionsCommand extends BushCommand { ] } ], - clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.ManageChannels]), + clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.ManageChannels]), userPermissions: [PermissionFlagsBits.Administrator], channel: 'guild', slash: true, @@ -64,9 +74,9 @@ export default class ChannelPermissionsCommand extends BushCommand { if (message.util.isSlashMessage(message)) await message.interaction.deferReply(); const permission = message.util.isSlashMessage(message) - ? await util.arg.cast('permission', message, args.permission) + ? await Arg.cast('permission', message, args.permission) : args.permission; - if (!permission) return await message.util.reply(`${util.emojis.error} Invalid permission.`); + if (!permission) return await message.util.reply(`${emojis.error} Invalid permission.`); const failedChannels = []; for (const [, channel] of message.guild.channels.cache) { try { @@ -79,7 +89,7 @@ export default class ChannelPermissionsCommand extends BushCommand { { reason: 'Changing overwrites for mass channel perms command' } ); } catch (e) { - void client.console.error('channelPermissions', util.formatError(e, false)); + void client.console.error('channelPermissions', formatError(e, false)); failedChannels.push(channel); } } diff --git a/src/commands/admin/roleAll.ts b/src/commands/admin/roleAll.ts index 80952cc..c731f08 100644 --- a/src/commands/admin/roleAll.ts +++ b/src/commands/admin/roleAll.ts @@ -1,4 +1,12 @@ -import { AllowedMentions, BushCommand, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; +import { + AllowedMentions, + BushCommand, + clientSendAndPermCheck, + emojis, + type ArgType, + type CommandMessage, + type SlashMessage +} from '#lib'; import assert from 'assert'; import { ApplicationCommandOptionType, PermissionFlagsBits, type GuildMember } from 'discord.js'; @@ -32,7 +40,7 @@ export default class RoleAllCommand extends BushCommand { } ], channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.ManageRoles]), + clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.ManageRoles]), userPermissions: [PermissionFlagsBits.Administrator], typing: true, slash: true, @@ -43,11 +51,11 @@ export default class RoleAllCommand extends BushCommand { public override async exec(message: CommandMessage | SlashMessage, args: { role: ArgType<'role'>; bots: ArgType<'flag'> }) { assert(message.inGuild()); if (!message.member!.permissions.has(PermissionFlagsBits.Administrator) && !message.member!.user.isOwner()) - return await message.util.reply(`${util.emojis.error} You must have admin perms to use this command.`); + return await message.util.reply(`${emojis.error} You must have admin perms to use this command.`); if (message.util.isSlashMessage(message)) await message.interaction.deferReply(); if (args.role.comparePositionTo(message.guild.members.me!.roles.highest) >= 0 && !args.role) { - return await message.util.reply(`${util.emojis.error} I cannot assign a role higher or equal to my highest role.`); + return await message.util.reply(`${emojis.error} I cannot assign a role higher or equal to my highest role.`); } let members = await message.guild.members.fetch(); @@ -62,7 +70,7 @@ export default class RoleAllCommand extends BushCommand { return true; }); - await message.util.reply(`${util.emojis.loading} adding roles to ${members.size} members`); + await message.util.reply(`${emojis.loading} adding roles to ${members.size} members`); const promises = members.map((member: GuildMember) => { return member.roles.add(args.role, `RoleAll Command - triggered by ${message.author.tag} (${message.author.id})`); @@ -72,7 +80,7 @@ export default class RoleAllCommand extends BushCommand { if (!failed.length) { await message.util.sendNew({ - content: `${util.emojis.success} Finished adding <@&${args.role.id}> to **${members.size}** member${ + content: `${emojis.success} Finished adding <@&${args.role.id}> to **${members.size}** member${ members.size > 1 ? 's' : '' }.`, allowedMentions: AllowedMentions.none() @@ -80,7 +88,7 @@ export default class RoleAllCommand extends BushCommand { } else { const array = [...members.values()]; await message.util.sendNew({ - content: `${util.emojis.warn} Finished adding <@&${args.role.id}> to **${members.size - failed.length}** member${ + content: `${emojis.warn} Finished adding <@&${args.role.id}> to **${members.size - failed.length}** member${ members.size - failed.length > 1 ? 's' : '' }! Failed members:\n${failed.map((_, index) => `<@${array[index].id}>`).join(' ')}`, allowedMentions: AllowedMentions.none() diff --git a/src/commands/config/_customAutomodPhrases.ts b/src/commands/config/_customAutomodPhrases.ts index 13887ae..d60688c 100644 --- a/src/commands/config/_customAutomodPhrases.ts +++ b/src/commands/config/_customAutomodPhrases.ts @@ -30,7 +30,7 @@ // ], // slash: true, // channel: 'guild', -// clientPermissions: (m) => util.clientSendAndPermCheck(m), +// clientPermissions: (m) => clientSendAndPermCheck(m), // userPermissions: [PermissionFlagsBits.ManageGuild] // }); // } diff --git a/src/commands/config/blacklist.ts b/src/commands/config/blacklist.ts index de457c0..80acd0b 100644 --- a/src/commands/config/blacklist.ts +++ b/src/commands/config/blacklist.ts @@ -1,4 +1,17 @@ -import { AllowedMentions, BushCommand, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; +import { + addOrRemoveFromArray, + AllowedMentions, + Arg, + BushCommand, + clientSendAndPermCheck, + emojis, + format, + getGlobal, + setGlobal, + type ArgType, + type CommandMessage, + type SlashMessage +} from '#lib'; import assert from 'assert'; import { ApplicationCommandOptionType, GuildMember, PermissionFlagsBits, User } from 'discord.js'; @@ -23,7 +36,7 @@ export default class BlacklistCommand extends BushCommand { { id: 'target', description: 'The channel/user to blacklist.', - type: util.arg.union('channel', 'user'), + type: Arg.union('channel', 'user'), readableType: 'channel|user', prompt: 'What channel or user that you would like to blacklist/unblacklist?', retry: '{error} Pick a valid user or channel.', @@ -41,7 +54,7 @@ export default class BlacklistCommand extends BushCommand { } ], slash: true, - clientPermissions: (m) => util.clientSendAndPermCheck(m), + clientPermissions: (m) => clientSendAndPermCheck(m), userPermissions: [PermissionFlagsBits.ManageGuild] }); } @@ -59,26 +72,26 @@ export default class BlacklistCommand extends BushCommand { const global = args.global && message.author.isOwner(); const target = typeof args.target === 'string' - ? (await util.arg.cast('textChannel', message, args.target)) ?? (await util.arg.cast('user', message, args.target)) + ? (await Arg.cast('textChannel', message, args.target)) ?? (await Arg.cast('user', message, args.target)) : args.target; - if (!target) return await message.util.reply(`${util.emojis.error} Choose a valid channel or user.`); + if (!target) return await message.util.reply(`${emojis.error} Choose a valid channel or user.`); const targetID = target.id; if (!message.inGuild() && !global) - return await message.util.reply(`${util.emojis.error} You have to be in a guild to disable commands.`); + return await message.util.reply(`${emojis.error} You have to be in a guild to disable commands.`); if (!global) assert(message.inGuild()); const blacklistedUsers = global - ? util.getGlobal('blacklistedUsers') + ? getGlobal('blacklistedUsers') : (await message.guild!.getSetting('blacklistedChannels')) ?? []; const blacklistedChannels = global - ? util.getGlobal('blacklistedChannels') + ? getGlobal('blacklistedChannels') : (await message.guild!.getSetting('blacklistedUsers')) ?? []; if (action === 'toggle') { action = blacklistedUsers.includes(targetID) || blacklistedChannels.includes(targetID) ? 'unblacklist' : 'blacklist'; } - const newValue = util.addOrRemoveFromArray( + const newValue = addOrRemoveFromArray( action === 'blacklist' ? 'add' : 'remove', target instanceof User ? blacklistedUsers : blacklistedChannels, targetID @@ -87,22 +100,22 @@ export default class BlacklistCommand extends BushCommand { const key = target instanceof User ? 'blacklistedUsers' : 'blacklistedChannels'; const success = await (global - ? util.setGlobal(key, newValue) + ? setGlobal(key, newValue) : message.guild!.setSetting(key, newValue, message.member as GuildMember) ).catch(() => false); if (!success) return await message.util.reply({ - content: `${util.emojis.error} There was an error${global ? ' globally' : ''} ${action}ing ${util.format.input( + content: `${emojis.error} There was an error${global ? ' globally' : ''} ${action}ing ${format.input( target instanceof User ? target.tag : target.name )}.`, allowedMentions: AllowedMentions.none() }); else return await message.util.reply({ - content: `${util.emojis.success} Successfully ${action}ed ${util.format.input( - target instanceof User ? target.tag : target.name - )}${global ? ' globally' : ''}.`, + content: `${emojis.success} Successfully ${action}ed ${format.input(target instanceof User ? target.tag : target.name)}${ + global ? ' globally' : '' + }.`, allowedMentions: AllowedMentions.none() }); } diff --git a/src/commands/config/config.ts b/src/commands/config/config.ts index 689a3af..f0db467 100644 --- a/src/commands/config/config.ts +++ b/src/commands/config/config.ts @@ -1,7 +1,14 @@ import { + addOrRemoveFromArray, BushCommand, + clientSendAndPermCheck, + colors, + emojis, GuildNoArraySetting, guildSettingsObj, + inspectAndRedact, + oxford, + prefix, settingsArr, type ArgType, type CommandMessage, @@ -145,7 +152,7 @@ export default class ConfigCommand extends BushCommand { }; }), channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m), + clientPermissions: (m) => clientSendAndPermCheck(m), userPermissions: [PermissionFlagsBits.ManageGuild] }); } @@ -171,11 +178,11 @@ export default class ConfigCommand extends BushCommand { id: 'action', type: actionType, prompt: { - start: `Would you like to ${util.oxford( + start: `Would you like |
