diff options
| author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-10-26 20:07:19 -0400 |
|---|---|---|
| committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-10-26 20:07:19 -0400 |
| commit | ed59b7f1827ab93573b079144c3eeaa01ce40492 (patch) | |
| tree | 7ceac6d61a8a25586ab9bbaf7acfbade91c97132 /src/commands | |
| parent | c0a81b014a56e4d44c826f78391a930361aab122 (diff) | |
| download | tanzanite-ed59b7f1827ab93573b079144c3eeaa01ce40492.tar.gz tanzanite-ed59b7f1827ab93573b079144c3eeaa01ce40492.tar.bz2 tanzanite-ed59b7f1827ab93573b079144c3eeaa01ce40492.zip | |
clean up, bug fixes
Diffstat (limited to 'src/commands')
68 files changed, 354 insertions, 303 deletions
diff --git a/src/commands/_fake-command/ironmoon.ts b/src/commands/_fake-command/ironmoon.ts index d7e737f..612db85 100644 --- a/src/commands/_fake-command/ironmoon.ts +++ b/src/commands/_fake-command/ironmoon.ts @@ -4,7 +4,7 @@ export default class IronmoonCommand extends BushCommand { public constructor() { super('ironmoon', { category: 'fake-commands', - description: { content: '', examples: '', usage: '' }, + description: { content: '', examples: [''], usage: [''] }, pseudo: true, clientPermissions: [], userPermissions: [] @@ -16,7 +16,7 @@ export default class IronmoonCommand extends BushCommand { else return false; } - public override async exec(message: BushMessage | BushSlashMessage): Promise<unknown> { + public override async exec(message: BushMessage | BushSlashMessage) { return await message.util.reply('Your message included the word ironmoon.'); } } diff --git a/src/commands/admin/channelPermissions.ts b/src/commands/admin/channelPermissions.ts index bae1133..dc35c87 100644 --- a/src/commands/admin/channelPermissions.ts +++ b/src/commands/admin/channelPermissions.ts @@ -1,5 +1,5 @@ -import { BushCommand, BushMessage, ButtonPaginator } from '@lib'; -import { GuildMember, MessageEmbed, Role } from 'discord.js'; +import { BushCommand, BushMessage, BushSlashMessage, ButtonPaginator } from '@lib'; +import { GuildMember, MessageEmbed, PermissionString, Role } from 'discord.js'; export default class ChannelPermissionsCommand extends BushCommand { public constructor() { @@ -8,9 +8,9 @@ export default class ChannelPermissionsCommand extends BushCommand { category: 'admin', typing: true, description: { - content: 'Use to mass change the channel ', - usage: 'ChannelPerms <role_id> <perm> <state>', - examples: ['ChannelPerms 783794633129197589 read_messages deny'] + content: 'Use to mass change the channel permissions.', + usage: ['channel-perms <role_id> <perm> <state>'], + examples: ['channel-perms 783794633129197589 read_messages deny'] }, args: [ { @@ -18,7 +18,7 @@ export default class ChannelPermissionsCommand extends BushCommand { customType: util.arg.union('member', 'member'), prompt: { start: 'What user/role would you like to change?', - retry: 'Invalid response. What user/role would you like to change?' + retry: '{error} Choose a valid user/role to change.' } }, { @@ -44,39 +44,79 @@ export default class ChannelPermissionsCommand extends BushCommand { ], clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_CHANNELS']), userPermissions: ['ADMINISTRATOR'], - channel: 'guild' + channel: 'guild', + slash: true, + slashOptions: [ + { + name: 'target', + description: 'What user/role would you like to change?', + type: 'MENTIONABLE', + required: true + }, + { + name: 'permission', + description: 'What permission would you like to change?', + type: 'STRING', + required: true + }, + { + name: 'state', + description: 'What should that permission be set to?', + type: 'STRING', + choices: [ + { + name: 'Enabled', + value: 'true' + }, + { + name: 'Disabled', + value: 'false' + }, + { + name: 'Neutral', + value: 'neutral' + } + ], + required: true + } + ] }); } public override async exec( - message: BushMessage, - { - target, - permission, - state - }: { + message: BushMessage | BushSlashMessage, + args: { target: Role | GuildMember; - permission: string; + permission: PermissionString | string; state: 'true' | 'false' | 'neutral'; } - ): Promise<unknown> { + ) { + if (!message.guild) return await message.util.reply(`${util.emojis.error} This command can only be run in a server.`); + if (!message.member!.permissions.has('ADMINISTRATOR') && !message.member!.user.isOwner()) + return await message.util.reply(`${util.emojis.error} You must have admin perms to use this command.`); + if (message.util.isSlashMessage(message)) await message.interaction.deferReply(); + + const permission: PermissionString = message.util.isSlashMessage(message) + ? await util.arg.cast('permission', message, args.permission) + : args.permission; + if (!permission) return await message.util.reply(`${util.emojis.error} Invalid permission.`); const failedChannels = []; - for (const channel of message.guild!.channels.cache.values()) { + for (const [, channel] of message.guild!.channels.cache) { try { if (channel.isThread()) return; if (channel.permissionsLocked) return; - const permissionState = state === 'true' ? true : state === 'false' ? false : null; + const permissionState = args.state === 'true' ? true : args.state === 'false' ? false : null; await channel.permissionOverwrites.create( - target.id, + args.target.id, { [permission]: permissionState }, { reason: 'Changing overwrites for mass channel perms command' } ); } catch (e) { - client.console.debug(e.stack); + void client.console.error('channelPermissions', e.stack); failedChannels.push(channel); } } - const failure = failedChannels.map((e) => `<#${e.id}>`).join(' '); + const failure = failedChannels.map((c) => `<#${c.id}>`).join(' '); if (failure.length > 2000) { const paginate: MessageEmbed[] = []; for (let i = 0; i < failure.length; i += 4000) { diff --git a/src/commands/admin/roleAll.ts b/src/commands/admin/roleAll.ts index 73369fc..1e67874 100644 --- a/src/commands/admin/roleAll.ts +++ b/src/commands/admin/roleAll.ts @@ -1,4 +1,4 @@ -import { AllowedMentions, BushCommand, BushMessage } from '@lib'; +import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage } from '@lib'; import { GuildMember, Role } from 'discord.js'; export default class RoleAllCommand extends BushCommand { @@ -8,8 +8,8 @@ export default class RoleAllCommand extends BushCommand { category: 'admin', description: { content: 'Give a role to every member on the server.', - usage: 'roleAll <role> [another role]... [--bots]', - examples: ['roleAll 783794633129197589 --bots'] + usage: ['role-all <role> [--bots]'], + examples: ['role-all 783794633129197589 --bots'] }, args: [ { @@ -30,14 +30,30 @@ export default class RoleAllCommand extends BushCommand { channel: 'guild', clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_ROLES']), userPermissions: ['ADMINISTRATOR'], - typing: true + typing: true, + slash: true, + slashOptions: [ + { + name: 'role', + description: 'What role would you like to give to every member on the server?', + type: 'ROLE', + required: true + }, + { + name: 'bots', + description: 'Would you like to also give roles to bots?', + type: 'BOOLEAN', + required: false + } + ] }); } - public override async exec(message: BushMessage, args: { role: Role; bot?: boolean }): Promise<unknown> { + public override async exec(message: BushMessage | BushSlashMessage, args: { role: Role; bots: boolean }) { if (!message.guild) return await message.util.reply(`${util.emojis.error} This command can only be run in a server.`); if (!message.member!.permissions.has('ADMINISTRATOR') && !message.member!.user.isOwner()) return await message.util.reply(`${util.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.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.`); @@ -47,7 +63,7 @@ export default class RoleAllCommand extends BushCommand { members = members.filter((member: GuildMember) => { try { - if (member.user.bot && !args.bot) return false; + if (member.user.bot && !args.bots) return false; if (member.roles.cache.has(args.role.id)) return false; } catch { return false; @@ -66,7 +82,7 @@ export default class RoleAllCommand extends BushCommand { if (!failed.length) { await message.util.reply({ content: `${util.emojis.success} Finished adding <@&${args.role.id}> to **${members.size}** member${ - members.size ? 's' : '' + members.size > 1 ? 's' : '' }.`, allowedMentions: AllowedMentions.none() }); @@ -74,7 +90,7 @@ export default class RoleAllCommand extends BushCommand { const array = [...members.values()]; await message.util.reply({ content: `${util.emojis.warn} Finished adding <@&${args.role.id}> to **${members.size - failed.length}** member${ - members.size - failed.length ? 's' : '' + 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/blacklist.ts b/src/commands/config/blacklist.ts index ef0c94e..d6d7c18 100644 --- a/src/commands/config/blacklist.ts +++ b/src/commands/config/blacklist.ts @@ -9,7 +9,7 @@ export default class BlacklistCommand extends BushCommand { category: 'config', description: { content: 'A command to blacklist users and channels.', - usage: 'blacklist|unblacklist <user|channel>', + usage: ['blacklist|unblacklist <user|channel>'], examples: ['blacklist @user', 'unblacklist #channel'] }, args: [ @@ -18,8 +18,7 @@ export default class BlacklistCommand extends BushCommand { customType: Argument.union('channel', 'user'), prompt: { start: 'What channel or user that you would like to blacklist/unblacklist?', - retry: '{error} Pick a valid command.', - optional: false + retry: '{error} Pick a valid user or channel.' } }, { @@ -56,7 +55,7 @@ export default class BlacklistCommand extends BushCommand { public override async exec( message: BushMessage | BushSlashMessage, args: { action: 'blacklist' | 'unblacklist'; target: Channel | User | string; global: boolean } - ): Promise<unknown> { + ) { let action: 'blacklist' | 'unblacklist' | 'toggle' = args.action ?? (message?.util?.parsed?.alias as 'blacklist' | 'unblacklist') ?? 'toggle'; const global = args.global && message.author.isOwner(); @@ -92,9 +91,7 @@ export default class BlacklistCommand extends BushCommand { }); else return await message.util.reply({ - content: `${util.emojis.success} Successfully **${action}ed** ${util.format.bold( - target?.tag ?? target.name - )} globally.`, + content: `${util.emojis.success} Successfully ${action}ed ${util.format.bold(target?.tag ?? target.name)} globally.`, allowedMentions: AllowedMentions.none() }); // guild disable diff --git a/src/commands/config/config.ts b/src/commands/config/config.ts index 0fdd615..0ca8ef8 100644 --- a/src/commands/config/config.ts +++ b/src/commands/config/config.ts @@ -24,9 +24,11 @@ export default class SettingsCommand extends BushCommand { category: 'config', description: { content: 'Configure server settings.', - usage: `settings (${settingsArr.map((s) => `\`${s}\``).join(', ')}) (${['view', 'set', 'add', 'remove'].map( - (s) => `\`${s}\`` - )})`, + usage: [ + `settings (${settingsArr.map((s) => `\`${s}\``).join(', ')}) (${['view', 'set', 'add', 'remove'].map( + (s) => `\`${s}\`` + )})` + ], examples: ['settings', 'config prefix set -'] }, slash: true, @@ -181,7 +183,7 @@ export default class SettingsCommand extends BushCommand { subcommand?: Action; value: string | Channel | Role; } - ): Promise<unknown> { + ) { if (!message.guild) return await message.util.reply(`${util.emojis.error} This command can only be used in servers.`); if (!message.member?.permissions.has('MANAGE_GUILD') && !message.member?.user.isOwner()) return await message.util.reply( diff --git a/src/commands/config/customAutomodPhrases.ts b/src/commands/config/customAutomodPhrases.ts index 51e219a..e02d52b 100644 --- a/src/commands/config/customAutomodPhrases.ts +++ b/src/commands/config/customAutomodPhrases.ts @@ -7,7 +7,7 @@ // category: 'config', // description: { // content: 'Configure additional phrases to be used for automod.', -// usage: 'custom-automod-phrases <requiredArg> [optionalArg]', +// usage: ['custom-automod-phrases <requiredArg> [optionalArg]'], // examples: ['custom-automod-phrases 1 2'] // }, // args: [ @@ -57,7 +57,7 @@ // public override async exec( // message: BushMessage | BushSlashMessage, // args: { required_argument: string; optional_argument: string } -// ): Promise<unknown> { +// ) { // return await message.util.reply(`${util.emojis.error} Do not use the template command.`); // args; // } diff --git a/src/commands/config/disable.ts b/src/commands/config/disable.ts index bca1207..2e3ce74 100644 --- a/src/commands/config/disable.ts +++ b/src/commands/config/disable.ts @@ -7,7 +7,7 @@ export default class DisableCommand extends BushCommand { category: 'config', description: { content: 'A command to disable and enable commands.', - usage: 'disable|enable <command>', + usage: ['disable|enable <command>'], examples: ['enable ban', 'disable kick'] }, args: [ @@ -62,7 +62,7 @@ export default class DisableCommand extends BushCommand { public override async exec( message: BushMessage | BushSlashMessage, args: { action: 'enable' | 'disable'; command: BushCommand | string; global: boolean } - ): Promise<unknown> { + ) { let action = (args.action ?? message?.util?.parsed?.alias ?? 'toggle') as 'disable' | 'enable' | 'toggle'; const global = args.global && message.author.isOwner(); const commandID = (args.command as BushCommand).id; diff --git a/src/commands/config/features.ts b/src/commands/config/features.ts index 3c3075c..8285845 100644 --- a/src/commands/config/features.ts +++ b/src/commands/config/features.ts @@ -8,7 +8,7 @@ export default class FeaturesCommand extends BushCommand { category: 'config', description: { content: 'Toggle features the server.', - usage: 'features', + usage: ['features'], examples: ['features'] }, slash: true, @@ -18,7 +18,7 @@ export default class FeaturesCommand extends BushCommand { }); } - public override async exec(message: BushMessage | BushSlashMessage): Promise<unknown> { + public override async exec(message: BushMessage | BushSlashMessage) { if (!message.guild) return await message.util.reply(`${util.emojis.error} This command can only be used in servers.`); const featureEmbed = new MessageEmbed().setTitle(`${message.guild!.name}'s Features`).setColor(util.colors.default); diff --git a/src/commands/config/levelRoles.ts b/src/commands/config/levelRoles.ts index ee5f255..c8f0bf3 100644 --- a/src/commands/config/levelRoles.ts +++ b/src/commands/config/levelRoles.ts @@ -58,7 +58,7 @@ // public override async exec( // message: BushMessage | BushSlashMessage, // args: { required_argument: string; optional_argument: string } -// ): Promise<unknown> { +// ) { // return await message.util.reply(`${util.emojis.error} Do not use the template command.`); // args; // } diff --git a/src/commands/config/log.ts b/src/commands/config/log.ts index 363620a..c364a35 100644 --- a/src/commands/config/log.ts +++ b/src/commands/config/log.ts @@ -9,7 +9,7 @@ export default class LogCommand extends BushCommand { category: 'config', description: { content: 'Set or remove a log channel.', - usage: 'log <logType> [channel]', + usage: ['log <logType> [channel]'], examples: ['log automod #automod-logs'] }, slash: true, @@ -60,10 +60,7 @@ export default class LogCommand extends BushCommand { return { log_type, channel }; } - public override async exec( - message: BushMessage | BushSlashMessage, - args: { log_type: GuildLogType; channel: TextChannel } - ): Promise<unknown> { + public override async exec(message: BushMessage | BushSlashMessage, args: { log_type: GuildLogType; channel: TextChannel }) { if (!message.guild) return await message.util.reply(`${util.emojis.error} This command can only be used in servers.`); const currentLogs = await message.guild.getSetting('logChannels'); const oldChannel = currentLogs[args.log_type] ?? undefined; diff --git a/src/commands/dev/__template.ts b/src/commands/dev/__template.ts index b9d9114..0d25766 100644 --- a/src/commands/dev/__template.ts +++ b/src/commands/dev/__template.ts @@ -7,7 +7,7 @@ export default class TemplateCommand extends BushCommand { category: 'template', description: { content: 'Command description.', - usage: 'template <requiredArg> [optionalArg]', + usage: ['template <requiredArg> [optionalArg]'], examples: ['template 1 2'] }, args: [ @@ -53,11 +53,10 @@ export default class TemplateCommand extends BushCommand { userPermissions: [] }); } - public override async exec( message: BushMessage | BushSlashMessage, args: { required_argument: string; optional_argument: string } - ): Promise<unknown> { + ) { return await message.util.reply(`${util.emojis.error} Do not use the template command.`); args; } |
