From 453683b57b8ff013ff25e2aaa4aa1d2e047edcb7 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sun, 28 Nov 2021 09:27:41 -0500 Subject: a few small changes --- src/arguments/messageLink.ts | 19 + src/commands/_fake-command/ironmoon.ts | 4 +- src/commands/admin/channelPermissions.ts | 77 ++-- src/commands/admin/roleAll.ts | 38 +- src/commands/config/blacklist.ts | 62 ++-- src/commands/config/config.ts | 14 +- src/commands/config/customAutomodPhrases.ts | 8 +- src/commands/config/disable.ts | 134 +++---- src/commands/config/features.ts | 8 +- src/commands/config/levelRoles.ts | 24 +- src/commands/config/log.ts | 33 +- src/commands/dev/__template.ts | 41 +-- src/commands/dev/dm.ts | 46 +++ src/commands/dev/eval.ts | 103 ++++-- src/commands/dev/javascript.ts | 30 +- src/commands/dev/reload.ts | 22 +- src/commands/dev/say.ts | 14 +- src/commands/dev/servers.ts | 10 +- src/commands/dev/sh.ts | 16 +- src/commands/dev/superUser.ts | 25 +- src/commands/dev/test.ts | 19 +- src/commands/fun/coinflip.ts | 8 +- src/commands/fun/dice.ts | 8 +- src/commands/fun/eightBall.ts | 24 +- src/commands/fun/minesweeper.ts | 74 ++-- src/commands/info/avatar.ts | 29 +- src/commands/info/botInfo.ts | 8 +- src/commands/info/color.ts | 38 +- src/commands/info/guildInfo.ts | 63 ++-- src/commands/info/help.ts | 49 ++- src/commands/info/icon.ts | 8 +- src/commands/info/links.ts | 8 +- src/commands/info/ping.ts | 8 +- src/commands/info/pronouns.ts | 26 +- src/commands/info/snowflake.ts | 54 ++- src/commands/info/userInfo.ts | 29 +- src/commands/leveling/leaderboard.ts | 26 +- src/commands/leveling/level.ts | 26 +- src/commands/leveling/setLevel.ts | 38 +- src/commands/leveling/setXp.ts | 40 +-- src/commands/moderation/_lockdown.ts | 23 +- src/commands/moderation/activePunishments.ts | 76 ++++ src/commands/moderation/ban.ts | 73 ++-- src/commands/moderation/evidence.ts | 32 +- src/commands/moderation/hideCase.ts | 24 +- src/commands/moderation/kick.ts | 49 +-- src/commands/moderation/modlog.ts | 46 +-- src/commands/moderation/mute.ts | 49 +-- src/commands/moderation/purge.ts | 57 ++- src/commands/moderation/removeReactionEmoji.ts | 48 +-- src/commands/moderation/role.ts | 123 ++++--- src/commands/moderation/slowmode.ts | 44 +-- src/commands/moderation/unban.ts | 42 +-- src/commands/moderation/unmute.ts | 49 +-- src/commands/moderation/warn.ts | 49 +-- src/commands/moulberry-bush/capePerms.ts | 27 +- src/commands/moulberry-bush/capes.ts | 28 +- src/commands/moulberry-bush/giveawayPing.ts | 8 +- src/commands/moulberry-bush/moulHammer.ts | 22 +- src/commands/moulberry-bush/report.ts | 41 +-- src/commands/moulberry-bush/rule.ts | 45 +-- src/commands/moulberry-bush/serverStatus.ts | 8 +- src/commands/utilities/activity.ts | 127 ++++--- src/commands/utilities/calculator.ts | 25 +- src/commands/utilities/decode.ts | 56 +-- src/commands/utilities/hash.ts | 16 +- src/commands/utilities/price.ts | 35 +- src/commands/utilities/steal.ts | 105 ++++-- src/commands/utilities/suicide.ts | 8 +- src/commands/utilities/uuid.ts | 39 +- src/commands/utilities/viewRaw.ts | 78 ++-- src/commands/utilities/whoHasRole.ts | 26 +- src/commands/utilities/wolframAlpha.ts | 37 +- src/lib/common/Format.ts | 52 ++- src/lib/common/util/Arg.ts | 6 +- src/lib/extensions/discord-akairo/BushClient.ts | 4 +- .../extensions/discord-akairo/BushClientUtil.ts | 283 ++++++++++----- src/lib/extensions/discord-akairo/BushCommand.ts | 309 ++++++++++++++-- src/lib/extensions/discord.js/BushGuild.ts | 48 ++- src/lib/extensions/global.d.ts | 9 + src/lib/utils/BushConstants.ts | 399 +++++++++------------ src/lib/utils/BushLogger.ts | 68 ++-- src/listeners/client/ready.ts | 5 +- src/listeners/commands/commandBlocked.ts | 12 +- src/listeners/commands/messageBlocked.ts | 5 +- src/listeners/custom/bushLevelUpdate.ts | 8 +- src/listeners/guild/guildMemberAdd.ts | 51 +-- src/listeners/guild/guildMemberRemove.ts | 14 +- src/listeners/other/promiseRejection.ts | 3 +- src/listeners/other/uncaughtException.ts | 3 +- 90 files changed, 2150 insertions(+), 1955 deletions(-) create mode 100644 src/arguments/messageLink.ts create mode 100644 src/commands/dev/dm.ts create mode 100644 src/commands/moderation/activePunishments.ts (limited to 'src') diff --git a/src/arguments/messageLink.ts b/src/arguments/messageLink.ts new file mode 100644 index 0000000..d270abd --- /dev/null +++ b/src/arguments/messageLink.ts @@ -0,0 +1,19 @@ +import { type BushArgumentTypeCaster } from '../lib'; + +export const messageLink: BushArgumentTypeCaster = async (_, phrase) => { + const match = client.consts.regex.messageLink.exec(phrase); + if (!match || !match.groups) return null; + + const { guild_id, channel_id, message_id } = match.groups; + + if (!guild_id || !channel_id || message_id) return null; + + const guild = client.guilds.cache.get(guild_id); + if (!guild) return null; + + const channel = guild.channels.cache.get(channel_id); + if (!channel || (!channel.isText() && !channel.isThread())) return null; + + const message = await channel.messages.fetch(message_id).catch(() => null); + return message; +}; diff --git a/src/commands/_fake-command/ironmoon.ts b/src/commands/_fake-command/ironmoon.ts index b13d1d3..428b554 100644 --- a/src/commands/_fake-command/ironmoon.ts +++ b/src/commands/_fake-command/ironmoon.ts @@ -4,7 +4,9 @@ export default class IronmoonCommand extends BushCommand { public constructor() { super('ironmoon', { category: 'fake-commands', - description: { content: '', examples: [''], usage: [''] }, + description: '', + examples: [''], + usage: [''], pseudo: true, clientPermissions: [], userPermissions: [] diff --git a/src/commands/admin/channelPermissions.ts b/src/commands/admin/channelPermissions.ts index befa3ea..b44ae21 100644 --- a/src/commands/admin/channelPermissions.ts +++ b/src/commands/admin/channelPermissions.ts @@ -7,79 +7,50 @@ export default class ChannelPermissionsCommand extends BushCommand { aliases: ['channel-perms', 'cperms', 'cperm', 'chanperms', 'chanperm', 'channel-permissions'], category: 'admin', typing: true, - description: { - content: 'Use to mass change the channel permissions.', - usage: ['channel-perms '], - examples: ['channel-perms 783794633129197589 read_messages deny'] - }, + description: 'Use to mass change the channel permissions.', + usage: ['channel-perms '], + examples: ['channel-perms 783794633129197589 read_messages deny'], args: [ { id: 'target', - customType: util.arg.union('member', 'member'), - prompt: { - start: 'What user/role would you like to change?', - retry: '{error} Choose a valid user/role to change.' - } + description: 'The user/role to change the permissions of.', + customType: util.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.', + slashType: 'MENTIONABLE' }, { id: 'permission', + description: 'The permission to change for the target user/role.', type: 'permission', - prompt: { - start: 'What permission would you like to change?', - retry: '{error} Choose a valid permission.' - } + prompt: 'What permission would you like to change?', + retry: '{error} Choose a valid permission.', + slashType: 'STRING' }, { id: 'state', + description: 'The state that the permission should be set to for the target.', customType: [ ['true', '1', 'yes', 'enable', 'allow'], ['false', '0', 'no', 'disable', 'disallow', 'deny'], ['neutral', 'remove', 'none'] ], - prompt: { - start: 'What should that permission be set to?', - retry: '{error} Set the state to either `enable`, `disable`, or `remove`.' - } + readableType: "'enable'|'disable'|'remove'", + prompt: 'What should that permission be set to?', + retry: '{error} Set the state to either `enable`, `disable`, or `remove`.', + slashType: 'STRING', + choices: [ + { name: 'Enabled', value: 'true' }, + { name: 'Disabled', value: 'false' }, + { name: 'Neutral', value: 'neutral' } + ] } ], clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_CHANNELS']), userPermissions: ['ADMINISTRATOR'], 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 - } - ] + slash: true }); } diff --git a/src/commands/admin/roleAll.ts b/src/commands/admin/roleAll.ts index 3c6b629..585e6cc 100644 --- a/src/commands/admin/roleAll.ts +++ b/src/commands/admin/roleAll.ts @@ -6,46 +6,34 @@ export default class RoleAllCommand extends BushCommand { super('roleAll', { aliases: ['role-all', 'rall'], category: 'admin', - description: { - content: 'Give a role to every member on the server.', - usage: ['role-all [--bots]'], - examples: ['role-all 783794633129197589 --bots'] - }, + description: 'Give a role to every member on the server.', + usage: ['role-all [--bots]'], + examples: ['role-all 783794633129197589 --bots'], args: [ { id: 'role', + description: 'The role to assigned to every member on the server.', type: 'role', - prompt: { - start: 'What role would you like to give to every member on the server?', - retry: '{error} Pick a valid role.' - } + prompt: 'What role would you like to give to every member on the server?', + retry: '{error} Pick a valid role.', + slashType: 'ROLE' }, { id: 'bots', + description: 'Also give the role to bots.', match: 'flag', + prompt: 'Would you like to also give roles to bots?', flag: '--bots', - default: false + default: false, + slashType: 'BOOLEAN', + optional: true } ], channel: 'guild', clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_ROLES']), userPermissions: ['ADMINISTRATOR'], 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 - } - ] + slash: true }); } diff --git a/src/commands/config/blacklist.ts b/src/commands/config/blacklist.ts index f0173a4..8bb778c 100644 --- a/src/commands/config/blacklist.ts +++ b/src/commands/config/blacklist.ts @@ -6,45 +6,43 @@ export default class BlacklistCommand extends BushCommand { super('blacklist', { aliases: ['blacklist', 'unblacklist'], category: 'config', - description: { - content: 'A command to blacklist users and channels.', - usage: ['blacklist|unblacklist '], - examples: ['blacklist @user', 'unblacklist #channel'] - }, + description: 'A command to blacklist users and channels.', + usage: ['blacklist|unblacklist '], + examples: ['blacklist @user', 'unblacklist #channel'], args: [ + { + id: 'action', + description: 'Whether to blacklist or unblacklist the target.', + readableType: "'blacklist'|'unblacklist'", + prompt: 'Would you like to add or remove someone or something from/to the blacklist?', + slashType: 'STRING', + choices: [ + { name: 'blacklist', value: 'blacklist' }, + { name: 'unblacklist', value: 'unblacklist' } + ], + only: 'slash' + }, { id: 'target', + description: 'The channel/user to blacklist.', customType: util.arg.union('channel', 'user'), - prompt: { - start: 'What channel or user that you would like to blacklist/unblacklist?', - retry: '{error} Pick a valid user or channel.' - } + readableType: 'channel|user', + prompt: 'What channel or user that you would like to blacklist/unblacklist?', + retry: '{error} Pick a valid user or channel.', + slashType: 'STRING' }, { id: 'global', + description: 'Blacklist the target globally.', match: 'flag', - flag: '--global' + flag: '--global', + optional: true, + slashType: false, + only: 'text', + ownerOnly: true } ], slash: true, - slashOptions: [ - { - name: 'action', - description: 'Would you like to add or remove someone or something from/to the blacklist?', - type: 'STRING', - choices: [ - { name: 'blacklist', value: 'blacklist' }, - { name: 'unblacklist', value: 'unblacklist' } - ], - required: true - }, - { - name: 'target', - description: 'What channel or user that you would like to blacklist/unblacklist?', - type: 'STRING', - required: true - } - ], channel: 'guild', clientPermissions: (m) => util.clientSendAndPermCheck(m), userPermissions: ['MANAGE_GUILD'] @@ -82,14 +80,14 @@ export default class BlacklistCommand extends BushCommand { .catch(() => false); if (!success) return await message.util.reply({ - content: `${util.emojis.error} There was an error globally ${action}ing ${util.format.bold( + content: `${util.emojis.error} There was an error globally ${action}ing ${util.format.input( target?.tag ?? target.name )}.`, allowedMentions: AllowedMentions.none() }); 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.input(target?.tag ?? target.name)} globally.`, allowedMentions: AllowedMentions.none() }); // guild disable @@ -110,12 +108,12 @@ export default class BlacklistCommand extends BushCommand { .catch(() => false); if (!success) return await message.util.reply({ - content: `${util.emojis.error} There was an error ${action}ing ${util.format.bold(target?.tag ?? target.name)}.`, + content: `${util.emojis.error} There was an error ${action}ing ${util.format.input(target?.tag ?? target.name)}.`, allowedMentions: AllowedMentions.none() }); else return await message.util.reply({ - content: `${util.emojis.success} Successfully ${action}ed ${util.format.bold(target?.tag ?? target.name)}.`, + content: `${util.emojis.success} Successfully ${action}ed ${util.format.input(target?.tag ?? target.name)}.`, allowedMentions: AllowedMentions.none() }); } diff --git a/src/commands/config/config.ts b/src/commands/config/config.ts index 2ce4246..6af5895 100644 --- a/src/commands/config/config.ts +++ b/src/commands/config/config.ts @@ -22,15 +22,11 @@ export default class SettingsCommand extends BushCommand { super('config', { aliases: ['config', 'settings', 'setting', 'configure'], category: 'config', - description: { - content: 'Configure server settings.', - usage: [ - `settings (${settingsArr.map((s) => `\`${s}\``).join(', ')}) (${['view', 'set', 'add', 'remove'].map( - (s) => `\`${s}\`` - )})` - ], - examples: ['settings', 'config prefix set -'] - }, + description: 'Configure server settings.', + usage: [ + `settings (${settingsArr.map((s) => `\`${s}\``).join(', ')}) (${['view', 'set', 'add', 'remove'].map((s) => `\`${s}\``)})` + ], + examples: ['settings', 'config prefix set -'], slash: true, slashOptions: settingsArr.map((setting) => { return { diff --git a/src/commands/config/customAutomodPhrases.ts b/src/commands/config/customAutomodPhrases.ts index 9fbebf5..cf37595 100644 --- a/src/commands/config/customAutomodPhrases.ts +++ b/src/commands/config/customAutomodPhrases.ts @@ -5,11 +5,9 @@ // super('customAutomodPhrases', { // aliases: ['custom-automod-phrases'], // category: 'config', -// description: { -// content: 'Configure additional phrases to be used for automod.', -// usage: ['custom-automod-phrases [optionalArg]'], -// examples: ['custom-automod-phrases 1 2'] -// }, +// description: 'Configure additional phrases to be used for automod.', +// usage: ['custom-automod-phrases [optionalArg]'], +// examples: ['custom-automod-phrases 1 2'], // args: [ // { // id: 'required_argument', diff --git a/src/commands/config/disable.ts b/src/commands/config/disable.ts index 83b4608..333ae19 100644 --- a/src/commands/config/disable.ts +++ b/src/commands/config/disable.ts @@ -5,52 +5,40 @@ export default class DisableCommand extends BushCommand { super('disable', { aliases: ['disable', 'enable'], category: 'config', - description: { - content: 'A command to disable and enable commands.', - usage: ['disable|enable '], - examples: ['enable ban', 'disable kick'] - }, + description: 'A command to disable and enable commands.', + usage: ['disable|enable '], + examples: ['enable ban', 'disable kick'], args: [ + { + id: 'action', + description: 'Whether to disable or enable the command.', + readableType: "'blacklist'|'unblacklist", + prompt: 'Would you like to disable or enable a command?', + slashType: 'STRING', + choices: ['blacklist', 'unblacklist'].map((v) => ({ name: v, value: v })), + only: 'slash' + }, { id: 'command', + description: 'The command to disable/enable.', customType: util.arg.union('commandAlias', 'command'), - prompt: { - start: 'What command would you like to enable/disable?', - retry: '{error} Pick a valid command.', - optional: false - } + readableType: 'command|commandAlias', + prompt: 'What command would you like to enable/disable?', + retry: '{error} Pick a valid command.', + slashType: 'STRING' }, { id: 'global', + description: 'Disable the command globally.', match: 'flag', - flag: '--global' + flag: '--global', + optional: true, + slashType: false, + only: 'text', + ownerOnly: true } ], slash: true, - slashOptions: [ - { - name: 'action', - description: 'Would you like to disable or enable a command?', - type: 'STRING', - choices: [ - { - name: 'enable', - value: 'enable' - }, - { - name: 'disable', - value: 'disable' - } - ], - required: true - }, - { - name: 'command', - description: 'What command would you like to enable/disable?', - type: 'STRING', - required: true - } - ], channel: 'guild', clientPermissions: (m) => util.clientSendAndPermCheck(m), userPermissions: ['MANAGE_GUILD'] @@ -67,57 +55,31 @@ export default class DisableCommand extends BushCommand { const global = args.global && message.author.isOwner(); const commandID = (args.command as BushCommand).id; - if (global) { - if (action === 'toggle') { - const disabledCommands = ( - (await Global.findByPk(client.config.environment)) ?? (await Global.create({ environment: client.config.environment })) - ).disabledCommands; - action = disabledCommands.includes(commandID) ? 'disable' : 'enable'; - } - const success = await util - .insertOrRemoveFromGlobal(action === 'disable' ? 'remove' : 'add', 'disabledCommands', commandID) - .catch(() => false); - if (!success) - return await message.util.reply({ - content: `${util.emojis.error} There was an error globally **${action.substring( - 0, - action.length - 2 - )}ing** the **${commandID}** command.`, - allowedMentions: AllowedMentions.none() - }); - else - return await message.util.reply({ - content: `${util.emojis.success} Successfully **${action.substring( - 0, - action.length - 2 - )}ed** the **${commandID}** command globally.`, - allowedMentions: AllowedMentions.none() - }); + const disabledCommands = global + ? ((await Global.findByPk(client.config.environment)) ?? (await Global.create({ environment: client.config.environment }))) + .disabledCommands + : await message.guild!.getSetting('disabledCommands'); - // guild disable - } else { - const disabledCommands = await message.guild!.getSetting('disabledCommands'); - if (action === 'toggle') { - action = disabledCommands.includes(commandID) ? 'disable' : 'enable'; - } - const newValue = util.addOrRemoveFromArray(action === 'disable' ? 'remove' : 'add', disabledCommands, commandID); - const success = await message.guild!.setSetting('disabledCommands', newValue, message.member!).catch(() => false); - if (!success) - return await message.util.reply({ - content: `${util.emojis.error} There was an error **${action.substr( - 0, - action.length - 2 - )}ing** the **${commandID}** command.`, - allowedMentions: AllowedMentions.none() - }); - else - return await message.util.reply({ - content: `${util.emojis.success} Successfully **${action.substr( - 0, - action.length - 2 - )}ed** the **${commandID}** command.`, - allowedMentions: AllowedMentions.none() - }); - } + if (action === 'toggle') action = disabledCommands.includes(commandID) ? 'disable' : 'enable'; + const newValue = util.addOrRemoveFromArray(action === 'disable' ? 'remove' : 'add', disabledCommands, commandID); + const success = global + ? await util.setGlobal('disabledCommands', newValue).catch(() => false) + : await message.guild!.setSetting('disabledCommands', newValue, message.member!).catch(() => false); + if (!success) + return await message.util.reply({ + content: `${util.emojis.error} There was an error${global ? ' globally' : ''} **${action.substring( + 0, + action.length - 2 + )}ing** the **${commandID}** command.`, + allowedMentions: AllowedMentions.none() + }); + else + return await message.util.reply({ + content: `${util.emojis.success} Successfully **${action.substring( + 0, + action.length - 2 + )}ed** the **${commandID}** command${global ? ' globally' : ''}.`, + allowedMentions: AllowedMentions.none() + }); } } diff --git a/src/commands/config/features.ts b/src/commands/config/features.ts index 095d985..894c90a 100644 --- a/src/commands/config/features.ts +++ b/src/commands/config/features.ts @@ -13,11 +13,9 @@ export default class FeaturesCommand extends BushCommand { super('features', { aliases: ['features'], category: 'config', - description: { - content: 'Toggle features the server.', - usage: ['features'], - examples: ['features'] - }, + description: 'Toggle features the server.', + usage: ['features'], + examples: ['features'], slash: true, channel: 'guild', clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), diff --git a/src/commands/config/levelRoles.ts b/src/commands/config/levelRoles.ts index e7b4505..7f99580 100644 --- a/src/commands/config/levelRoles.ts +++ b/src/commands/config/levelRoles.ts @@ -5,11 +5,9 @@ // super('levelRole', { // aliases: ['level-role', 'level-roles', 'lr'], // category: 'config', -// description: { -// content: 'Configure roles to be assigned to users upon reaching certain levels.', -// usage: ['level-role add ', 'level-role remove '], -// examples: ['level-role 1 2'] -// }, +// description: 'Configure roles to be assigned to users upon reaching certain levels.', +// usage: ['level-role add ', 'level-role remove '], +// examples: ['level-role 1 2'], // args: [ // { // id: 'action', @@ -18,20 +16,16 @@ // { // id: 'role', // type: 'role', -// prompt: { -// start: 'What would you like to set your first argument to be?', -// retry: '{error} Pick a valid argument.', -// optional: false -// } +// prompt: 'What would you like to set your first argument to be?', +// retry: '{error} Pick a valid argument.', +// optional: false // }, // { // id: 'level', // type: 'integer', -// prompt: { -// start: 'What would you like to set your second argument to be?', -// retry: '{error} Pick a valid argument.', -// optional: false -// } +// prompt: 'What would you like to set your second argument to be?', +// retry: '{error} Pick a valid argument.', +// optional: false // } // ], // slash: true, diff --git a/src/commands/config/log.ts b/src/commands/config/log.ts index cccef8c..6121ad7 100644 --- a/src/commands/config/log.ts +++ b/src/commands/config/log.ts @@ -7,25 +7,26 @@ export default class LogCommand extends BushCommand { super('log', { aliases: ['log', 'logging'], category: 'config', - description: { - content: 'Set or remove a log channel.', - usage: ['log [channel]'], - examples: ['log automod #automod-logs'] - }, + description: 'Set or remove a log channel.', + usage: ['log [channel]'], + examples: ['log automod #automod-logs'], slash: true, - slashOptions: [ + args: [ { - name: 'log_type', - description: 'What log type would you like to change?', - type: 'STRING', - required: true, - choices: guildLogsArr.map((log) => ({ name: log, value: log })) + id: 'log_type', + description: 'The log type to change.', + prompt: 'What log type would you like to change?', + slashType: 'STRING', + choices: guildLogsArr.map((log) => ({ name: log, value: log })), + only: 'slash' }, { - name: 'channel', - description: 'What channel would you like these logs to be sent in?', - type: 'CHANNEL', - required: false + id: 'channel', + description: 'The channel to have logs of the seleted type to be sent in.', + type: 'channel', + prompt: 'What channel would you like these logs to be sent in?', + slashType: 'CHANNEL', + channelTypes: ['GUILD_TEXT', 'GUILD_NEWS', 'GUILD_NEWS_THREAD', 'GUILD_PUBLIC_THREAD', 'GUILD_PRIVATE_THREAD'] } ], channel: 'guild', @@ -36,7 +37,7 @@ export default class LogCommand extends BushCommand { override *args(): IterableIterator { const log_type = yield { - id: 'log', + id: 'log_type', type: guildLogsArr, prompt: { start: 'What log type would you like to change?', diff --git a/src/commands/dev/__template.ts b/src/commands/dev/__template.ts index fe685ff..5bb29c8 100644 --- a/src/commands/dev/__template.ts +++ b/src/commands/dev/__template.ts @@ -5,46 +5,29 @@ export default class TemplateCommand extends BushCommand { super('template', { aliases: ['template'], category: 'template', - description: { - content: 'Command description.', - usage: ['template [optionalArg]'], - examples: ['template 1 2'] - }, + description: 'Command description.', + usage: ['template [optionalArg]'], + examples: ['template 1 2'], args: [ { id: 'required_argument', type: 'string', - prompt: { - start: 'What would you like to set your first argument to be?', - retry: '{error} Pick a valid argument.', - optional: false - } + description: 'This is the first argument.', + prompt: 'What would you like to set your first argument to be?', + retry: '{error} Pick a valid argument.', + slashType: 'STRING' }, { id: 'optional_argument', type: 'string', - prompt: { - start: 'What would you like to set your second argument to be?', - retry: '{error} Pick a valid argument.', - optional: true - } + description: 'This is the second argument.', + prompt: 'What would you like to set your second argument to be?', + retry: '{error} Pick a valid argument.', + optional: true, + slashType: 'STRING' } ], slash: false, //set this to true - slashOptions: [ - { - name: 'required_argument', - description: 'What would you like to set your first argument to be?', - type: 'STRING', - required: true - }, - { - name: 'optional_argument', - description: 'What would you like to set your second argument to be?', - type: 'STRING', - required: false - } - ], superUserOnly: true, ownerOnly: true, channel: 'guild', diff --git a/src/commands/dev/dm.ts b/src/commands/dev/dm.ts new file mode 100644 index 0000000..5031dfd --- /dev/null +++ b/src/commands/dev/dm.ts @@ -0,0 +1,46 @@ +import { BushCommand, BushUser, type BushMessage, type BushSlashMessage } from '#lib'; + +export default class DMCommand extends BushCommand { + public constructor() { + super('dm', { + aliases: ['dm'], + category: 'dev', + description: 'Send a direct message to a specified user from the bot.', + usage: ['dm '], + examples: ['dm IRONM00N hi'], + args: [ + { + id: 'user', + type: 'string', + description: 'The user to send the dm to.', + prompt: 'Who would you like to dm?', + retry: '{error} Pick a valid user to send a dm to.', + slashType: 'STRING' + }, + { + id: 'content', + type: 'string', + description: 'This is the second argument.', + prompt: 'What would you like to set your second argument to be?', + retry: '{error} Pick a valid argument.', + optional: true, + slashType: 'STRING' + } + ], + slash: false, + ownerOnly: true, + hidden: true, + clientPermissions: (m) => util.clientSendAndPermCheck(m), + userPermissions: [] + }); + } + public override async exec(message: BushMessage | BushSlashMessage, args: { user: BushUser; content: string }) { + try { + const u = await client.users.fetch(args.user.id); + await u.send(args.content); + } catch (e) { + return message.util.reply(`${util.emojis.error} There was an error sending ${util.format.input(args.user.tag)} a dm.`); + } + return message.util.reply(`${util.emojis.success} Successfully sent ${util.format.input(args.user.tag)} a dm.`); + } +} diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts index b82534c..5b30d96 100644 --- a/src/commands/dev/eval.ts +++ b/src/commands/dev/eval.ts @@ -11,42 +11,95 @@ export default class EvalCommand extends BushCommand { super('eval', { aliases: ['eval', 'ev', 'evaluate'], category: 'dev', - description: { - content: 'Evaluate code.', - usage: ['eval [--depth #] [--sudo] [--silent] [--delete] [--proto] [--hidden] [--ts]'], - examples: ['eval message.channel.delete()'] - }, + description: 'Evaluate code.', + usage: ['eval [--depth #] [--sudo] [--silent] [--delete] [--proto] [--hidden] [--ts]'], + examples: ['eval message.channel.delete()'], args: [ - { id: 'sel_depth', match: 'option', type: 'integer', flag: '--depth', default: 0 }, - { id: 'sudo', match: 'flag', flag: '--sudo' }, - { id: 'delete_msg', match: 'flag', flag: '--delete' }, - { id: 'silent', match: 'flag', flag: '--silent' }, - { id: 'typescript', match: 'flag', flag: '--ts' }, - { id: 'hidden', match: 'flag', flag: '--hidden' }, - { id: 'show_proto', match: 'flag', flag: '--proto' }, + { + id: 'sel_depth', + description: 'How deep to inspect the output.', + match: 'option', + type: 'integer', + flag: '--depth', + default: 0, + prompt: 'How deep would you like to inspect the output?', + slashType: 'INTEGER', + optional: true + }, + { + id: 'sudo', + description: 'Whether or not to override checks.', + match: 'flag', + flag: '--sudo', + prompt: 'Would you like to override checks?', + slashType: 'BOOLEAN', + optional: true + }, + { + id: 'delete_msg', + description: 'Whether or not to delete the message that invoked the command.', + match: 'flag', + flag: '--delete', + prompt: 'Would you like to delete the message that invoked the command?', + slashType: false, + optional: true, + only: 'text' + }, + { + id: 'silent', + description: 'Whether or not to make the response silent', + match: 'flag', + flag: '--silent', + prompt: 'Would you like to make the response silent?', + slashType: 'BOOLEAN', + optional: true + }, + { + id: 'typescript', + description: 'Whether or not to treat the code as typescript and transpile it.', + match: 'flag', + flag: '--ts', + prompt: 'Is this code written in typescript?', + slashType: 'BOOLEAN', + optional: true + }, + { + id: 'hidden', + description: 'Whether or not to show hidden items.', + match: 'flag', + flag: '--hidden', + prompt: 'Would you like to show hidden items?', + slashType: 'BOOLEAN', + optional: true + }, + { + id: 'show_proto', + description: 'Whether or not to show the prototype of the output.', + match: 'flag', + flag: '--proto', + prompt: 'Would you like to show the prototype of the output?', + slashType: 'BOOLEAN', + optional: true + }, { id: 'show_methods', + description: 'Whether or not to inspect the prototype chain for methods.', match: 'flag', - flag: ['--func', '--function', '--functions', '--meth', '--method', '--methods'] + flag: ['--func', '--function', '--functions', '--meth', '--method', '--methods'], + prompt: 'Would you like to inspect the prototype chain to find methods?', + slashType: 'BOOLEAN', + optional: true }, { id: 'code', + description: 'The code you would like to evaluate.', match: 'rest', - type: 'string', - prompt: { start: 'What would you like to eval?', retry: '{error} Invalid code to eval.' } + prompt: 'What would you like to eval?', + retry: '{error} Invalid code to eval.', + slashType: 'STRING' } ], slash: true, - slashOptions: [ - { name: 'code', description: 'The code you would like to evaluate.', type: 'STRING', required: true }, - { name: 'sel_depth', description: 'How deep to display the output.', type: 'INTEGER', required: false }, - { name: 'sudo', description: 'Whether or not to override checks.', type: 'BOOLEAN', required: false }, - { name: 'silent', description: 'Whether or not to make the response silent', type: 'BOOLEAN', required: false }, - { name: 'typescript', description: 'Whether or not the code is typescript.', type: 'BOOLEAN', required: false }, - { name: 'hidden', description: 'Whether or not to show hidden items.', type: 'BOOLEAN', required: false }, - { name: 'show_proto', description: 'Show prototype.', type: 'BOOLEAN', required: false }, - { name: 'show_methods', description: 'Show class functions.', type: 'BOOLEAN', required: false } - ], ownerOnly: true, clientPermissions: (m) => util.clientSendAndPermCheck(m), userPermissions: [] diff --git a/src/commands/dev/javascript.ts b/src/commands/dev/javascript.ts index 8a47b23..5173cd1 100644 --- a/src/commands/dev/javascript.ts +++ b/src/commands/dev/javascript.ts @@ -7,25 +7,31 @@ export default class JavascriptCommand extends BushCommand { super('javascript', { aliases: ['javascript', 'js'], category: 'dev', - description: { - content: 'Evaluate code in a sand boxed environment.', - usage: ['javascript [--depth #]'], - examples: ['javascript 9+10'] - }, + description: 'Evaluate code in a sand boxed environment.', + usage: ['javascript [--depth #]'], + examples: ['javascript 9+10'], args: [ - { id: 'sel_depth', match: 'option', type: 'integer', flag: '--depth', default: 0 }, + { + id: 'sel_depth', + description: 'How deep to inspect the output.', + match: 'option', + type: 'integer', + flag: '--depth', + default: 0, + prompt: 'How deep would you like to inspect the output?', + slashType: 'INTEGER', + optional: true + }, { id: 'code', + description: 'The code you would like to run in a sand boxed environment.', match: 'rest', - type: 'string', - prompt: { start: 'What would you like to eval?', retry: '{error} Invalid code to eval.' } + prompt: 'What code would you like to run in a sand boxed environment?', + retry: '{error} Invalid code to run in a sand boxed environment.', + slashType: 'STRING' } ], slash: true, - slashOptions: [ - { name: 'code', description: 'The code you would like to evaluate.', type: 'STRING', required: true }, - { name: 'sel_depth', description: 'How deep to display the output.', type: 'INTEGER', required: false } - ], superUserOnly: true, clientPermissions: (m) => util.clientSendAndPermCheck(m), userPermissions: [] diff --git a/src/commands/dev/reload.ts b/src/commands/dev/reload.ts index f9b1867..6d030b7 100644 --- a/src/commands/dev/reload.ts +++ b/src/commands/dev/reload.ts @@ -5,29 +5,23 @@ export default class ReloadCommand extends BushCommand { super('reload', { aliases: ['reload'], category: 'dev', - description: { - content: 'Reloads the bot', - usage: ['reload'], - examples: ['reload'] - }, + description: 'Reloads the bot', + usage: ['reload'], + examples: ['reload'], // args: [ // { // id: 'fast', + // description: 'Whether or not to use esbuild for fast compiling.', // match: 'flag', - // flag: '--fast' + // flag: '--fast', + // prompt: 'Would you like to use esbuild for fast compiling?', + // optional: true, + // slashType:'BOOLEAN' // } // ], ownerOnly: true, typing: true, slash: true, - // slashOptions: [ - // { - // name: 'fast', - // description: 'Whether to use esbuild for fast compiling or not', - // type: 'BOOLEAN', - // required: false - // } - // ], clientPermissions: (m) => util.clientSendAndPermCheck(m), userPermissions: [] }); diff --git a/src/commands/dev/say.ts b/src/commands/dev/say.ts index 400a132..80cbbe2 100644 --- a/src/commands/dev/say.ts +++ b/src/commands/dev/say.ts @@ -5,20 +5,20 @@ export default class SayCommand extends BushCommand { super('say', { aliases: ['say'], category: 'dev', - description: { - content: 'A command make the bot say something.', - usage: ['say '], - examples: ['say hello'] - }, + description: 'A command make the bot say something.', + usage: ['say '], + examples: ['say hello'], args: [ { id: 'content', + description: 'The content of the message to send.', type: 'string', match: 'rest', - prompt: { start: 'What would you like the bot to say?', retry: '{error} Choose something valid to say.' } + prompt: 'What would you like the bot to say?', + retry: '{error} Choose something for the bot to send.', + slashType: 'STRING' } ], - slashOptions: [{ name: 'content', description: 'What would you like the bot to say?', type: 'STRING' }], ownerOnly: true, clientPermissions: (m) => util.clientSendAndPermCheck(m), userPermissions: [], diff --git a/src/commands/dev/servers.ts b/src/commands/dev/servers.ts index e8a2fe4..308d1db 100644 --- a/src/commands/dev/servers.ts +++ b/src/commands/dev/servers.ts @@ -6,11 +6,9 @@ export default class ServersCommand extends BushCommand { super('servers', { aliases: ['servers', 'guilds'], category: 'dev', - description: { - content: 'Displays all the severs the bot is in', - usage: ['servers'], - examples: ['servers'] - }, + description: 'Displays all the severs the bot is in', + usage: ['servers'], + examples: ['servers'], clientPermissions: (m) => util.clientSendAndPermCheck(m), userPermissions: [], ownerOnly: true @@ -25,7 +23,7 @@ export default class ServersCommand extends BushCommand { title: `Server List [\`${guilds.length.toLocaleString()}\`]`, color: util.colors.default, fields: chunk.map((guild) => ({ - name: util.format.bold(guild.name), + name: util.format.input(guild.name), value: [ `**ID:** ${guild.id}`, `**Owner:** ${client.users.cache.has(guild.ownerId) ? client.users.cache.get(guild.ownerId)!.tag : guild.ownerId}`, diff --git a/src/commands/dev/sh.ts b/src/commands/dev/sh.ts index 83432f4..5ef72b1 100644 --- a/src/commands/dev/sh.ts +++ b/src/commands/dev/sh.ts @@ -17,20 +17,18 @@ export default class ShCommand extends BushCommand { super('sh', { aliases: ['sh', 'shell', 'cmd'], category: 'dev', - description: { - content: 'Run shell commands.', - usage: ['sh '], - examples: ['sh git pull'] - }, + description: 'Run shell commands.', + usage: ['sh '], + examples: ['sh git pull'], args: [ { id: 'command', + description: 'The content you would like to run as a shell command.', type: 'string', match: 'rest', - prompt: { - start: 'What would you like run', - retry: '{error} Invalid command to run.' - } + prompt: 'What would you like run', + retry: '{error} Invalid command to run.', + slashType: 'STRING' } ], ownerOnly: true, diff --git a/src/commands/dev/superUser.ts b/src/commands/dev/superUser.ts index 17d81ac..e0328db 100644 --- a/src/commands/dev/superUser.ts +++ b/src/commands/dev/superUser.ts @@ -7,14 +7,27 @@ export default class SuperUserCommand extends BushCommand { super('superuser', { aliases: ['superuser', 'su'], category: 'dev', - description: { - content: 'A command to manage superusers.', - usage: ['superuser '], - examples: ['superuser add IRONM00N'] - }, + description: 'A command to manage superusers.', + usage: ['superuser '], + examples: ['superuser add IRONM00N'], clientPermissions: (m) => util.clientSendAndPermCheck(m), userPermissions: [], - ownerOnly: true + ownerOnly: true, + helpArgs: [ + { + id: 'action', + description: 'Whether to add or remove a user from the superuser list.', + readableType: 'add|remove', + slashType: false + }, + { + id: 'user', + description: 'The user to add/remove from the superuser list.', + type: 'user', + match: 'restContent', + slashType: false + } + ] }); } diff --git a/src/commands/dev/test.ts b/src/commands/dev/test.ts index 83dd592..f3ac627 100644 --- a/src/commands/dev/test.ts +++ b/src/commands/dev/test.ts @@ -13,21 +13,18 @@ export default class TestCommand extends BushCommand { super('test', { aliases: ['test'], category: 'dev', - description: { - content: 'A command to stuff.', - usage: ['test [feature]'], - examples: ['test lots of buttons', 'test buttons'] - }, + description: 'A command to test stuff.', + usage: ['test [feature]'], + examples: ['test lots of buttons', 'test buttons'], args: [ { id: 'feature', - type: 'string', + description: 'The feature to test.', match: 'rest', - prompt: { - start: 'start prompt', - retry: 'retry prompt', - optional: true - } + prompt: 'start prompt', + retry: 'retry prompt', + optional: true, + slashType: false } ], superUserOnly: true, diff --git a/src/commands/fun/coinflip.ts b/src/commands/fun/coinflip.ts index 83de5ba..cd436f8 100644 --- a/src/commands/fun/coinflip.ts +++ b/src/commands/fun/coinflip.ts @@ -5,11 +5,9 @@ export default class CoinFlipCommand extends BushCommand { super('coinflip', { aliases: ['coinflip', 'cf'], category: 'fun', - description: { - content: 'Flip a virtual coin.', - usage: ['coinflip'], - examples: ['coinflip'] - }, + description: 'Flip a virtual coin.', + usage: ['coinflip'], + examples: ['coinflip'], clientPermissions: (m) => util.clientSendAndPermCheck(m), userPermissions: [], slash: true diff --git a/src/commands/fun/dice.ts b/src/commands/fun/dice.ts index 74f387e..2f96e1c 100644 --- a/src/commands/fun/dice.ts +++ b/src/commands/fun/dice.ts @@ -5,11 +5,9 @@ export default class EightBallCommand extends BushCommand { super('dice', { aliases: ['dice', 'die'], category: 'fun', - description: { - content: 'Roll virtual dice.', - usage: ['dice'], - examples: ['dice'] - }, + description: 'Roll virtual dice.', + usage: ['dice'], + examples: ['dice'], clientPermissions: (m) => util.clientSendAndPermCheck(m), userPermissions: [], slash: true diff --git a/src/commands/fun/eightBall.ts b/src/commands/fun/eightBall.ts index fc662ad..d6b0b8c 100644 --- a/src/commands/fun/eightBall.ts +++ b/src/commands/fun/eightBall.ts @@ -5,31 +5,21 @@ export default class EightBallCommand extends BushCommand { super('eightBall', { aliases: ['8ball', 'eightball'], category: 'fun', - description: { - content: 'Ask questions for a randomly generated response.', - usage: ['8Ball '], - examples: ['8Ball does anyone love me?'] - }, + description: 'Ask questions for a randomly generated response.', + usage: ['8Ball '], + examples: ['8Ball does anyone love me?'], args: [ { id: 'question', + description: 'The question to have answered.', type: 'string', match: 'rest', - prompt: { - start: 'What question would you like answered?', - retry: '{error} Invalid question.' - } + prompt: 'What question would you like answered?', + retry: '{error} Invalid question.', + slashType: 'STRING' } ], slash: true, - slashOptions: [ - { - name: 'question', - description: 'What question would you like answered?', - type: 'STRING', - required: true - } - ], clientPermissions: (m) => util.clientSendAndPermCheck(m), userPermissions: [] }); diff --git a/src/commands/fun/minesweeper.ts b/src/commands/fun/minesweeper.ts index 9b511a3..7ef1de7 100644 --- a/src/commands/fun/minesweeper.ts +++ b/src/commands/fun/minesweeper.ts @@ -6,58 +6,60 @@ export default class MinesweeperCommand extends BushCommand { super('minesweeper', { aliases: ['minesweeper'], category: 'fun', - description: { - content: 'minesweeper command.', - usage: ['minesweeper [--spaces] [--revealFirstCell]'], - examples: ['minesweeper 10 10 2'] - }, + description: 'minesweeper command.', + usage: ['minesweeper [--spaces] [--revealFirstCell]'], + examples: ['minesweeper 10 10 2'], args: [ { id: 'rows', + description: 'The number of rows to generate.', type: 'integer', - prompt: { - start: 'How many rows would you like?', - retry: '{error} Choose a valid number of rows', - optional: true - }, - default: 9 + prompt: 'How many rows would you like?', + retry: '{error} Choose a valid number of rows', + optional: true, + default: 9, + slashType: 'INTEGER' }, { id: 'columns', + description: 'The number of columns to generate.', type: 'integer', - prompt: { - start: 'How many columns would you like?', - retry: '{error} Choose a valid number of columns', - optional: true - }, - default: 9 + prompt: 'How many columns would you like?', + retry: '{error} Choose a valid number of columns', + optional: true, + default: 9, + slashType: 'INTEGER' }, { id: 'mines', + description: 'The number of mines to generate.', type: 'integer', - prompt: { - start: 'How many mines would you like?', - retry: '{error} Choose a valid number of mines', - optional: true - }, - default: 10 + prompt: 'How many mines would you like?', + retry: '{error} Choose a valid number of mines', + optional: true, + default: 10, + slashType: 'INTEGER' }, - { id: 'spaces', match: 'flag', flag: '--spaces' }, - { id: 'reveal_first_cell', match: 'flag', flag: '--revealFirstCell' } - ], - slash: true, - slashOptions: [ - { name: 'rows', description: 'How many rows would you like?', type: 'INTEGER', required: false }, - { name: 'columns', description: 'How many rows would you like?', type: 'INTEGER', required: false }, - { name: 'mines', description: 'How many rows would you like?', type: 'INTEGER', required: false }, - { name: 'spaces', description: 'Would you like there to be spaces?', type: 'BOOLEAN', required: false }, { - name: 'reveal_first_cell', - description: 'Would you like to automatically reveal the first cell?', - type: 'BOOLEAN', - required: false + id: 'spaces', + description: 'Whether or not to put a space between cells.', + match: 'flag', + flag: '--spaces', + prompt: 'Would you like there to be spaces?', + slashType: 'BOOLEAN', + optional: true + }, + { + id: 'reveal_first_cell', + description: 'Whether or not to reveal the first cell automatically.', + match: 'flag', + flag: '--revealFirstCell', + prompt: 'Would you like to automatically reveal the first cell?', + slashType: 'BOOLEAN', + optional: true } ], + slash: true, clientPermissions: (m) => util.clientSendAndPermCheck(m), userPermissions: [] }); diff --git a/src/commands/info/avatar.ts b/src/commands/info/avatar.ts index e8b213f..87ea0cc 100644 --- a/src/commands/info/avatar.ts +++ b/src/commands/info/avatar.ts @@ -6,33 +6,24 @@ export default class AvatarCommand extends BushCommand { super('avatar', { aliases: ['avatar', 'av'], category: 'info', - description: { - content: "A command to get a user's avatar", - usage: ['avatar [user]'], - examples: ['avatar', 'av IRONM00N'] - }, + description: "A command to get a user's avatar", + usage: ['avatar [user]'], + examples: ['avatar', 'av IRONM00N'], args: [ { id: 'user', + description: 'The user you would like to find the avatar of.', customType: util.arg.union('member', 'globalUser'), - prompt: { - start: 'Who would you like to see the avatar of?', - retry: '{error} Choose a valid user.', - optional: true - } + readableType: 'member|user', + prompt: 'Who would you like to see the avatar of?', + retry: '{error} Choose a valid user.', + optional: true, + slashType: 'USER' } ], clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), userPermissions: [], - slash: true, - slashOptions: [ - { - name: 'user', - description: 'The user you would like to find the avatar of.', - type: 'USER', - required: false - } - ] + slash: true }); } diff --git a/src/commands/info/botInfo.ts b/src/commands/info/botInfo.ts index 833ed96..56885c5 100644 --- a/src/commands/info/botInfo.ts +++ b/src/commands/info/botInfo.ts @@ -8,11 +8,9 @@ export default class BotInfoCommand extends BushCommand { super('botInfo', { aliases: ['bot-info', 'stats'], category: 'info', - description: { - content: 'Shows information about the bot', - usage: ['bot-info'], - examples: ['bot-info'] - }, + description: 'Shows information about the bot', + usage: ['bot-info'], + examples: ['bot-info'], slash: true, clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), userPermissions: [] diff --git a/src/commands/info/color.ts b/src/commands/info/color.ts index 8fed7da..cb612b5 100644 --- a/src/commands/info/color.ts +++ b/src/commands/info/color.ts @@ -14,20 +14,19 @@ export default class ColorCommand extends BushCommand { super('color', { aliases: ['color'], category: 'info', - description: { - content: 'Find the color of a hex code, user, or role.', - usage: ['color '], - examples: ['color #0000FF'] - }, + description: 'Find the color of a hex code, user, or role.', + usage: ['color '], + examples: ['color #0000FF'], args: [ { id: 'color', + description: 'The color string, role, or member to find the color of.', customType: Argument.union(isValidTinyColor, 'role', 'member'), + readableType: 'color|role|member', match: 'restContent', - prompt: { - start: 'What color code, role, or user would you like to find the color of?', - retry: '{error} Choose a valid color, role, or member.' - } + prompt: 'What color code, role, or user would you like to find the color of?', + retry: '{error} Choose a valid color, role, or member.', + slashType: 'STRING' } ], channel: 'guild', @@ -41,16 +40,23 @@ export default class ColorCommand extends BushCommand { } public override async exec(message: BushMessage | BushSlashMessage, args: { color: string | BushRole | BushGuildMember }) { + const _color = message.util.isSlashMessage(message) + ? ((await util.arg.cast(Argument.union(isValidTinyColor, 'role', 'member'), message, args.color as string)) as + | string + | BushRole + | BushGuildMember) + : args.color; + const color = - typeof args.color === 'string' - ? tinycolor(args.color) - : args.color instanceof Role - ? tinycolor(args.color.hexColor) - : tinycolor(args.color.displayHexColor); + typeof _color === 'string' + ? tinycolor(_color) + : _color instanceof Role + ? tinycolor(_color.hexColor) + : tinycolor(_color.displayHexColor); - if (args.color instanceof Role && args.color.hexColor === '#000000') { + if (_color instanceof Role && _color.hexColor === '#000000') { return await message.util.reply({ - content: `${util.emojis.error} <@&${args.color.id}> does not have a color.`, + content: `${util.emojis.error} <@&${_color.id}> does not have a color.`, allowedMentions: AllowedMentions.none() }); } diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts index 47a8281..a38a446 100644 --- a/src/commands/info/guildInfo.ts +++ b/src/commands/info/guildInfo.ts @@ -14,31 +14,22 @@ export default class GuildInfoCommand extends BushCommand { super('guildInfo', { aliases: ['guild-info', 'serverinfo', 'guild', 'server', 'g'], category: 'info', - description: { - content: 'Get info about a server.', - usage: ['guild-info [guild]'], - examples: ['guild-info 516977525906341928'] - }, + description: 'Get info about a server.', + usage: ['guild-info [guild]'], + examples: ['guild-info 516977525906341928'], args: [ { id: 'guild', + description: 'The guild to find information about.', customType: util.arg.union('guild', 'snowflake'), - prompt: { - start: 'What server would you like to find information about?', - retry: '{error} Choose a valid server to find information about.', - optional: true - } + readableType: 'guild|snowflake', + prompt: 'What server would you like to find information about?', + retry: '{error} Choose a valid server to find information about.', + optional: true, + slashType: 'STRING' } ], slash: true, - slashOptions: [ - { - name: 'guild', - description: 'The id of the guild you would like to find information about.', - type: 'STRING', - required: false - } - ], clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), userPermissions: [] }); @@ -67,23 +58,15 @@ export default class GuildInfoCommand extends BushCommand { const guildStats: string[] = []; const guildSecurity: string[] = []; const verifiedGuilds = Object.values(client.consts.mappings.guilds); - if (verifiedGuilds.includes(guild.id)) emojis.push(otherEmojis.BUSH_VERIFIED); + if (verifiedGuilds.includes(guild.id as typeof verifiedGuilds[number])) emojis.push(otherEmojis.BUSH_VERIFIED); if (!isPreview && guild instanceof Guild) { if (guild.premiumTier !== 'NONE') emojis.push(otherEmojis[`BOOST_${guild.premiumTier}`]); await guild.fetch(); const channels = guild.channels.cache; - type ChannelType = - | 'GUILD_TEXT' - | 'GUILD_NEWS' - | 'GUILD_VOICE' - | 'GUILD_STAGE_VOICE' - | 'GUILD_STORE' - | 'GUILD_CATEGORY' - | 'THREAD'; const channelTypes = ( - ['GUILD_TEXT', 'GUILD_VOICE', 'GUILD_STAGE_VOICE', 'GUILD_STORE', 'GUILD_CATEGORY', 'THREAD'] as ChannelType[] + ['GUILD_TEXT', 'GUILD_VOICE', 'GUILD_STAGE_VOICE', 'GUILD_STORE', 'GUILD_CATEGORY', 'THREAD'] as const ).map((type) => `${otherEmojis[type]} ${channels.filter((channel) => channel.type.includes(type)).size.toLocaleString()}`); const guildRegions = [ @@ -113,18 +96,18 @@ export default class GuildInfoCommand extends BushCommand { if (guild.banner) guildAbout.push(`**Banner:** [link](${guild.bannerURL({ size: 4096, format: 'png' })})`); if (guild.splash) guildAbout.push(`**Splash:** [link](${guild.splashURL({ size: 4096, format: 'png' })})`); - enum EmojiTierMap { - TIER_3 = 500, - TIER_2 = 300, - TIER_1 = 100, - NONE = 50 - } - enum StickerTierMap { - TIER_3 = 60, - TIER_2 = 30, - TIER_1 = 15, - NONE = 0 - } + const EmojiTierMap = { + TIER_3: 500, + TIER_2: 300, + TIER_1: 100, + NONE: 50 + } as const; + const StickerTierMap = { + TIER_3: 60, + TIER_2: 30, + TIER_1: 15, + NONE: 0 + } as const; guildStats.push( `**Channels:** ${guild.channels.cache.size.toLocaleString()} / 500 (${channelTypes.join(', ')})`, diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts index 3bf8f5e..3b7883f 100644 --- a/src/commands/info/help.ts +++ b/src/commands/info/help.ts @@ -7,33 +7,32 @@ export default class HelpCommand extends BushCommand { super('help', { aliases: ['help'], category: 'info', - description: { - content: 'Displays a list of commands, or detailed information for a specific command.', - usage: ['help [command]'], - examples: ['help prefix'] - }, + description: 'Displays a list of commands, or detailed information for a specific command.', + usage: ['help [command]'], + examples: ['help prefix'], args: [ { id: 'command', + description: 'The command to show info about.', type: 'commandAlias', match: 'content', - prompt: { - start: 'What command do you need help with?', - retry: '{error} Choose a valid command to find help for.', - optional: true - } + prompt: 'What command do you need help with?', + retry: '{error} Choose a valid command to find help for.', + slashType: 'STRING', + optional: true }, - { id: 'showHidden', match: 'flag', flag: '--hidden' } - ], - slash: true, - slashOptions: [ { - name: 'command', - description: 'What command do you need help with?', - type: 'STRING', - required: false + id: 'showHidden', + description: 'Whether ot not to show hidden commands as well.', + match: 'flag', + flag: '--hidden', + slashType: 'BOOLEAN', + ownerOnly: true, + only: 'text', + optional: true } ], + slash: true, clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), userPermissions: [] }); @@ -80,17 +79,17 @@ export default class HelpCommand extends BushCommand { const embed = new MessageEmbed() .setColor(util.colors.default) .setTitle(`${command.id} Command`) - .setDescription(`${command.description?.content ?? '*This command does not have a description.*'}`); - if (command.description?.usage?.length) { + .setDescription(`${command.description ?? '*This command does not have a description.*'}`); + if (command.usage?.length) { embed.addField( - `» Usage${command.description.usage.length > 1 ? 's' : ''}`, - command.description.usage.map((u) => `\`${u}\``).join('\n') + `» Usage${command.usage.length > 1 ? 's' : ''}`, + command.usage.map((u) => `\`${u}\``).join('\n') ); } - if (command.description?.examples?.length) { + if (command.examples?.length) { embed.addField( - `» Example${command.description.examples.length > 1 ? 's' : ''}`, - command.description.examples.map((u) => `\`${u}\``).join('\n') + `» Example${command.examples.length > 1 ? 's' : ''}`, + command.examples.map((u) => `\`${u}\``).join('\n') ); } if (command.aliases?.length > 1) embed.addField('» Aliases', `\`${command.aliases.join('` `')}\``); diff --git a/src/commands/info/icon.ts b/src/commands/info/icon.ts index 2a04a65..42b7fa4 100644 --- a/src/commands/info/icon.ts +++ b/src/commands/info/icon.ts @@ -6,11 +6,9 @@ export default class IconCommand extends BushCommand { super('icon', { aliases: ['icon', 'guildavatar', 'severicon', 'guildicon'], category: 'info', - description: { - content: "A command to get the server's icon", - usage: ['icon'], - examples: ['icon'] - }, + description: "A command to get the server's icon", + usage: ['icon'], + examples: ['icon'], clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), userPermissions: [], channel: 'guild', diff --git a/src/commands/info/links.ts b/src/commands/info/links.ts index 935dca0..3f82245 100644 --- a/src/commands/info/links.ts +++ b/src/commands/info/links.ts @@ -7,11 +7,9 @@ export default class LinksCommand extends BushCommand { super('links', { aliases: ['links', 'invite', 'support'], category: 'info', - description: { - content: 'Sends bot links', - usage: ['links'], - examples: ['links'] - }, + description: 'Sends bot links', + usage: ['links'], + examples: ['links'], clientPermissions: (m) => util.clientSendAndPermCheck(m), userPermissions: [], slash: true diff --git a/src/commands/info/ping.ts b/src/commands/info/ping.ts index 1d3f75a..619971f 100644 --- a/src/commands/info/ping.ts +++ b/src/commands/info/ping.ts @@ -6,11 +6,9 @@ export default class PingCommand extends BushCommand { super('ping', { aliases: ['ping'], category: 'info', - description: { - content: 'Gets the latency of the bot', - usage: ['ping'], - examples: ['ping'] - }, + description: 'Gets the latency of the bot', + usage: ['ping'], + examples: ['ping'], slash: true, clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), userPermissions: [] diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts index 3cf27b6..29cd2ce 100644 --- a/src/commands/inf