aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-01-23 18:13:05 -0500
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-01-23 18:13:05 -0500
commita3f8d3884a1deca5eccfb6d990e2a7b42fbbe08a (patch)
tree9b0f8ed8a93c22c90512751e3f2f5937e1925760 /src/commands
parent5557677f1570eb564a30cfcebb6030235dc84d47 (diff)
downloadtanzanite-a3f8d3884a1deca5eccfb6d990e2a7b42fbbe08a.tar.gz
tanzanite-a3f8d3884a1deca5eccfb6d990e2a7b42fbbe08a.tar.bz2
tanzanite-a3f8d3884a1deca5eccfb6d990e2a7b42fbbe08a.zip
fix discord.js breaking changes, some other stuff
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/_fake-command/ironmoon.ts1
-rw-r--r--src/commands/admin/channelPermissions.ts14
-rw-r--r--src/commands/admin/roleAll.ts12
-rw-r--r--src/commands/config/_customAutomodPhrases.ts7
-rw-r--r--src/commands/config/blacklist.ts8
-rw-r--r--src/commands/config/config.ts69
-rw-r--r--src/commands/config/disable.ts8
-rw-r--r--src/commands/config/features.ts41
-rw-r--r--src/commands/config/log.ts9
-rw-r--r--src/commands/dev/__template.ts5
-rw-r--r--src/commands/dev/debug.ts79
-rw-r--r--src/commands/dev/dm.ts6
-rw-r--r--src/commands/dev/eval.ts39
-rw-r--r--src/commands/dev/javascript.ts10
-rw-r--r--src/commands/dev/reload.ts2
-rw-r--r--src/commands/dev/say.ts3
-rw-r--r--src/commands/dev/sh.ts7
-rw-r--r--src/commands/dev/test.ts75
-rw-r--r--src/commands/fun/eightBall.ts3
-rw-r--r--src/commands/fun/minesweeper.ts11
-rw-r--r--src/commands/info/avatar.ts6
-rw-r--r--src/commands/info/botInfo.ts4
-rw-r--r--src/commands/info/color.ts6
-rw-r--r--src/commands/info/guildInfo.ts88
-rw-r--r--src/commands/info/help.ts46
-rw-r--r--src/commands/info/icon.ts5
-rw-r--r--src/commands/info/links.ts31
-rw-r--r--src/commands/info/ping.ts8
-rw-r--r--src/commands/info/pronouns.ts6
-rw-r--r--src/commands/info/snowflake.ts60
-rw-r--r--src/commands/info/userInfo.ts30
-rw-r--r--src/commands/leveling/leaderboard.ts6
-rw-r--r--src/commands/leveling/level.ts6
-rw-r--r--src/commands/leveling/levelRoles.ts9
-rw-r--r--src/commands/leveling/setLevel.ts7
-rw-r--r--src/commands/leveling/setXp.ts7
-rw-r--r--src/commands/moderation/_activePunishments.ts10
-rw-r--r--src/commands/moderation/ban.ts14
-rw-r--r--src/commands/moderation/block.ts11
-rw-r--r--src/commands/moderation/evidence.ts7
-rw-r--r--src/commands/moderation/hideCase.ts5
-rw-r--r--src/commands/moderation/kick.ts11
-rw-r--r--src/commands/moderation/lockdown.ts16
-rw-r--r--src/commands/moderation/modlog.ts8
-rw-r--r--src/commands/moderation/mute.ts11
-rw-r--r--src/commands/moderation/purge.ts15
-rw-r--r--src/commands/moderation/removeReactionEmoji.ts11
-rw-r--r--src/commands/moderation/role.ts19
-rw-r--r--src/commands/moderation/slowmode.ts17
-rw-r--r--src/commands/moderation/timeout.ts11
-rw-r--r--src/commands/moderation/unban.ts12
-rw-r--r--src/commands/moderation/unblock.ts11
-rw-r--r--src/commands/moderation/unlockdown.ts13
-rw-r--r--src/commands/moderation/unmute.ts11
-rw-r--r--src/commands/moderation/untimeout.ts11
-rw-r--r--src/commands/moderation/warn.ts9
-rw-r--r--src/commands/moulberry-bush/capePermissions.ts6
-rw-r--r--src/commands/moulberry-bush/capes.ts7
-rw-r--r--src/commands/moulberry-bush/giveawayPing.ts15
-rw-r--r--src/commands/moulberry-bush/moulHammer.ts6
-rw-r--r--src/commands/moulberry-bush/report.ts11
-rw-r--r--src/commands/moulberry-bush/rule.ts10
-rw-r--r--src/commands/moulberry-bush/serverStatus.ts5
-rw-r--r--src/commands/utilities/activity.ts10
-rw-r--r--src/commands/utilities/calculator.ts6
-rw-r--r--src/commands/utilities/decode.ts8
-rw-r--r--src/commands/utilities/hash.ts4
-rw-r--r--src/commands/utilities/price.ts9
-rw-r--r--src/commands/utilities/remind.ts3
-rw-r--r--src/commands/utilities/reminders.ts5
-rw-r--r--src/commands/utilities/steal.ts13
-rw-r--r--src/commands/utilities/uuid.ts5
-rw-r--r--src/commands/utilities/viewRaw.ts16
-rw-r--r--src/commands/utilities/whoHasRole.ts5
-rw-r--r--src/commands/utilities/wolframAlpha.ts8
75 files changed, 633 insertions, 486 deletions
diff --git a/src/commands/_fake-command/ironmoon.ts b/src/commands/_fake-command/ironmoon.ts
index 428b554..1f63c06 100644
--- a/src/commands/_fake-command/ironmoon.ts
+++ b/src/commands/_fake-command/ironmoon.ts
@@ -12,6 +12,7 @@ export default class IronmoonCommand extends BushCommand {
userPermissions: []
});
}
+
public override condition(message: BushMessage): boolean {
return false;
if (message.content.toLowerCase().includes('ironmoon')) return true;
diff --git a/src/commands/admin/channelPermissions.ts b/src/commands/admin/channelPermissions.ts
index 026f1a6..f0d2c65 100644
--- a/src/commands/admin/channelPermissions.ts
+++ b/src/commands/admin/channelPermissions.ts
@@ -1,5 +1,5 @@
import { BushCommand, ButtonPaginator, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
-import { MessageEmbed } from 'discord.js';
+import { ApplicationCommandOptionType, MessageEmbed, Permissions } from 'discord.js';
export default class ChannelPermissionsCommand extends BushCommand {
public constructor() {
@@ -18,7 +18,7 @@ export default class ChannelPermissionsCommand extends BushCommand {
readableType: 'member|role',
prompt: 'What user/role would you like to change?',
retry: '{error} Choose a valid user/role to change.',
- slashType: 'MENTIONABLE'
+ slashType: ApplicationCommandOptionType.Mentionable
},
{
id: 'permission',
@@ -26,7 +26,7 @@ export default class ChannelPermissionsCommand extends BushCommand {
type: 'permission',
prompt: 'What permission would you like to change?',
retry: '{error} Choose a valid permission.',
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
},
{
id: 'state',
@@ -39,7 +39,7 @@ export default class ChannelPermissionsCommand extends BushCommand {
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',
+ slashType: ApplicationCommandOptionType.String,
choices: [
{ name: 'Enabled', value: 'true' },
{ name: 'Disabled', value: 'false' },
@@ -47,8 +47,8 @@ export default class ChannelPermissionsCommand extends BushCommand {
]
}
],
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_CHANNELS']),
- userPermissions: ['ADMINISTRATOR'],
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_CHANNELS]),
+ userPermissions: [Permissions.FLAGS.ADMINISTRATOR],
channel: 'guild',
slash: true
});
@@ -63,7 +63,7 @@ export default class ChannelPermissionsCommand extends BushCommand {
}
) {
if (!message.inGuild()) 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())
+ if (!message.member!.permissions.has(Permissions.FLAGS.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();
diff --git a/src/commands/admin/roleAll.ts b/src/commands/admin/roleAll.ts
index 6e82011..3b438d9 100644
--- a/src/commands/admin/roleAll.ts
+++ b/src/commands/admin/roleAll.ts
@@ -1,5 +1,5 @@
import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
-import { type GuildMember } from 'discord.js';
+import { ApplicationCommandOptionType, Permissions, type GuildMember } from 'discord.js';
export default class RoleAllCommand extends BushCommand {
public constructor() {
@@ -16,7 +16,7 @@ export default class RoleAllCommand extends BushCommand {
type: 'role',
prompt: 'What role would you like to give to every member on the server?',
retry: '{error} Pick a valid role.',
- slashType: 'ROLE'
+ slashType: ApplicationCommandOptionType.Role
},
{
id: 'bots',
@@ -25,13 +25,13 @@ export default class RoleAllCommand extends BushCommand {
prompt: 'Would you like to also give roles to bots?',
flag: '--bots',
default: false,
- slashType: 'BOOLEAN',
+ slashType: ApplicationCommandOptionType.Boolean,
optional: true
}
],
channel: 'guild',
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_ROLES']),
- userPermissions: ['ADMINISTRATOR'],
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_ROLES]),
+ userPermissions: [Permissions.FLAGS.ADMINISTRATOR],
typing: true,
slash: true
});
@@ -39,7 +39,7 @@ export default class RoleAllCommand extends BushCommand {
public override async exec(message: BushMessage | BushSlashMessage, args: { role: ArgType<'role'>; bots: ArgType<'boolean'> }) {
if (!message.inGuild()) 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())
+ if (!message.member!.permissions.has(Permissions.FLAGS.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();
diff --git a/src/commands/config/_customAutomodPhrases.ts b/src/commands/config/_customAutomodPhrases.ts
index cd59c9a..1c91f28 100644
--- a/src/commands/config/_customAutomodPhrases.ts
+++ b/src/commands/config/_customAutomodPhrases.ts
@@ -1,4 +1,5 @@
// import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
+// import { Permissions } from 'discord.js';
// export default class CustomAutomodPhrasesCommand extends BushCommand {
// public constructor() {
@@ -15,7 +16,7 @@
// 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'
+// slashType: ApplicationCommandOptionType.String
// },
// {
// id: 'optional_argument',
@@ -24,13 +25,13 @@
// prompt: 'What would you like to set your second argument to be?',
// retry: '{error} Pick a valid argument.',
// optional: true,
-// slashType: 'STRING'
+// slashType: ApplicationCommandOptionType.String
// }
// ],
// slash: true,
// channel: 'guild',
// clientPermissions: (m) => util.clientSendAndPermCheck(m),
-// userPermissions: ['MANAGE_GUILD']
+// userPermissions: [Permissions.FLAGS.MANAGE_GUILD]
// });
// }
diff --git a/src/commands/config/blacklist.ts b/src/commands/config/blacklist.ts
index d15b8d7..0498b87 100644
--- a/src/commands/config/blacklist.ts
+++ b/src/commands/config/blacklist.ts
@@ -1,5 +1,5 @@
import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
-import { User } from 'discord.js';
+import { ApplicationCommandOptionType, Permissions, User } from 'discord.js';
export default class BlacklistCommand extends BushCommand {
public constructor() {
@@ -15,7 +15,7 @@ export default class BlacklistCommand extends BushCommand {
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',
+ slashType: ApplicationCommandOptionType.String,
choices: ['blacklist', 'unblacklist'].map((c) => ({ name: c, value: c })),
only: 'slash'
},
@@ -26,7 +26,7 @@ export default class BlacklistCommand extends BushCommand {
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'
+ slashType: ApplicationCommandOptionType.String
},
{
id: 'global',
@@ -42,7 +42,7 @@ export default class BlacklistCommand extends BushCommand {
slash: true,
channel: 'guild',
clientPermissions: (m) => util.clientSendAndPermCheck(m),
- userPermissions: ['MANAGE_GUILD']
+ userPermissions: [Permissions.FLAGS.MANAGE_GUILD]
});
}
diff --git a/src/commands/config/config.ts b/src/commands/config/config.ts
index 6e08cc3..41bdc04 100644
--- a/src/commands/config/config.ts
+++ b/src/commands/config/config.ts
@@ -9,16 +9,20 @@ import {
type GuildSettingType
} from '#lib';
import assert from 'assert';
-import { type ArgumentOptions, type Flag } from 'discord-akairo';
+import { SlashOption, type ArgumentOptions, type Flag } from 'discord-akairo';
import {
+ ActionRow,
+ ApplicationCommandOptionType,
+ ButtonComponent,
+ ButtonStyle,
Channel,
Formatters,
GuildMember,
- MessageActionRow,
- MessageButton,
MessageEmbed,
- MessageSelectMenu,
+ Permissions,
Role,
+ SelectMenuComponent,
+ SelectMenuOption,
User,
type Message,
type MessageComponentInteraction,
@@ -37,33 +41,45 @@ export default class ConfigCommand extends BushCommand {
],
examples: ['settings', 'config prefix set -'],
slash: true,
- slashOptions: settingsArr.map((setting) => {
+ slashOptions: settingsArr.map((setting): SlashOption => {
const obj = guildSettingsObj[setting];
const type = obj.type;
const baseTypeUpper = type.replace('-array', '').toUpperCase() as SlashArgType;
const isArray = type.includes('-array');
const loweredName = obj.name.toLowerCase();
+ const enumType =
+ baseTypeUpper === 'CHANNEL'
+ ? ApplicationCommandOptionType.Channel
+ : baseTypeUpper === 'ROLE'
+ ? ApplicationCommandOptionType.Role
+ : baseTypeUpper === 'STRING'
+ ? ApplicationCommandOptionType.String
+ : baseTypeUpper === 'USER'
+ ? ApplicationCommandOptionType.User
+ : new Error(`Unknown type: ${type}`);
+ if (enumType instanceof Error) throw enumType;
+
return {
name: _.snakeCase(setting),
description: `Manage the server's ${loweredName}`,
- type: 'SUB_COMMAND_GROUP',
+ type: ApplicationCommandOptionType.SubcommandGroup,
options: isArray
? [
{
name: 'view',
description: `View the server's ${loweredName}.`,
- type: 'SUB_COMMAND'
+ type: ApplicationCommandOptionType.Subcommand
},
{
name: 'add',
description: `Add a value to the server's ${loweredName}.`,
- type: 'SUB_COMMAND',
+ type: ApplicationCommandOptionType.Subcommand,
options: [
{
name: 'value',
description: `What would you like to add to the server's ${loweredName}?'`,
- type: baseTypeUpper,
+ type: enumType,
channelTypes: baseTypeUpper === 'CHANNEL' && obj.subType ? obj.subType : undefined,
required: true
}
@@ -72,12 +88,12 @@ export default class ConfigCommand extends BushCommand {
{
name: 'remove',
description: `Remove a value from the server's ${loweredName}.`,
- type: 'SUB_COMMAND',
+ type: ApplicationCommandOptionType.Subcommand,
options: [
{
name: 'value',
description: `What would you like to remove from the server's ${loweredName}?'`,
- type: baseTypeUpper,
+ type: enumType,
channelTypes: baseTypeUpper === 'CHANNEL' && obj.subType ? obj.subType : undefined,
required: true
}
@@ -88,17 +104,17 @@ export default class ConfigCommand extends BushCommand {
{
name: 'view',
description: `View the server's ${loweredName}.`,
- type: 'SUB_COMMAND'
+ type: ApplicationCommandOptionType.Subcommand
},
{
name: 'set',
description: `Set the server's ${loweredName}.`,
- type: 'SUB_COMMAND',
+ type: ApplicationCommandOptionType.Subcommand,
options: [
{
name: 'value',
description: `What would you like to set the server's ${loweredName} to?'`,
- type: baseTypeUpper,
+ type: enumType,
channelTypes: baseTypeUpper === 'CHANNEL' && obj.subType ? obj.subType : undefined,
required: true
}
@@ -109,7 +125,7 @@ export default class ConfigCommand extends BushCommand {
}),
channel: 'guild',
clientPermissions: (m) => util.clientSendAndPermCheck(m),
- userPermissions: ['MANAGE_GUILD']
+ userPermissions: [Permissions.FLAGS.MANAGE_GUILD]
});
}
@@ -192,8 +208,8 @@ export default class ConfigCommand extends BushCommand {
}
) {
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(`${util.emojis.error} You must have the **MANAGE_GUILD** permission to run this command.`);
+ if (!message.member?.permissions.has(Permissions.FLAGS.MANAGE_GUILD) && !message.member?.user.isOwner())
+ return await message.util.reply(`${util.emojis.error} You must have the **Manage Server** permission to run this command.`);
const setting = message.util.isSlash ? (_.camelCase(args.subcommandGroup)! as GuildSettings) : args.setting!;
const action = message.util.isSlash ? args.subcommand! : args.action!;
const value = args.value;
@@ -278,14 +294,15 @@ export default class ConfigCommand extends BushCommand {
const desc = settingsArr.map((s) => `:wrench: **${guildSettingsObj[s].name}**`).join('\n');
settingsEmbed.setDescription(desc);
- const selMenu = new MessageActionRow().addComponents(
- new MessageSelectMenu()
+ const selMenu = new ActionRow().addComponents(
+ new SelectMenuComponent()
.addOptions(
- ...settingsArr.map((s) => ({
- label: guildSettingsObj[s].name,
- value: s,
- description: guildSettingsObj[s].description
- }))
+ ...settingsArr.map((s) =>
+ new SelectMenuOption()
+ .setLabel(guildSettingsObj[s].name)
+ .setValue(s)
+ .setDescription(guildSettingsObj[s].description)
+ )
)
.setPlaceholder('Select A Setting to View')
.setMaxValues(1)
@@ -335,8 +352,8 @@ export default class ConfigCommand extends BushCommand {
: '[No Value Set]';
};
- const components = new MessageActionRow().addComponents(
- new MessageButton().setStyle('PRIMARY').setCustomId('command_settingsBack').setLabel('Back')
+ const components = new ActionRow().addComponents(
+ new ButtonComponent().setStyle(ButtonStyle.Primary).setCustomId('command_settingsBack').setLabel('Back')
);
settingsEmbed.setDescription(
`${Formatters.italic(guildSettingsObj[setting].description)}\n\n**Type**: ${guildSettingsObj[setting].type}`
diff --git a/src/commands/config/disable.ts b/src/commands/config/disable.ts
index 564f90f..d59ff55 100644
--- a/src/commands/config/disable.ts
+++ b/src/commands/config/disable.ts
@@ -1,6 +1,6 @@
import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
import assert from 'assert';
-import { AutocompleteInteraction } from 'discord.js';
+import { ApplicationCommandOptionType, AutocompleteInteraction, Permissions } from 'discord.js';
import Fuse from 'fuse.js';
assert(Fuse);
@@ -20,7 +20,7 @@ export default class DisableCommand extends BushCommand {
description: 'Whether to disable or enable the command.',
readableType: "'disable'|'enable",
prompt: 'Would you like to disable or enable a command?',
- slashType: 'STRING',
+ slashType: ApplicationCommandOptionType.String,
choices: ['disable', 'enable'].map((v) => ({ name: v, value: v })),
only: 'slash'
},
@@ -31,7 +31,7 @@ export default class DisableCommand extends BushCommand {
readableType: 'command|commandAlias',
prompt: 'What command would you like to enable/disable?',
retry: '{error} Pick a valid command.',
- slashType: 'STRING',
+ slashType: ApplicationCommandOptionType.String,
autocomplete: true
},
{
@@ -48,7 +48,7 @@ export default class DisableCommand extends BushCommand {
slash: true,
channel: 'guild',
clientPermissions: (m) => util.clientSendAndPermCheck(m),
- userPermissions: ['MANAGE_GUILD']
+ userPermissions: [Permissions.FLAGS.MANAGE_GUILD]
});
}
diff --git a/src/commands/config/features.ts b/src/commands/config/features.ts
index 894c90a..fdd6c1e 100644
--- a/src/commands/config/features.ts
+++ b/src/commands/config/features.ts
@@ -6,7 +6,16 @@ import {
type BushSlashMessage,
type GuildFeatures
} from '#lib';
-import { MessageActionRow, MessageEmbed, MessageSelectMenu, type Message, type SelectMenuInteraction } from 'discord.js';
+import {
+ ActionRow,
+ ComponentType,
+ MessageEmbed,
+ Permissions,
+ SelectMenuComponent,
+ SelectMenuOption,
+ type Message,
+ type SelectMenuInteraction
+} from 'discord.js';
export default class FeaturesCommand extends BushCommand {
public constructor() {
@@ -18,8 +27,8 @@ export default class FeaturesCommand extends BushCommand {
examples: ['features'],
slash: true,
channel: 'guild',
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
- userPermissions: ['MANAGE_GUILD']
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
+ userPermissions: [Permissions.FLAGS.MANAGE_GUILD]
});
}
@@ -33,7 +42,7 @@ export default class FeaturesCommand extends BushCommand {
const components = this.generateComponents(guildFeaturesArr, false);
const msg = (await message.util.reply({ embeds: [featureEmbed], components: [components] })) as Message;
const collector = msg.createMessageComponentCollector({
- componentType: 'SELECT_MENU',
+ componentType: ComponentType.SelectMenu,
time: 300_000,
filter: (i) => i.guildId === msg.guildId && i.message?.id === msg.id
});
@@ -74,19 +83,17 @@ export default class FeaturesCommand extends BushCommand {
}
public generateComponents(guildFeatures: GuildFeatures[], disable: boolean) {
- return new MessageActionRow().addComponents(
- new MessageSelectMenu({
- customId: 'command_selectFeature',
- disabled: disable,
- maxValues: 1,
- minValues: 1,
- options: guildFeatures.map((f) => ({
- label: guildFeaturesObj[f].name,
- value: f,
- description: guildFeaturesObj[f].description
- })),
- placeholder: 'Select A Feature to Toggle'
- })
+ return new ActionRow().addComponents(
+ new SelectMenuComponent()
+ .setCustomId('command_selectFeature')
+ .setDisabled(disable)
+ .setMaxValues(1)
+ .setMinValues(1)
+ .setOptions(
+ guildFeatures.map((f) =>
+ new SelectMenuOption().setLabel(guildFeaturesObj[f].name).setValue(f).setDescription(guildFeaturesObj[f].description)
+ )
+ )
);
}
}
diff --git a/src/commands/config/log.ts b/src/commands/config/log.ts
index 3072866..5906623 100644
--- a/src/commands/config/log.ts
+++ b/src/commands/config/log.ts
@@ -1,5 +1,6 @@
import { BushCommand, guildLogsArr, type ArgType, type BushMessage, type BushSlashMessage, type GuildLogType } from '#lib';
import { type ArgumentOptions, type Flag } from 'discord-akairo';
+import { ApplicationCommandOptionType, Permissions } from 'discord.js';
export default class LogCommand extends BushCommand {
public constructor() {
@@ -15,7 +16,7 @@ export default class LogCommand extends BushCommand {
id: 'log_type',
description: 'The log type to change.',
prompt: 'What log type would you like to change?',
- slashType: 'STRING',
+ slashType: ApplicationCommandOptionType.String,
choices: guildLogsArr.map((log) => ({ name: log, value: log })),
only: 'slash'
},
@@ -24,14 +25,14 @@ export default class LogCommand extends BushCommand {
description: 'The channel to have logs of the selected 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'],
+ slashType: ApplicationCommandOptionType.Channel,
+ channelTypes: ['GuildText', 'GuildNews', 'GuildNewsThread', 'GuildPublicThread', 'GuildPrivateThread'],
only: 'slash'
}
],
channel: 'guild',
clientPermissions: (m) => util.clientSendAndPermCheck(m),
- userPermissions: ['MANAGE_GUILD']
+ userPermissions: [Permissions.FLAGS.MANAGE_GUILD]
});
}
diff --git a/src/commands/dev/__template.ts b/src/commands/dev/__template.ts
index 6adba08..7ea1784 100644
--- a/src/commands/dev/__template.ts
+++ b/src/commands/dev/__template.ts
@@ -1,4 +1,5 @@
import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage, type OptionalArgType } from '#lib';
+import { ApplicationCommandOptionType } from 'discord.js';
export default class TemplateCommand extends BushCommand {
public constructor() {
@@ -15,7 +16,7 @@ export default class TemplateCommand extends BushCommand {
type: 'string',
prompt: 'What would you like to set your first argument to be?',
retry: '{error} Pick a valid argument.',
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
},
{
id: 'optional_argument',
@@ -24,7 +25,7 @@ export default class TemplateCommand extends BushCommand {
prompt: 'What would you like to set your second argument to be?',
retry: '{error} Pick a valid argument.',
optional: true,
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
}
],
slash: false, //set this to true
diff --git a/src/commands/dev/debug.ts b/src/commands/dev/debug.ts
new file mode 100644
index 0000000..f8c614d
--- /dev/null
+++ b/src/commands/dev/debug.ts
@@ -0,0 +1,79 @@
+// import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+// import { ApplicationCommandOptionType, AutocompleteInteraction, ChatInputCommandInteraction } from 'discord.js';
+// import Fuse from 'fuse.js';
+
+// export default class DebugCommand extends BushCommand {
+// public constructor() {
+// super('debug', {
+// aliases: ['debug'],
+// category: 'debug',
+// description: 'Command description.',
+// usage: ['template <requiredArg> [optionalArg]'],
+// examples: ['template 1 2'],
+// args: [
+// {
+// id: 'action',
+// description: 'Debug action.',
+// type: 'string',
+// prompt: 'Debug action.',
+// retry: '{error} Pick valid action.',
+// slashType: ApplicationCommandOptionType.String,
+// autocomplete: true
+// }
+// ],
+// slash: true,
+// slashGuilds: ['516977525906341928'],
+// superUserOnly: true,
+// clientPermissions: (m) => util.clientSendAndPermCheck(m),
+// userPermissions: []
+// });
+// }
+
+// public override async exec(message: BushMessage | BushSlashMessage, args: { action: ArgType<'string'> }) {
+// if (args.action === 'util.reply') {
+// return await message.util.reply(`This is a util.reply`);
+// } else if (args.action === 'util.reply-object') {
+// return await message.util.reply({
+// content: `This is a util.reply with object parameters`,
+// embeds: [{ description: 'And an embed' }]
+// });
+// } else if (args.action === 'util.send') {
+// return await message.util.send(`This is a util.send`);
+// } else if (args.action === 'util.send-object') {
+// return await message.util.send({
+// content: `This is a util.send with object parameters`,
+// embeds: [{ description: 'And an embed' }]
+// });
+// } else if (args.action === 'interaction.reply') {
+// return await (message.interaction as ChatInputCommandInteraction).reply(`This is a interaction.reply`);
+// } else if (args.action === 'interaction.reply-object') {
+// return await (message.interaction as ChatInputCommandInteraction).reply({
+// content: `This is a interaction.reply with object parameters`,
+// embeds: [{ description: 'And an embed' }]
+// });
+// } else {
+// return await message.util.reply(`${util.emojis.error} Invalid action.`);
+// }
+// }
+
+// public override autocomplete(interaction: AutocompleteInteraction) {
+// const actions = [
+// 'util.reply',
+// 'util.reply-object',
+// 'util.send',
+// 'util.send-object',
+// 'interaction.reply',
+// 'interaction.reply-object'
+// ];
+
+// const fuzzy = new Fuse(actions, {
+// threshold: 0.5,
+// isCaseSensitive: false,
+// findAllMatches: true
+// }).search(interaction.options.getFocused().toString());
+
+// const res = fuzzy.slice(0, fuzzy.length >= 25 ? 25 : undefined).map((v) => ({ name: v.item, value: v.item }));
+
+// void interaction.respond(res.length ? res : actions.map((v) => ({ name: v, value: v })));
+// }
+// }
diff --git a/src/commands/dev/dm.ts b/src/commands/dev/dm.ts
index d702875..0646f59 100644
--- a/src/commands/dev/dm.ts
+++ b/src/commands/dev/dm.ts
@@ -1,4 +1,5 @@
import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { ApplicationCommandOptionType } from 'discord.js';
export default class DMCommand extends BushCommand {
public constructor() {
@@ -15,7 +16,7 @@ export default class DMCommand extends BushCommand {
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'
+ slashType: ApplicationCommandOptionType.String
},
{
id: 'content',
@@ -24,7 +25,7 @@ export default class DMCommand extends BushCommand {
description: 'The content to send to the user.',
prompt: 'What would you like to send to the user?',
retry: '{error} Pick something to send the user.',
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
}
],
slash: false,
@@ -34,6 +35,7 @@ export default class DMCommand extends BushCommand {
userPermissions: []
});
}
+
public override async exec(
message: BushMessage | BushSlashMessage,
args: { user: ArgType<'user'>; content: ArgType<'string'> }
diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts
index 656eeff..92b1117 100644
--- a/src/commands/dev/eval.ts
+++ b/src/commands/dev/eval.ts
@@ -12,26 +12,28 @@ import {
StickyRole,
type ArgType
} from '#lib';
+import { Snowflake as Snowflake_ } from '@sapphire/snowflake';
import { Canvas } from 'canvas';
import { exec } from 'child_process';
import {
+ ActionRow,
+ ApplicationCommandOptionType,
+ ButtonComponent,
ButtonInteraction,
Collection,
Collector,
CommandInteraction,
- ContextMenuInteraction,
+ ContextMenuCommandInteraction,
DMChannel,
Emoji,
Interaction,
InteractionCollector,
Message,
- MessageActionRow,
MessageAttachment,
- MessageButton,
MessageCollector,
MessageEmbed,
- MessageSelectMenu,
ReactionCollector,
+ SelectMenuComponent,
Util
} from 'discord.js';
import ts from 'typescript';
@@ -39,7 +41,8 @@ import { promisify } from 'util';
const { transpile } = ts,
emojis = util.emojis,
colors = util.colors,
- sh = promisify(exec);
+ sh = promisify(exec),
+ SnowflakeUtil = new Snowflake_(1420070400000n);
/* eslint-enable @typescript-eslint/no-unused-vars */
export default class EvalCommand extends BushCommand {
@@ -57,7 +60,7 @@ export default class EvalCommand extends BushCommand {
match: 'rest',
prompt: 'What would you like to eval?',
retry: '{error} Invalid code to eval.',
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
},
{
id: 'sel_depth',
@@ -67,7 +70,7 @@ export default class EvalCommand extends BushCommand {
flag: '--depth',
default: 0,
prompt: 'How deep would you like to inspect the output?',
- slashType: 'INTEGER',
+ slashType: ApplicationCommandOptionType.Integer,
optional: true
},
{
@@ -76,7 +79,7 @@ export default class EvalCommand extends BushCommand {
match: 'flag',
flag: '--sudo',
prompt: 'Would you like to override checks?',
- slashType: 'BOOLEAN',
+ slashType: ApplicationCommandOptionType.Boolean,
optional: true
},
{
@@ -95,7 +98,7 @@ export default class EvalCommand extends BushCommand {
match: 'flag',
flag: '--silent',
prompt: 'Would you like to make the response silent?',
- slashType: 'BOOLEAN',
+ slashType: ApplicationCommandOptionType.Boolean,
optional: true
},
{
@@ -104,7 +107,7 @@ export default class EvalCommand extends BushCommand {
match: 'flag',
flag: '--ts',
prompt: 'Is this code written in typescript?',
- slashType: 'BOOLEAN',
+ slashType: ApplicationCommandOptionType.Boolean,
optional: true
},
{
@@ -113,7 +116,7 @@ export default class EvalCommand extends BushCommand {
match: 'flag',
flag: '--hidden',
prompt: 'Would you like to show hidden items?',
- slashType: 'BOOLEAN',
+ slashType: ApplicationCommandOptionType.Boolean,
optional: true
},
{
@@ -122,7 +125,7 @@ export default class EvalCommand extends BushCommand {
match: 'flag',
flag: '--proto',
prompt: 'Would you like to show the prototype of the output?',
- slashType: 'BOOLEAN',
+ slashType: ApplicationCommandOptionType.Boolean,
optional: true
},
{
@@ -131,7 +134,7 @@ export default class EvalCommand extends BushCommand {
match: 'flag',
flag: ['--func', '--function', '--functions', '--meth', '--method', '--methods'],
prompt: 'Would you like to inspect the prototype chain to find methods?',
- slashType: 'BOOLEAN',
+ slashType: ApplicationCommandOptionType.Boolean,
optional: true
},
{
@@ -140,7 +143,7 @@ export default class EvalCommand extends BushCommand {
match: 'flag',
flag: '--async',
prompt: 'Would you like to wrap the code in an async function?',
- slashType: 'BOOLEAN',
+ slashType: ApplicationCommandOptionType.Boolean,
optional: true
},
{
@@ -149,7 +152,7 @@ export default class EvalCommand extends BushCommand {
match: 'flag',
flag: ['--strings', '--string'],
prompt: 'Would you like to not inspect strings?',
- slashType: 'BOOLEAN',
+ slashType: ApplicationCommandOptionType.Boolean,
optional: true
}
],
@@ -242,9 +245,7 @@ export default class EvalCommand extends BushCommand {
embed.addField('📤 Error', await util.inspectCleanRedactCodeblock(e, 'js'));
}
- embed
- .setTimestamp()
- .setFooter({ text: message.author.tag, iconURL: message.author.displayAvatarURL({ dynamic: true }) ?? undefined });
+ embed.setTimestamp().setFooter({ text: message.author.tag, iconURL: message.author.displayAvatarURL() ?? undefined });
if (!args.silent || message.util.isSlashMessage(message)) {
await message.util.reply({ embeds: [embed] });
@@ -260,4 +261,4 @@ export default class EvalCommand extends BushCommand {
}
}
-/** @typedef {ActivePunishment|Global|Guild|Level|ModLog|StickyRole|ButtonInteraction|Collection|Collector|CommandInteraction|ContextMenuInteraction|DMChannel|Emoji|Interaction|InteractionCollector|Message|MessageActionRow|MessageAttachment|MessageButton|MessageCollector|MessageSelectMenu|ReactionCollector|Util|Canvas|Shared} VSCodePleaseDontRemove */
+/** @typedef {ActivePunishment|Global|Guild|Level|ModLog|StickyRole|ButtonInteraction|Collection|Collector|CommandInteraction|ContextMenuCommandInteraction|DMChannel|Emoji|Interaction|InteractionCollector|Message|ActionRow|MessageAttachment|ButtonComponent|MessageCollector|SelectMenuComponent|ReactionCollector|Util|Canvas|Shared} VSCodePleaseDontRemove */
diff --git a/src/commands/dev/javascript.ts b/src/commands/dev/javascript.ts
index c8113aa..9d6a20b 100644
--- a/src/commands/dev/javascript.ts
+++ b/src/commands/dev/javascript.ts
@@ -1,6 +1,6 @@
import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
import assert from 'assert';
-import { MessageEmbed } from 'discord.js';
+import { ApplicationCommandOptionType, MessageEmbed } from 'discord.js';
import { VM } from 'vm2';
assert(VM);
@@ -19,7 +19,7 @@ export default class JavascriptCommand extends BushCommand {
match: 'rest',
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'
+ slashType: ApplicationCommandOptionType.String
},
{
id: 'sel_depth',
@@ -29,7 +29,7 @@ export default class JavascriptCommand extends BushCommand {
flag: '--depth',
default: 0,
prompt: 'How deep would you like to inspect the output?',
- slashType: 'INTEGER',
+ slashType: ApplicationCommandOptionType.Integer,
optional: true
}
],
@@ -75,9 +75,7 @@ export default class JavascriptCommand extends BushCommand {
embed.addField('📤 Error', await util.inspectCleanRedactCodeblock(e, 'js'));
}
- embed
- .setTimestamp()
- .setFooter({ text: message.author.tag, iconURL: message.author.displayAvatarURL({ dynamic: true }) ?? undefined });
+ embed.setTimestamp().setFooter({ text: message.author.tag, iconURL: message.author.displayAvatarURL() ?? undefined });
await message.util.reply({ embeds: [embed] });
}
diff --git a/src/commands/dev/reload.ts b/src/commands/dev/reload.ts
index 6d030b7..d874c83 100644
--- a/src/commands/dev/reload.ts
+++ b/src/commands/dev/reload.ts
@@ -16,7 +16,7 @@ export default class ReloadCommand extends BushCommand {
// flag: '--fast',
// prompt: 'Would you like to use esbuild for fast compiling?',
// optional: true,
- // slashType:'BOOLEAN'
+ // slashType: ApplicationCommandOptionType.Boolean
// }
// ],
ownerOnly: true,
diff --git a/src/commands/dev/say.ts b/src/commands/dev/say.ts
index 2c8151f..bbada0c 100644
--- a/src/commands/dev/say.ts
+++ b/src/commands/dev/say.ts
@@ -1,4 +1,5 @@
import { AllowedMentions, BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
+import { ApplicationCommandOptionType } from 'discord.js';
export default class SayCommand extends BushCommand {
public constructor() {
@@ -16,7 +17,7 @@ export default class SayCommand extends BushCommand {
match: 'rest',
prompt: 'What would you like the bot to say?',
retry: '{error} Choose something for the bot to send.',
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
}
],
ownerOnly: true,
diff --git a/src/commands/dev/sh.ts b/src/commands/dev/sh.ts
index 9956897..f74dedf 100644
--- a/src/commands/dev/sh.ts
+++ b/src/commands/dev/sh.ts
@@ -2,8 +2,9 @@ import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
import assert from 'assert';
import chalk from 'chalk';
import { exec } from 'child_process';
-import { MessageEmbed, Util } from 'discord.js';
+import { ApplicationCommandOptionType, MessageEmbed, Util } from 'discord.js';
import { promisify } from 'util';
+
assert(chalk);
const sh = promisify(exec);
@@ -30,7 +31,7 @@ export default class ShCommand extends BushCommand {
match: 'rest',
prompt: 'What would you like run',
retry: '{error} Invalid command to run.',
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
}
],
ownerOnly: true,
@@ -46,7 +47,7 @@ export default class ShCommand extends BushCommand {
const embed = new MessageEmbed()
.setColor(util.colors.gray)
- .setFooter({ text: message.author.tag, iconURL: message.author.avatarURL({ dynamic: true }) ?? undefined })
+ .setFooter({ text: message.author.tag, iconURL: message.author.avatarURL() ?? undefined })
.setTimestamp()
.setTitle('Shell Command')
.addField('📥 Input', await util.codeblock(input, 1024, 'sh', true))
diff --git a/src/commands/dev/test.ts b/src/commands/dev/test.ts
index 1ec7f71..63c1112 100644
--- a/src/commands/dev/test.ts
+++ b/src/commands/dev/test.ts
@@ -1,6 +1,13 @@
import { BushCommand, ButtonPaginator, Shared, type BushMessage } from '#lib';
-import { MessageActionRow, MessageButton, MessageEmbed, type ApplicationCommand, type Collection } from 'discord.js';
-import { MessageButtonStyles } from 'discord.js/typings/enums';
+import {
+ ActionRow,
+ ActionRowComponent,
+ ButtonComponent,
+ ButtonStyle,
+ MessageEmbed,
+ type ApplicationCommand,
+ type Collection
+} from 'discord.js';
import badLinksSecretArray from '../../lib/badlinks-secret.js';
import badLinksArray from '../../lib/badlinks.js';
import badWords from '../../lib/badwords.js';
@@ -44,12 +51,12 @@ export default class TestCommand extends BushCommand {
}
if (['button', 'buttons'].includes(args?.feature?.toLowerCase())) {
- const ButtonRow = new MessageActionRow().addComponents(
- new MessageButton({ style: MessageButtonStyles.PRIMARY, customId: 'primaryButton', label: 'Primary' }),
- new MessageButton({ style: MessageButtonStyles.SECONDARY, customId: 'secondaryButton', label: 'Secondary' }),
- new MessageButton({ style: MessageButtonStyles.SUCCESS, customId: 'success', label: 'Success' }),
- new MessageButton({ style: MessageButtonStyles.DANGER, customId: 'danger', label: 'Danger' }),
- new MessageButton({ style: MessageButtonStyles.LINK, label: 'Link', url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' })
+ const ButtonRow = new ActionRow().addComponents(
+ new ButtonComponent().setStyle(ButtonStyle.Primary).setCustomId('primaryButton').setLabel('Primary'),
+ new ButtonComponent().setStyle(ButtonStyle.Secondary).setCustomId('secondaryButton').setLabel('Secondary'),
+ new ButtonComponent().setStyle(ButtonStyle.Success).setCustomId('successButton').setLabel('Success'),
+ new ButtonComponent().setStyle(ButtonStyle.Danger).setCustomId('dangerButton').setLabel('Danger'),
+ new ButtonComponent().setStyle(ButtonStyle.Link).setLabel('Link').setURL('https://www.youtube.com/watch?v=dQw4w9WgXcQ')
);
return await message.util.reply({ content: 'buttons', components: [ButtonRow] });
} else if (['embed', 'button embed'].includes(args?.feature?.toLowerCase())) {
@@ -67,25 +74,17 @@ export default class TestCommand extends BushCommand {
)
.setTitle('Title');
- const buttonRow = new MessageActionRow().addComponents(
- new MessageButton({
- style: MessageButtonStyles.LINK,
- label: 'Link',
- url: 'https://www.google.com/'
- })
+ const buttonRow = new ActionRow().addComponents(
+ new ButtonComponent().setStyle(ButtonStyle.Link).setLabel('Link').setURL('https://google.com/')
);
return await message.util.reply({ content: 'Test', embeds: [embed], components: [buttonRow] });
} else if (['lots of buttons'].includes(args?.feature?.toLowerCase())) {
- const ButtonRows: MessageActionRow[] = [];
+ const ButtonRows: ActionRow<ActionRowComponent>[] = [];
for (let a = 1; a <= 5; a++) {
- const row = new MessageActionRow();
+ const row = new ActionRow();
for (let b = 1; b <= 5; b++) {
const id = (a + 5 * (b - 1)).toString();
- const button = new MessageButton({
- style: MessageButtonStyles.SECONDARY,
- customId: id,
- label: id
- });
+ const button = new ButtonComponent().setStyle(ButtonStyle.Primary).setCustomId(id).setLabel(id);
row.addComponents(button);
}
ButtonRows.push(row);
@@ -99,39 +98,25 @@ export default class TestCommand extends BushCommand {
return await ButtonPaginator.send(message, embeds);
} else if (['lots of embeds'].includes(args?.feature?.toLowerCase())) {
const description = 'This is a description.';
- const _avatar = message.author.avatarURL({ dynamic: true }) ?? undefined;
+ const _avatar = message.author.avatarURL() ?? undefined;
const author = { name: 'This is a author', iconURL: _avatar };
const footer = { text: 'This is a footer', iconURL: _avatar };
- const fields = [];
- for (let i = 0; i < 25; i++) {
- fields.push({ name: `Field ${i}`, value: `Field Value ${i}` });
- }
+ const fields = Array(25)
+ .fill(0)
+ .map((_, i) => ({ name: `Field ${i}`, value: 'Field Value' }));
const c = util.colors;
const o = { description, author, footer, fields, time: Date.now() };
- const embeds = [
- { ...o, title: 'Embed Title 0', color: c.red },
- { ...o, title: 'Embed Title 1', color: c.orange },
- { ...o, title: 'Embed Title 2', color: c.gold },
- { ...o, title: 'Embed Title 3', color: c.yellow },
- { ...o, title: 'Embed Title 4', color: c.green },
- { ...o, title: 'Embed Title 5', color: c.darkGreen },
- { ...o, title: 'Embed Title 6', color: c.aqua },
- { ...o, title: 'Embed Title 7', color: c.blue },
- { ...o, title: 'Embed Title 8', color: c.purple },
- { ...o, title: 'Embed Title 9', color: c.pink }
- ];
+ const colors = [c.red, c.orange, c.gold, c.yellow, c.green, c.darkGreen, c.aqua, c.blue, c.purple, c.pink];
+
+ const embeds = colors.map((c, i) => ({ ...o, title: `Embed Title ${i}`, color: c }));
- const ButtonRows: MessageActionRow[] = [];
+ const ButtonRows: ActionRow<ActionRowComponent>[] = [];
for (let a = 1; a <= 5; a++) {
- const row = new MessageActionRow();
+ const row = new ActionRow();
for (let b = 1; b <= 5; b++) {
const id = (a + 5 * (b - 1)).toString();
- const button = new MessageButton({
- style: MessageButtonStyles.SECONDARY,
- customId: id,
- label: id
- });
+ const button = new ButtonComponent().setStyle(ButtonStyle.Secondary).setCustomId(id).setLabel(id);
row.addComponents(button);
}
ButtonRows.push(row);
diff --git a/src/commands/fun/eightBall.ts b/src/commands/fun/eightBall.ts
index b4d2fbe..ff06fe5 100644
--- a/src/commands/fun/eightBall.ts
+++ b/src/commands/fun/eightBall.ts
@@ -1,4 +1,5 @@
import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
+import { ApplicationCommandOptionType } from 'discord.js';
export default class EightBallCommand extends BushCommand {
public constructor() {
@@ -16,7 +17,7 @@ export default class EightBallCommand extends BushCommand {
match: 'rest',
prompt: 'What question would you like answered?',
retry: '{error} Invalid question.',
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
}
],
slash: true,
diff --git a/src/commands/fun/minesweeper.ts b/src/commands/fun/minesweeper.ts
index 6878c05..b9737a3 100644
--- a/src/commands/fun/minesweeper.ts
+++ b/src/commands/fun/minesweeper.ts
@@ -1,6 +1,7 @@
import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
import { Minesweeper } from '@notenoughupdates/discord.js-minesweeper';
import assert from 'assert';
+import { ApplicationCommandOptionType } from 'discord.js';
assert(Minesweeper);
export default class MinesweeperCommand extends BushCommand {
@@ -20,7 +21,7 @@ export default class MinesweeperCommand extends BushCommand {
retry: '{error} Choose a valid number of rows',
optional: true,
default: 9,
- slashType: 'INTEGER'
+ slashType: ApplicationCommandOptionType.Integer
},
{
id: 'columns',
@@ -30,7 +31,7 @@ export default class MinesweeperCommand extends BushCommand {
retry: '{error} Choose a valid number of columns',
optional: true,
default: 9,
- slashType: 'INTEGER'
+ slashType: ApplicationCommandOptionType.Integer
},
{
id: 'mines',
@@ -40,7 +41,7 @@ export default class MinesweeperCommand extends BushCommand {
retry: '{error} Choose a valid number of mines',
optional: true,
default: 10,
- slashType: 'INTEGER'
+ slashType: ApplicationCommandOptionType.Integer
},
{
id: 'spaces',
@@ -48,7 +49,7 @@ export default class MinesweeperCommand extends BushCommand {
match: 'flag',
flag: '--spaces',
prompt: 'Would you like there to be spaces?',
- slashType: 'BOOLEAN',
+ slashType: ApplicationCommandOptionType.Boolean,
optional: true
},
{
@@ -57,7 +58,7 @@ export default class MinesweeperCommand extends BushCommand {
match: 'flag',
flag: '--revealFirstCell',
prompt: 'Would you like to automatically reveal the first cell?',
- slashType: 'BOOLEAN',
+ slashType: ApplicationCommandOptionType.Boolean,
optional: true
}
],
diff --git a/src/commands/info/avatar.ts b/src/commands/info/avatar.ts
index ce2543f..58d8bca 100644
--- a/src/commands/info/avatar.ts
+++ b/src/commands/info/avatar.ts
@@ -1,5 +1,5 @@
import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
-import { GuildMember, MessageEmbed } from 'discord.js';
+import { ApplicationCommandOptionType, GuildMember, MessageEmbed, Permissions } from 'discord.js';
export default class AvatarCommand extends BushCommand {
constructor() {
@@ -18,10 +18,10 @@ export default class AvatarCommand extends BushCommand {
prompt: 'Who would you like to see the avatar of?',
retry: '{error} Choose a valid user.',
optional: true,
- slashType: 'USER'
+ slashType: ApplicationCommandOptionType.User
}
],
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: [],
slash: true
});
diff --git a/src/commands/info/botInfo.ts b/src/commands/info/botInfo.ts
index fa572e8..3aea3cd 100644
--- a/src/commands/info/botInfo.ts
+++ b/src/commands/info/botInfo.ts
@@ -1,6 +1,6 @@
import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
import assert from 'assert';
-import { MessageEmbed, version as discordJSVersion } from 'discord.js';
+import { MessageEmbed, Permissions, version as discordJSVersion } from 'discord.js';
import * as os from 'os';
const { default: prettyBytes } = await import('pretty-bytes');
assert(prettyBytes);
@@ -15,7 +15,7 @@ export default class BotInfoCommand extends BushCommand {
usage: ['bot-info'],
examples: ['bot-info'],
slash: true,
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: []
});
}
diff --git a/src/commands/info/color.ts b/src/commands/info/color.ts
index 5b2c818..d385c53 100644
--- a/src/commands/info/color.ts
+++ b/src/commands/info/color.ts
@@ -9,7 +9,7 @@ import {
type BushSlashMessage
} from '#lib';
import assert from 'assert';
-import { MessageEmbed, Role } from 'discord.js';
+import { ApplicationCommandOptionType, MessageEmbed, Permissions, Role } from 'discord.js';
import tinycolor from 'tinycolor2';
assert(tinycolor);
@@ -36,11 +36,11 @@ export default class ColorCommand extends BushCommand {
match: 'restContent',
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'
+ slashType: ApplicationCommandOptionType.String
}
],
channel: 'guild',
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: []
});
}
diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts
index 7d3d170..afc5111 100644
--- a/src/commands/info/guildInfo.ts
+++ b/src/commands/info/guildInfo.ts
@@ -1,9 +1,14 @@
import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage, type OptionalArgType } from '#lib';
import assert from 'assert';
+import { GuildDefaultMessageNotifications, GuildExplicitContentFilter } from 'discord-api-types';
import {
- Constants,
+ ApplicationCommandOptionType,
Guild,
+ GuildMFALevel,
+ GuildPremiumTier,
+ GuildVerificationLevel,
MessageEmbed,
+ Permissions,
type BaseGuildVoiceChannel,
type GuildPreview,
type Snowflake,
@@ -27,11 +32,11 @@ export default class GuildInfoCommand extends BushCommand {
prompt: 'What server would you like to find information about?',
retry: '{error} Choose a valid server to find information about.',
optional: true,
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
}
],
slash: true,
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: []
});
}
@@ -66,20 +71,20 @@ 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 as typeof verifiedGuilds[number])) emojis.push(otherEmojis.BUSH_VERIFIED);
+ if (verifiedGuilds.includes(guild.id as typeof verifiedGuilds[number])) emojis.push(otherEmojis.BushVerified);
if (!isPreview && guild instanceof Guild) {
- if (guild.premiumTier !== 'NONE') emojis.push(otherEmojis[`BOOST_${guild.premiumTier}`]);
+ if (guild.premiumTier !== 'None') emojis.push(otherEmojis[`Boost${guild.premiumTier}`]);
await guild.fetch();
const channels = guild.channels.cache;
- const channelTypes = (
- ['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 channelTypes = (['Text', 'Voice', 'News', 'Stage', 'Store', 'Category', 'Thread'] as const).map(
+ (type) => `${otherEmojis[`Channel${type}`]} ${channels.filter((channel) => channel[`is${type}`]()).size.toLocaleString()}`
+ );
const guildRegions = [
...new Set(
- guild.channels.cache.filter((c) => c.isVoice()).map((c) => (c as BaseGuildVoiceChannel).rtcRegion ?? 'automatic')
+ guild.channels.cache.filter((c) => c.isVoiceBased()).map((c) => (c as BaseGuildVoiceChannel).rtcRegion ?? 'automatic')
)
] as RTCRegion[];
@@ -92,48 +97,42 @@ export default class GuildInfoCommand extends BushCommand {
`**Regions:** ${guildRegions.map((region) => client.consts.mappings.regions[region] || region).join(', ')}`
);
if (guild.premiumSubscriptionCount)
- guildAbout.push(
- `**Boosts:** Level ${Constants.PremiumTiers[guild.premiumTier]} with ${guild.premiumSubscriptionCount ?? 0} boosts`
- );
- if (guild.me?.permissions.has('MANAGE_GUILD') && guild.vanityURLCode) {
+ guildAbout.push(`**Boosts:** Level ${guild.premiumTier} with ${guild.premiumSubscriptionCount ?? 0} boosts`);
+ if (guild.me?.permissions.has(Permissions.FLAGS.MANAGE_GUILD) && guild.vanityURLCode) {
const vanityInfo: Vanity = await guild.fetchVanityData();
guildAbout.push(`**Vanity URL:** discord.gg/${vanityInfo.code}`, `**Vanity Uses:** ${vanityInfo.uses?.toLocaleString()}`);
}
- if (guild.icon) guildAbout.push(`**Icon:** [link](${guild.iconURL({ dynamic: true, size: 4096, format: 'png' })})`);
+ if (guild.icon) guildAbout.push(`**Icon:** [link](${guild.iconURL({ size: 4096, format: 'png' })})`);
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' })})`);
const EmojiTierMap = {
- TIER_3: 500,
- TIER_2: 300,
- TIER_1: 100,
- NONE: 50
+ [GuildPremiumTier.Tier3]: 500,
+ [GuildPremiumTier.Tier2]: 300,
+ [GuildPremiumTier.Tier1]: 100,
+ [GuildPremiumTier.None]: 50
} as const;
const StickerTierMap = {
- TIER_3: 60,
- TIER_2: 30,
- TIER_1: 15,
- NONE: 0
+ [GuildPremiumTier.Tier3]: 60,
+ [GuildPremiumTier.Tier2]: 30,
+ [GuildPremiumTier.Tier1]: 15,
+ [GuildPremiumTier.None]: 0
} as const;
guildStats.push(
`**Channels:** ${guild.channels.cache.size.toLocaleString()} / 500 (${channelTypes.join(', ')})`,
// subtract 1 for @everyone role
`**Roles:** ${((guild.roles.cache.size ?? 0) - 1).toLocaleString()} / 250`,
- `**Emojis:** ${guild.emojis.cache.size?.toLocaleString() ?? 0} / ${EmojiTierMap[guild.premiumTier]}`,
- `**Stickers:** ${guild.stickers.cache.size?.toLocaleString() ?? 0} / ${StickerTierMap[guild.premiumTier]}`
+ `**Emojis:** ${guild.emojis.cache.size?.toLocaleString() ?? 0} / ${(<any>EmojiTierMap)[guild.premiumTier]}`,
+ `**Stickers:** ${guild.stickers.cache.size?.toLocaleString() ?? 0} / ${(<any>StickerTierMap)[guild.premiumTier]}`
);
guildSecurity.push(
- `**Verification Level**: ${guild.verificationLevel.toLowerCase().replace(/_/g, ' ')}`,
- `**Explicit Content Filter:** ${guild.explicitContentFilter.toLowerCase().replace(/_/g, ' ')}`,
- `**Default Message Notifications:** ${
- typeof guild.defaultMessageNotifications === 'string'
- ? guild.defaultMessageNotifications.toLowerCase().replace(/_/g, ' ')
- : guild.defaultMessageNotifications
- }`,
- `**2FA Required**: ${guild.mfaLevel === 'ELEVATED' ? 'yes' : 'no'}`
+ `**Verification Level**: ${(<any>BushGuildVerificationLevel)[guild.verificationLevel]}`,
+ `**Explicit Content Filter:** ${(<any>BushGuildExplicitContentFilter)[guild.explicitContentFilter]}`,
+ `**Default Message Notifications:** ${(<any>BushGuildDefaultMessageNotifications)[guild.defaultMessageNotifications]}`,
+ `**2FA Required**: ${guild.mfaLevel === GuildMFALevel.Elevated ? 'True' : 'False'}`
);
} else {
guildAbout.push(
@@ -142,8 +141,8 @@ export default class GuildInfoCommand extends BushCommand {
}, ${util.emojis.offlineCircle} ${(
(guild.approximateMemberCount ?? 0) - (guild.approximatePresenceCount ?? 0)
).toLocaleString()})`,
- `**Emojis:** ${(guild as GuildPreview).emojis.size?.toLocaleString() ?? 0}`
- // `**Stickers:** ${(guild as GuildPreview).stickers.size}`
+ `**Emojis:** ${(guild as GuildPreview).emojis.size?.toLocaleString() ?? 0}`,
+ `**Stickers:** ${(guild as GuildPreview).stickers.size}`
);
}
@@ -174,7 +173,7 @@ export default class GuildInfoCommand extends BushCommand {
.setColor(util.colors.default)
.addField('» About', guildAbout.join('\n'));
if (guildStats.length) guildInfoEmbed.addField('» Stats', guildStats.join('\n'));
- const guildIcon = guild.iconURL({ size: 2048, format: 'png', dynamic: true });
+ const guildIcon = guild.iconURL({ size: 2048, format: 'png' });
if (guildIcon) {
guildInfoEmbed.setThumbnail(guildIcon);
}
@@ -203,3 +202,22 @@ type RTCRegion =
| 'japan'
| 'india'
| 'automatic';
+
+enum BushGuildVerificationLevel {
+ 'None' = GuildVerificationLevel.None,
+ 'Low' = GuildVerificationLevel.Low,
+ 'Medium' = GuildVerificationLevel.Medium,
+ 'High' = GuildVerificationLevel.High,
+ 'Very High' = GuildVerificationLevel.VeryHigh
+}
+
+enum BushGuildExplicitContentFilter {
+ 'Disabled' = GuildExplicitContentFilter.Disabled,
+ 'Members Without Roles' = GuildExplicitContentFilter.MembersWithoutRoles,
+ 'All Members' = GuildExplicitContentFilter.AllMembers
+}
+
+enum BushGuildDefaultMessageNotifications {
+ 'All Messages' = GuildDefaultMessageNotifications.AllMessages,
+ 'Only Mentions' = GuildDefaultMessageNotifications.OnlyMentions
+}
diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts
index 1ac7b3e..c77b5d2 100644
--- a/src/commands/info/help.ts
+++ b/src/commands/info/help.ts
@@ -1,8 +1,17 @@
import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
import assert from 'assert';
-import { AutocompleteInteraction, MessageActionRow, MessageButton, MessageEmbed } from 'discord.js';
+import {
+ ActionRow,
+ ApplicationCommandOptionType,
+ AutocompleteInteraction,
+ ButtonComponent,
+ ButtonStyle,
+ MessageEmbed,
+ Permissions
+} from 'discord.js';
import Fuse from 'fuse.js';
import packageDotJSON from '../../../package.json' assert { type: 'json' };
+
assert(Fuse);
assert(packageDotJSON);
@@ -22,7 +31,7 @@ export default class HelpCommand extends BushCommand {
match: 'content',
prompt: 'What command do you need help with?',
retry: '{error} Choose a valid command to find help for.',
- slashType: 'STRING',
+ slashType: ApplicationCommandOptionType.String,
optional: true,
autocomplete: true
},
@@ -31,14 +40,14 @@ export default class HelpCommand extends BushCommand {
description: 'Whether ot not to show hidden commands as well.',
match: 'flag',
flag: '--hidden',
- slashType: 'BOOLEAN',
+ slashType: ApplicationCommandOptionType.Boolean,
ownerOnly: true,
only: 'text',
optional: true
}
],
slash: true,
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: []
});
}
@@ -117,40 +126,23 @@ export default class HelpCommand extends BushCommand {
if (restrictions.length) embed.addField('» Restrictions', restrictions.join('\n'));
}
- return await message.util.reply({ embeds: [embed], components: row.components.length ? [row] : undefined });
+ const params = { embeds: [embed], components: row.components.length ? [row] : undefined };
+ return await message.util.reply(params);
}
private addLinks(message: BushMessage | BushSlashMessage) {
- const row = new MessageActionRow();
+ const row = new ActionRow();
if (!client.config.isDevelopment && !client.guilds.cache.some((guild) => guild.ownerId === message.author.id)) {
- row.addComponents(
- new MessageButton({
- style: 'LINK',
- label: 'Invite Me',
- url: `https://discord.com/api/oauth2/authorize?client_id=${
- client.user!.id
- }&permissions=5368709119918&scope=bot%20applications.commands`
- })
- );
+ row.addComponents(new ButtonComponent().setStyle(ButtonStyle.Link).setLabel('Invite Me').setURL(util.invite));
}
if (!client.guilds.cache.get(client.config.supportGuild.id)?.members.cache.has(message.author.id)) {
row.addComponents(
- new MessageButton({
- style: 'LINK',
- label: 'Support Server',
- url: client.config.supportGuild.invite
- })
+ new ButtonComponent().setStyle(ButtonStyle.Link).setLabel('Support Server').setURL(client.config.supportGuild.invite)
);
}
if (packageDotJSON?.repository)
- row.addComponents(
- new MessageButton({
- style: 'LINK',
- label: 'GitHub',
- url: packageDotJSON.repository
- })
- );
+ row.addComponents(new ButtonComponent().setStyle(ButtonStyle.Link).setLabel('GitHub').setURL(packageDotJSON.repository));
else void message.channel?.send('Error importing package.json, please report this to my developer.');
return row;
diff --git a/src/commands/info/icon.ts b/src/commands/info/icon.ts
index 42b7fa4..9602d40 100644
--- a/src/commands/info/icon.ts
+++ b/src/commands/info/icon.ts
@@ -1,5 +1,5 @@
import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
-import { MessageEmbed } from 'discord.js';
+import { MessageEmbed, Permissions } from 'discord.js';
export default class IconCommand extends BushCommand {
constructor() {
@@ -9,7 +9,7 @@ export default class IconCommand extends BushCommand {
description: "A command to get the server's icon",
usage: ['icon'],
examples: ['icon'],
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: [],
channel: 'guild',
slash: true
@@ -23,7 +23,6 @@ export default class IconCommand extends BushCommand {
.setImage(
message.guild!.iconURL({
size: 2048,
- dynamic: true,
format: 'png'
})!
)
diff --git a/src/commands/info/links.ts b/src/commands/info/links.ts
index b0d2007..25b040c 100644
--- a/src/commands/info/links.ts
+++ b/src/commands/info/links.ts
@@ -1,7 +1,8 @@
import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
import { assert } from 'console';
-import { MessageActionRow, MessageButton } from 'discord.js';
+import { ActionRow, ButtonComponent, ButtonStyle } from 'discord.js';
import packageDotJSON from '../../../package.json' assert { type: 'json' };
+
assert(packageDotJSON);
export default class LinksCommand extends BushCommand {
@@ -19,26 +20,14 @@ export default class LinksCommand extends BushCommand {
}
public override async exec(message: BushMessage | BushSlashMessage) {
- if (client.config.isDevelopment) return await message.util.reply(`${util.emojis.error} The dev bot cannot be invited.`);
- const ButtonRow = new MessageActionRow().addComponents(
- new MessageButton({
- style: 'LINK',
- label: 'Invite Me',
- url: `https://discord.com/api/oauth2/authorize?client_id=${
- client.user!.id
- }&permissions=5368709119918&scope=bot%20applications.commands`
- }),
- new MessageButton({
- style: 'LINK',
- label: 'Support Server',
- url: client.config.supportGuild.invite
- }),
- new MessageButton({
- style: 'LINK',
- label: 'GitHub',
- url: packageDotJSON.repository
- })
+ const buttonRow = new ActionRow();
+ if (!client.config.isDevelopment || message.author.isOwner()) {
+ buttonRow.addComponents(new ButtonComponent().setStyle(ButtonStyle.Link).setLabel('Invite Me').setURL(util.invite));
+ }
+ buttonRow.addComponents(
+ new ButtonComponent().setStyle(ButtonStyle.Link).setLabel('Support Server').setURL(client.config.supportGuild.invite),
+ new ButtonComponent().setStyle(ButtonStyle.Link).setLabel('GitHub').setURL(packageDotJSON.repository)
);
- return await message.util.reply({ content: '\u200B', components: [ButtonRow] });
+ return await message.util.reply({ content: 'Here are some useful links:', components: [buttonRow] });
}
}
diff --git a/src/commands/info/ping.ts b/src/commands/info/ping.ts
index a156368..1a8f542 100644
--- a/src/commands/info/ping.ts
+++ b/src/commands/info/ping.ts
@@ -1,5 +1,5 @@
import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
-import { MessageEmbed, type Message } from 'discord.js';
+import { MessageEmbed, Permissions, type Message } from 'discord.js';
export default class PingCommand extends BushCommand {
public constructor() {
@@ -10,7 +10,7 @@ export default class PingCommand extends BushCommand {
usage: ['ping'],
examples: ['ping'],
slash: true,
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: []
});
}
@@ -24,7 +24,7 @@ export default class PingCommand extends BushCommand {
.setTitle('Pong! 🏓')
.addField('Bot Latency', botLatency, true)
.addField('API Latency', apiLatency, true)
- .setFooter({ text: message.author.username, iconURL: message.author.displayAvatarURL({ dynamic: true }) })
+ .setFooter({ text: message.author.username, iconURL: message.author.displayAvatarURL() })
.setColor(util.colors.default)
.setTimestamp();
await sentMessage.edit({
@@ -45,7 +45,7 @@ export default class PingCommand extends BushCommand {
.addField('API Latency', apiLatency, true)
.setFooter({
text: message.interaction.user.username,
- iconURL: message.interaction.user.displayAvatarURL({ dynamic: true })
+ iconURL: message.interaction.user.displayAvatarURL()
})
.setColor(util.colors.default)
.setTimestamp();
diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts
index 9b9f870..e390865 100644
--- a/src/commands/info/pronouns.ts
+++ b/src/commands/info/pronouns.ts
@@ -1,5 +1,5 @@
import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
-import { MessageEmbed } from 'discord.js';
+import { ApplicationCommandOptionType, MessageEmbed, Permissions } from 'discord.js';
export default class PronounsCommand extends BushCommand {
public constructor() {
@@ -17,10 +17,10 @@ export default class PronounsCommand extends BushCommand {
prompt: 'Who would you like to view the pronouns of?',
retry: '{error} Choose a valid user to view the pronouns of.',
optional: true,
- slashType: 'USER'
+ slashType: ApplicationCommandOptionType.User
}
],
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: [],
slash: true
});
diff --git a/src/commands/info/snowflake.ts b/src/commands/info/snowflake.ts
index 1a41257..d9ad108 100644
--- a/src/commands/info/snowflake.ts
+++ b/src/commands/info/snowflake.ts
@@ -1,18 +1,14 @@
import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
import {
+ ApplicationCommandOptionType,
MessageEmbed,
+ Permissions,
SnowflakeUtil,
- type CategoryChannel,
type DeconstructedSnowflake,
- type DMChannel,
type Guild,
- type NewsChannel,
type Role,
type Snowflake,
- type StageChannel,
- type TextChannel,
- type User,
- type VoiceChannel
+ type User
} from 'discord.js';
export default class SnowflakeCommand extends BushCommand {
@@ -30,11 +26,10 @@ export default class SnowflakeCommand extends BushCommand {
type: 'snowflake',
prompt: 'What snowflake would you like to get information about?',
retry: '{error} Choose a valid snowflake.',
- optional: false,
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
}
],
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: [],
slash: true
});
@@ -46,35 +41,25 @@ export default class SnowflakeCommand extends BushCommand {
// Channel
if (client.channels.cache.has(snowflake)) {
- const channel = client.channels.cache.get(snowflake)!;
+ const channel = client.channels.resolve(snowflake)!;
const channelInfo = [`**Type:** ${channel.type}`];
- if (['DM', 'GROUP_DM'].includes(channel.type)) {
- const _channel = channel as DMChannel;
- channelInfo.push(`**Recipient:** ${util.discord.escapeMarkdown(_channel.recipient.tag)} (${_channel.recipient.id})`);
- snowflakeEmbed.setTitle(
- `:snowflake: DM with ${util.discord.escapeMarkdown((channel as DMChannel).recipient.tag)} \`[Channel]\``
- );
+ if (channel.isDM()) {
+ channelInfo.push(`**Recipient:** ${util.discord.escapeMarkdown(channel.recipient.tag)} (${channel.recipient.id})`);
+ snowflakeEmbed.setTitle(`:snowflake: DM with ${util.discord.escapeMarkdown(channel.recipient.tag)} \`[Channel]\``);
} else if (
- (
- [
- 'GUILD_CATEGORY',
- 'GUILD_NEWS',
- 'GUILD_TEXT',
- 'GUILD_VOICE',
- 'GUILD_STORE',
- 'GUILD_STAGE_VOICE',
- 'GUILD_NEWS_THREAD',
- 'GUILD_PUBLIC_THREAD',
- 'GUILD_PRIVATE_THREAD'
- ] as const
- ).includes(channel.type)
+ channel.isCategory() ||
+ channel.isNews() ||
+ channel.isText() ||
+ channel.isVoice() ||
+ channel.isStore() ||
+ channel.isStage() ||
+ channel.isThread()
) {
- const _channel = channel as TextChannel | VoiceChannel | NewsChannel | StageChannel | CategoryChannel | StageChannel;
channelInfo.push(
- `**Channel Name:** <#${_channel.id}> (${util.discord.escapeMarkdown(_channel.name)})`,
- `**Channel's Server:** ${util.discord.escapeMarkdown(_channel.guild.name)} (${_channel.guild.id})`
+ `**Channel Name:** <#${channel.id}> (${util.discord.escapeMarkdown(channel.name)})`,
+ `**Channel's Server:** ${util.discord.escapeMarkdown(channel.guild.name)} (${channel.guild.id})`
);
- snowflakeEmbed.setTitle(`:snowflake: ${util.discord.escapeMarkdown(_channel.name)} \`[Channel]\``);
+ snowflakeEmbed.setTitle(`:snowflake: ${util.discord.escapeMarkdown(channel.name)} \`[Channel]\``);
}
snowflakeEmbed.addField('» Channel Info', channelInfo.join('\n'));
}
@@ -89,7 +74,7 @@ export default class SnowflakeCommand extends BushCommand {
})`,
`**Members:** ${guild.memberCount?.toLocaleString()}`
];
- if (guild.icon) snowflakeEmbed.setThumbnail(guild.iconURL({ size: 2048, dynamic: true })!);
+ if (guild.icon) snowflakeEmbed.setThumbnail(guild.iconURL({ size: 2048 })!);
snowflakeEmbed.addField('» Server Info', guildInfo.join('\n'));
snowflakeEmbed.setTitle(`:snowflake: ${util.discord.escapeMarkdown(guild.name)} \`[Server]\``);
}
@@ -99,7 +84,7 @@ export default class SnowflakeCommand extends BushCommand {
if (client.users.cache.has(snowflake) || fetchedUser) {
const user: User = (client.users.cache.get(snowflake) ?? fetchedUser)!;
const userInfo = [`**Name:** <@${user.id}> (${util.discord.escapeMarkdown(user.tag)})`];
- if (user.avatar) snowflakeEmbed.setThumbnail(user.avatarURL({ size: 2048, dynamic: true })!);
+ if (user.avatar) snowflakeEmbed.setThumbnail(user.avatarURL({ size: 2048 })!);
snowflakeEmbed.addField('» User Info', userInfo.join('\n'));
snowflakeEmbed.setTitle(`:snowflake: ${util.discord.escapeMarkdown(user.tag)} \`[User]\``);
}
@@ -136,11 +121,10 @@ export default class SnowflakeCommand extends BushCommand {
const deconstructedSnowflake: DeconstructedSnowflake = SnowflakeUtil.deconstruct(snowflake);
const snowflakeInfo = [
`**Timestamp:** ${deconstructedSnowflake.timestamp}`,
- `**Created:** ${util.timestamp(deconstructedSnowflake.date)}`,
+ `**Created:** ${util.timestamp(new Date(Number(deconstructedSnowflake.timestamp)))}`,
`**Worker ID:** ${deconstructedSnowflake.workerId}`,
`**Process ID:** ${deconstructedSnowflake.processId}`,
`**Increment:** ${deconstructedSnowflake.increment}`
- // `**Binary:** ${deconstructedSnowflake.binary}`
];
snowflakeEmbed.addField('» Snowflake Info', snowflakeInfo.join('\n'));
diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts
index 609bd94..38c9ea6 100644
--- a/src/commands/info/userInfo.ts
+++ b/src/commands/info/userInfo.ts
@@ -7,7 +7,7 @@ import {
type BushSlashMessage,
type BushUser
} from '#lib';
-import { MessageEmbed } from 'discord.js';
+import { ActivityType, ApplicationCommandOptionType, MessageEmbed, Permissions, UserFlags } from 'discord.js';
// TODO: Add bot information
export default class UserInfoCommand extends BushCommand {
@@ -27,11 +27,11 @@ export default class UserInfoCommand extends BushCommand {
prompt: 'What user would you like to find information about?',
retry: '{error} Choose a valid user to find information about.',
optional: true,
- slashType: 'USER'
+ slashType: ApplicationCommandOptionType.User
}
],
slash: true,
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: []
});
}
@@ -58,12 +58,12 @@ export default class UserInfoCommand extends BushCommand {
const userEmbed: MessageEmbed = new MessageEmbed()
.setTitle(util.discord.escapeMarkdown(user.tag))
- .setThumbnail(user.displayAvatarURL({ size: 2048, format: 'png', dynamic: true }))
+ .setThumbnail(user.displayAvatarURL({ size: 2048, format: 'png' }))
.setTimestamp();
// Flags
- if (client.config.owners.includes(user.id)) emojis.push(client.consts.mappings.otherEmojis.DEVELOPER);
- if (superUsers.includes(user.id)) emojis.push(client.consts.mappings.otherEmojis.SUPERUSER);
+ if (client.config.owners.includes(user.id)) emojis.push(client.consts.mappings.otherEmojis.Developer);
+ if (superUsers.includes(user.id)) emojis.push(client.consts.mappings.otherEmojis.Superuser);
const flags = user.flags?.toArray();
if (flags) {
flags.forEach((f) => {
@@ -77,15 +77,15 @@ export default class UserInfoCommand extends BushCommand {
if (
Number(user.discriminator) < 10 ||
client.consts.mappings.maybeNitroDiscrims.includes(user.discriminator) ||
- user.displayAvatarURL({ dynamic: true })?.endsWith('.gif') ||
- user.flags?.toArray().includes('PARTNERED_SERVER_OWNER')
+ user.displayAvatarURL()?.endsWith('.gif') ||
+ user.flags?.has(UserFlags.FLAGS.PARTNER)
) {
- emojis.push(client.consts.mappings.otherEmojis.NITRO);
+ emojis.push(client.consts.mappings.otherEmojis.Nitro);
}
- if (guild?.ownerId == user.id) emojis.push(client.consts.mappings.otherEmojis.OWNER);
- else if (member?.permissions.has('ADMINISTRATOR')) emojis.push(client.consts.mappings.otherEmojis.ADMIN);
- if (member?.premiumSinceTimestamp) emojis.push(client.consts.mappings.otherEmojis.BOOSTER);
+ if (guild?.ownerId == user.id) emojis.push(client.consts.mappings.otherEmojis.Owner);
+ else if (member?.permissions.has(Permissions.FLAGS.ADMINISTRATOR)) emojis.push(client.consts.mappings.otherEmojis.Admin);
+ if (member?.premiumSinceTimestamp) emojis.push(client.consts.mappings.otherEmojis.Booster);
const createdAt = util.timestamp(user.createdAt),
createdAtDelta = util.dateDelta(user.createdAt),
@@ -97,7 +97,7 @@ export default class UserInfoCommand extends BushCommand {
// General Info
const generalInfo = [`**Mention:** <@${user.id}>`, `**ID:** ${user.id}`, `**Created:** ${createdAt} (${createdAtDelta} ago)`];
if (user.accentColor !== null) generalInfo.push(`**Accent Color:** ${user.hexAccentColor}`);
- if (user.banner) generalInfo.push(`**Banner:** [link](${user.bannerURL({ dynamic: true, format: 'png', size: 4096 })})`);
+ if (user.banner) generalInfo.push(`**Banner:** [link](${user.bannerURL({ format: 'png', size: 4096 })})`);
const pronouns = await Promise.race([util.getPronounsOf(user), util.sleep(2)]);
if (pronouns && typeof pronouns === 'string') generalInfo.push(`**Pronouns:** ${pronouns}`);
@@ -126,7 +126,7 @@ export default class UserInfoCommand extends BushCommand {
const activitiesNames: string[] = [];
if (member.presence.activities) {
member.presence.activities.forEach((a) => {
- if (a.type == 'CUSTOM' && a.state) {
+ if (a.type == ActivityType.Custom && a.state) {
const emoji = `${a.emoji ? `${a.emoji.toString()} ` : ''}`;
customStatus = `${emoji}${a.state}`;
}
@@ -169,7 +169,7 @@ export default class UserInfoCommand extends BushCommand {
// Important Perms
const perms = [];
- if (member?.permissions.has('ADMINISTRATOR') || guild?.ownerId == user.id) {
+ if (member?.permissions.has(Permissions.FLAGS.ADMINISTRATOR) || guild?.ownerId == user.id) {
perms.push('`Administrator`');
} else if (member?.permissions.toArray().length) {
member.permissions.toArray().forEach((permission) => {
diff --git a/src/commands/leveling/leaderboard.ts b/src/commands/leveling/leaderboard.ts
index ffed9e9..2e0ce5d 100644
--- a/src/commands/leveling/leaderboard.ts
+++ b/src/commands/leveling/leaderboard.ts
@@ -1,5 +1,5 @@
import { BushCommand, ButtonPaginator, Level, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
-import { MessageEmbed } from 'discord.js';
+import { ApplicationCommandOptionType, MessageEmbed, Permissions } from 'discord.js';
export default class LeaderboardCommand extends BushCommand {
public constructor() {
@@ -17,7 +17,7 @@ export default class LeaderboardCommand extends BushCommand {
prompt: 'What page of the leaderboard would you like to view?',
retry: '{error} Pick a valid argument.',
optional: true,
- slashType: 'INTEGER'
+ slashType: ApplicationCommandOptionType.Integer
}
],
slash: true,
@@ -32,7 +32,7 @@ export default class LeaderboardCommand extends BushCommand {
if (!(await message.guild.hasFeature('leveling')))
return await message.util.reply(
`${util.emojis.error} This command can only be run in servers with the leveling feature enabled.${
- message.member?.permissions.has('MANAGE_GUILD')
+ message.member?.permissions.has(Permissions.FLAGS.MANAGE_GUILD)
? ` You can toggle features using the \`${util.prefix(message)}features\` command.`
: ''
}`
diff --git a/src/commands/leveling/level.ts b/src/commands/leveling/level.ts
index 48cf3ed..18648e8 100644
--- a/src/commands/leveling/level.ts
+++ b/src/commands/leveling/level.ts
@@ -12,7 +12,7 @@ import {
import { SimplifyNumber } from '@notenoughupdates/simplify-number';
import assert from 'assert';
import canvas from 'canvas';
-import { MessageAttachment } from 'discord.js';
+import { ApplicationCommandOptionType, MessageAttachment, Permissions } from 'discord.js';
import got from 'got';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';
@@ -36,7 +36,7 @@ export default class LevelCommand extends BushCommand {
prompt: 'What user would you like to see the level of?',
retry: '{error} Choose a valid user to see the level of.',
optional: true,
- slashType: 'USER'
+ slashType: ApplicationCommandOptionType.User
}
],
slash: true,
@@ -51,7 +51,7 @@ export default class LevelCommand extends BushCommand {
if (!(await message.guild.hasFeature('leveling')))
return await message.util.reply(
`${util.emojis.error} This command can only be run in servers with the leveling feature enabled.${
- message.member?.permissions.has('MANAGE_GUILD')
+ message.member?.permissions.has(Permissions.FLAGS.MANAGE_GUILD)
? ` You can toggle features using the \`${util.prefix(message)}features\` command.`
: ''
}`
diff --git a/src/commands/leveling/levelRoles.ts b/src/commands/leveling/levelRoles.ts
index a5eb5c4..115ace1 100644
--- a/src/commands/leveling/levelRoles.ts
+++ b/src/commands/leveling/levelRoles.ts
@@ -1,5 +1,6 @@
import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage, type OptionalArgType } from '#lib';
import assert from 'assert';
+import { ApplicationCommandOptionType, Permissions } from 'discord.js';
export default class LevelRolesCommand extends BushCommand {
public constructor() {
@@ -17,7 +18,7 @@ export default class LevelRolesCommand extends BushCommand {
description: 'The level to assign the role when reached.',
prompt: 'What level would you like to set a role for when reached?',
retry: '{error} Pick a valid integer representing the role to assign a role to when reached.',
- slashType: 'INTEGER'
+ slashType: ApplicationCommandOptionType.Integer
},
{
id: 'role',
@@ -26,14 +27,14 @@ export default class LevelRolesCommand extends BushCommand {
description: 'The role to assign to a user who reaches the specified level.',
prompt: 'What role would you like to assign to users when they reach that level?',
retry: '{error} Choose a valid role to assign to users upon reaching the specified level.',
- slashType: 'ROLE',
+ slashType: ApplicationCommandOptionType.Role,
optional: true
}
],
slash: true,
channel: 'guild',
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_ROLES']),
- userPermissions: ['MANAGE_GUILD', 'MANAGE_ROLES']
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_ROLES]),
+ userPermissions: [Permissions.FLAGS.MANAGE_GUILD, Permissions.FLAGS.MANAGE_ROLES]
});
}
diff --git a/src/commands/leveling/setLevel.ts b/src/commands/leveling/setLevel.ts
index 184ee1b..29f36e0 100644
--- a/src/commands/leveling/setLevel.ts
+++ b/src/commands/leveling/setLevel.ts
@@ -1,4 +1,5 @@
import { AllowedMentions, BushCommand, Level, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { ApplicationCommandOptionType, Permissions } from 'discord.js';
export default class SetLevelCommand extends BushCommand {
public constructor() {
@@ -15,7 +16,7 @@ export default class SetLevelCommand extends BushCommand {
type: 'user',
prompt: 'What user would you like to change the level of?',
retry: '{error} Choose a valid user to change the level of.',
- slashType: 'USER'
+ slashType: ApplicationCommandOptionType.User
},
{
id: 'level',
@@ -23,13 +24,13 @@ export default class SetLevelCommand extends BushCommand {
type: 'integer',
prompt: 'What level would you like to set the user to?',
retry: '{error} Choose a valid level to set the user to.',
- slashType: 'INTEGER'
+ slashType: ApplicationCommandOptionType.Integer
}
],
slash: true,
channel: 'guild',
clientPermissions: (m) => util.clientSendAndPermCheck(m),
- userPermissions: ['ADMINISTRATOR']
+ userPermissions: [Permissions.FLAGS.ADMINISTRATOR]
});
}
diff --git a/src/commands/leveling/setXp.ts b/src/commands/leveling/setXp.ts
index d6f28b2..721f28f 100644
--- a/src/commands/leveling/setXp.ts
+++ b/src/commands/leveling/setXp.ts
@@ -1,4 +1,5 @@
import { AllowedMentions, BushCommand, Level, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { ApplicationCommandOptionType, Permissions } from 'discord.js';
export default class SetXpCommand extends BushCommand {
public constructor() {
@@ -15,7 +16,7 @@ export default class SetXpCommand extends BushCommand {
type: 'user',
prompt: 'What user would you like to change the xp of?',
retry: '{error} Choose a valid user to change the xp of.',
- slashType: 'USER'
+ slashType: ApplicationCommandOptionType.User
},
{
id: 'xp',
@@ -24,13 +25,13 @@ export default class SetXpCommand extends BushCommand {
match: 'restContent',
prompt: 'How much xp should the user have?',
retry: "{error} Choose a valid number to set the user's xp to.",
- slashType: 'INTEGER'
+ slashType: ApplicationCommandOptionType.Integer
}
],
slash: true,
channel: 'guild',
clientPermissions: (m) => util.clientSendAndPermCheck(m),
- userPermissions: ['ADMINISTRATOR']
+ userPermissions: [Permissions.FLAGS.ADMINISTRATOR]
});
}
diff --git a/src/commands/moderation/_activePunishments.ts b/src/commands/moderation/_activePunishments.ts
index 98c4912..5b1674c 100644
--- a/src/commands/moderation/_activePunishments.ts
+++ b/src/commands/moderation/_activePunishments.ts
@@ -1,5 +1,6 @@
// import { BushCommand, ModLog, ModLogModel, type BushGuildMember, type BushMessage, type BushSlashMessage } from '#lib';
// import { FindOptions, Op } from 'sequelize';
+// import { Permissions } from 'discord.js';
// const punishmentTypes = ['ban', 'kick', 'mute', 'warn', 'role'] as const;
@@ -19,8 +20,8 @@
// match: 'option',
// prompt: 'Only show active punishments from what user?',
// optional: true,
-// slashType: 'USER',
-// slashResolve: 'member'
+// slashType: ApplicationCommandOptionType.User,
+// slashResolve: 'Member'
// },
// {
// id: 'type',
@@ -29,7 +30,7 @@
// readableType: punishmentTypes.map((v) => `'${v}'`).join('|'),
// match: 'option',
// optional: true,
-// slashType: 'STRING',
+// slashType: ApplicationCommandOptionType.String,
// choices: punishmentTypes.map((v) => ({ name: v, value: v }))
// }
// ],
@@ -37,9 +38,10 @@
// channel: 'guild',
// hidden: true,
// clientPermissions: (m) => util.clientSendAndPermCheck(m),
-// userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES'])
+// userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES])
// });
// }
+//
// public override async exec(
// message: BushMessage | BushSlashMessage,
// args: { moderator?: BushGuildMember; type: typeof punishmentTypes[number] }
diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts
index aeb03f0..33f980d 100644
--- a/src/commands/moderation/ban.ts
+++ b/src/commands/moderation/ban.ts
@@ -8,7 +8,7 @@ import {
type BushSlashMessage,
type OptionalArgType
} from '#lib';
-import { type User } from 'discord.js';
+import { ApplicationCommandOptionType, Permissions, type User } from 'discord.js';
export default class BanCommand extends BushCommand {
public constructor() {
@@ -25,7 +25,7 @@ export default class BanCommand extends BushCommand {
type: util.arg.union('user', 'snowflake'),
prompt: 'What user would you like to ban?',
retry: '{error} Choose a valid user to ban.',
- slashType: 'USER'
+ slashType: ApplicationCommandOptionType.User
},
{
id: 'reason_and_duration',
@@ -34,7 +34,7 @@ export default class BanCommand extends BushCommand {
match: 'rest',
prompt: 'Why should this user be banned and for how long?',
retry: '{error} Choose a valid ban reason and duration.',
- slashType: 'STRING',
+ slashType: ApplicationCommandOptionType.String,
optional: true
},
{
@@ -46,7 +46,7 @@ export default class BanCommand extends BushCommand {
retry: '{error} Choose between 0 and 7 days to delete messages from the user for.',
type: util.arg.range('integer', 0, 7, true),
optional: true,
- slashType: 'INTEGER',
+ slashType: ApplicationCommandOptionType.Integer,
choices: [...Array(8).keys()].map((v) => ({ name: v.toString(), value: v }))
},
{
@@ -62,8 +62,8 @@ export default class BanCommand extends BushCommand {
],
slash: true,
channel: 'guild',
- clientPermissions: ['BAN_MEMBERS'],
- userPermissions: ['BAN_MEMBERS']
+ clientPermissions: [Permissions.FLAGS.BAN_MEMBERS],
+ userPermissions: [Permissions.FLAGS.BAN_MEMBERS]
});
}
@@ -141,6 +141,8 @@ export default class BanCommand extends BushCommand {
return `${util.emojis.warn} Banned ${victim} however I could not send them a dm.`;
case banResponse.SUCCESS:
return `${util.emojis.success} Successfully banned ${victim}.`;
+ default:
+ return `${util.emojis.error} An error occurred: ${util.format.input(responseCode)}}`;
}
};
return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() });
diff --git a/src/commands/moderation/block.ts b/src/commands/moderation/block.ts
index 57f909a..0b6458d 100644
--- a/src/commands/moderation/block.ts
+++ b/src/commands/moderation/block.ts
@@ -11,6 +11,7 @@ import {
type OptionalArgType
} from '#lib';
import assert from 'assert';
+import { ApplicationCommandOptionType, Permissions } from 'discord.js';
export default class BlockCommand extends BushCommand {
public constructor() {
@@ -27,7 +28,7 @@ export default class BlockCommand extends BushCommand {
type: 'user',
prompt: 'What user would you like to block?',
retry: '{error} Choose a valid user to block.',
- slashType: 'USER'
+ slashType: ApplicationCommandOptionType.User
},
{
id: 'reason_and_duration',
@@ -37,7 +38,7 @@ export default class BlockCommand extends BushCommand {
prompt: 'Why should this user be blocked and for how long?',
retry: '{error} Choose a valid block reason and duration.',
optional: true,
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
},
{
id: 'force',
@@ -52,8 +53,8 @@ export default class BlockCommand extends BushCommand {
],
slash: true,
channel: 'guild',
- clientPermissions: (m) => util.clientSendAndPermCheck(m, 'MANAGE_CHANNELS'),
- userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES'])
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_CHANNELS]),
+ userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES])
});
}
@@ -120,6 +121,8 @@ export default class BlockCommand extends BushCommand {
return `${util.emojis.warn} Blocked ${victim} however I could not send them a dm.`;
case blockResponse.SUCCESS:
return `${util.emojis.success} Successfully blocked ${victim}.`;
+ default:
+ return `${util.emojis.error} An error occurred: ${util.format.input(responseCode)}}`;
}
};
return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() });
diff --git a/src/commands/moderation/evidence.ts b/src/commands/moderation/evidence.ts
index cff63ed..155d804 100644
--- a/src/commands/moderation/evidence.ts
+++ b/src/commands/moderation/evidence.ts
@@ -1,5 +1,6 @@
import { BushCommand, ModLog, type BushMessage, type BushSlashMessage } from '#lib';
import { type ArgumentOptions, type Flag } from 'discord-akairo';
+import { ApplicationCommandOptionType, Permissions } from 'discord.js';
export default class EvidenceCommand extends BushCommand {
public constructor() {
@@ -15,7 +16,7 @@ export default class EvidenceCommand extends BushCommand {
description: 'The case to modify the evidence of.',
type: 'string',
prompt: 'What case would you like to modify the evidence of?',
- slashType: 'STRING',
+ slashType: ApplicationCommandOptionType.String,
only: 'slash'
},
{
@@ -23,14 +24,14 @@ export default class EvidenceCommand extends BushCommand {
description: 'The value to set the evidence to.',
type: 'string',
prompt: 'What would you like to modify the evidence to?',
- slashType: 'STRING',
+ slashType: ApplicationCommandOptionType.String,
only: 'slash'
}
],
slash: true,
channel: 'guild',
clientPermissions: (m) => util.clientSendAndPermCheck(m),
- userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES'])
+ userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES])
});
}
diff --git a/src/commands/moderation/hideCase.ts b/src/commands/moderation/hideCase.ts
index e12d8c8..2c71119 100644
--- a/src/commands/moderation/hideCase.ts
+++ b/src/commands/moderation/hideCase.ts
@@ -1,4 +1,5 @@
import { BushCommand, ModLog, type BushMessage, type BushSlashMessage } from '#lib';
+import { ApplicationCommandOptionType, Permissions } from 'discord.js';
export default class HideCaseCommand extends BushCommand {
public constructor() {
@@ -15,12 +16,12 @@ export default class HideCaseCommand extends BushCommand {
type: 'string',
prompt: 'What modlog case would you like to hide?',
retry: '{error} Choose a valid case id.',
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
}
],
slash: true,
clientPermissions: (m) => util.clientSendAndPermCheck(m),
- userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES']),
+ userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES]),
channel: 'guild'
});
}
diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts
index af486ac..4fd6c10 100644
--- a/src/commands/moderation/kick.ts
+++ b/src/commands/moderation/kick.ts
@@ -7,6 +7,7 @@ import {
type BushMessage,
type BushSlashMessage
} from '#lib';
+import { ApplicationCommandOptionType, Permissions } from 'discord.js';
export default class KickCommand extends BushCommand {
public constructor() {
@@ -23,7 +24,7 @@ export default class KickCommand extends BushCommand {
type: 'user',
prompt: 'What user would you like to kick?',
retry: '{error} Choose a valid user to kick.',
- slashType: 'USER'
+ slashType: ApplicationCommandOptionType.User
},
{
id: 'reason',
@@ -33,7 +34,7 @@ export default class KickCommand extends BushCommand {
prompt: 'Why should this user be kicked?',
retry: '{error} Choose a valid kick reason.',
optional: true,
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
},
{
id: 'force',
@@ -47,8 +48,8 @@ export default class KickCommand extends BushCommand {
}
],
slash: true,
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['KICK_MEMBERS']),
- userPermissions: ['KICK_MEMBERS']
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.KICK_MEMBERS]),
+ userPermissions: [Permissions.FLAGS.KICK_MEMBERS]
});
}
@@ -86,6 +87,8 @@ export default class KickCommand extends BushCommand {
return `${util.emojis.warn} Kicked ${victim} however I could not send them a dm.`;
case kickResponse.SUCCESS:
return `${util.emojis.success} Successfully kicked ${victim}.`;
+ default:
+ return `${util.emojis.error} An error occurred: ${util.format.input(responseCode)}}`;
}
};
return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() });
diff --git a/src/commands/moderation/lockdown.ts b/src/commands/moderation/lockdown.ts
index 87a2f05..350ce26 100644
--- a/src/commands/moderation/lockdown.ts
+++ b/src/commands/moderation/lockdown.ts
@@ -11,7 +11,7 @@ import {
type OptionalArgType
} from '#lib';
import assert from 'assert';
-import { Collection } from 'discord.js';
+import { ApplicationCommandOptionType, Collection, Permissions } from 'discord.js';
export default class LockdownCommand extends BushCommand {
public constructor() {
@@ -27,8 +27,8 @@ export default class LockdownCommand extends BushCommand {
description: 'Specify a different channel to lockdown instead of the one you trigger the command in.',
type: util.arg.union('textChannel', 'newsChannel', 'threadChannel'),
prompt: 'What channel would you like to lockdown?',
- slashType: 'CHANNEL',
- channelTypes: ['GUILD_TEXT', 'GUILD_NEWS', 'GUILD_NEWS_THREAD', 'GUILD_PUBLIC_THREAD', 'GUILD_PRIVATE_THREAD'],
+ slashType: ApplicationCommandOptionType.Channel,
+ channelTypes: ['GuildText', 'GuildNews', 'GuildNewsThread', 'GuildPublicThread', 'GuildPrivateThread'],
optional: true
},
{
@@ -37,7 +37,7 @@ export default class LockdownCommand extends BushCommand {
type: 'string',
match: 'rest',
prompt: 'What is the reason for the lockdown?',
- slashType: 'STRING',
+ slashType: ApplicationCommandOptionType.String,
optional: true
},
{
@@ -46,14 +46,14 @@ export default class LockdownCommand extends BushCommand {
match: 'flag',
flag: '--all',
prompt: 'Would you like to lockdown all configured channels?',
- slashType: 'BOOLEAN',
+ slashType: ApplicationCommandOptionType.Boolean,
optional: true
}
],
slash: true,
channel: 'guild',
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_CHANNELS']),
- userPermissions: ['MANAGE_CHANNELS']
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_CHANNELS]),
+ userPermissions: [Permissions.FLAGS.MANAGE_CHANNELS]
});
}
@@ -134,7 +134,7 @@ export default class LockdownCommand extends BushCommand {
action === 'lockdown' ? 'locked down' : 'unlocked'
} **${num}** channel${num > 0 ? 's' : ''}.`;
} else {
- throw new Error(`Unknown response: ${response}`);
+ return `${util.emojis.error} An error occurred: ${util.format.input(response)}}`;
}
assert(messageResponse);
diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts
index 8651afe..e7b3576 100644
--- a/src/commands/moderation/modlog.ts
+++ b/src/commands/moderation/modlog.ts
@@ -1,5 +1,5 @@
import { BushCommand, ButtonPaginator, ModLog, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
-import { MessageEmbed, User } from 'discord.js';
+import { ApplicationCommandOptionType, MessageEmbed, Permissions, User } from 'discord.js';
export default class ModlogCommand extends BushCommand {
public constructor() {
@@ -16,7 +16,7 @@ export default class ModlogCommand extends BushCommand {
type: util.arg.union('user', 'string'),
prompt: 'What case id or user would you like to see?',
retry: '{error} Choose a valid case id or user.',
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
},
{
id: 'hidden',
@@ -26,12 +26,12 @@ export default class ModlogCommand extends BushCommand {
flag: ['--hidden', '-h'],
default: false,
optional: true,
- slashType: 'BOOLEAN'
+ slashType: ApplicationCommandOptionType.Boolean
}
],
slash: true,
clientPermissions: (m) => util.clientSendAndPermCheck(m),
- userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES'])
+ userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES])
});
}
diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts
index 40e13e7..ea935ce 100644
--- a/src/commands/moderation/mute.ts
+++ b/src/commands/moderation/mute.ts
@@ -9,6 +9,7 @@ import {
type OptionalArgType
} from '#lib';
import assert from 'assert';
+import { ApplicationCommandOptionType, Permissions } from 'discord.js';
export default class MuteCommand extends BushCommand {
public constructor() {
@@ -25,7 +26,7 @@ export default class MuteCommand extends BushCommand {
type: 'user',
prompt: 'What user would you like to mute?',
retry: '{error} Choose a valid user to mute.',
- slashType: 'USER'
+ slashType: ApplicationCommandOptionType.User
},
{
id: 'reason_and_duration',
@@ -35,7 +36,7 @@ export default class MuteCommand extends BushCommand {
prompt: 'Why should this user be muted and for how long?',
retry: '{error} Choose a valid mute reason and duration.',
optional: true,
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
},
{
id: 'force',
@@ -50,8 +51,8 @@ export default class MuteCommand extends BushCommand {
],
slash: true,
channel: 'guild',
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_ROLES']),
- userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES'])
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_ROLES]),
+ userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES])
});
}
@@ -118,6 +119,8 @@ export default class MuteCommand extends BushCommand {
return `${util.emojis.warn} Muted ${victim} however I could not send them a dm.`;
case muteResponse.SUCCESS:
return `${util.emojis.success} Successfully muted ${victim}.`;
+ default:
+ return `${util.emojis.error} An error occurred: ${util.format.input(responseCode)}}`;
}
};
return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() });
diff --git a/src/commands/moderation/purge.ts b/src/commands/moderation/purge.ts
index 8fa279b..b48f997 100644
--- a/src/commands/moderation/purge.ts
+++ b/src/commands/moderation/purge.ts
@@ -1,6 +1,6 @@
import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
import assert from 'assert';
-import { Collection, type Snowflake } from 'discord.js';
+import { ApplicationCommandOptionType, Collection, Permissions, type Snowflake } from 'discord.js';
export default class PurgeCommand extends BushCommand {
public constructor() {
@@ -18,7 +18,7 @@ export default class PurgeCommand extends BushCommand {
readableType: 'integer',
prompt: 'How many messages would you like to purge?',
retry: '{error} Please pick a number between 1 and 100.',
- slashType: 'INTEGER',
+ slashType: ApplicationCommandOptionType.Integer,
minValue: 1,
maxValue: 100
},
@@ -28,7 +28,7 @@ export default class PurgeCommand extends BushCommand {
match: 'flag',
flag: '--bot',
prompt: 'Would you like to only delete messages that are from bots?',
- slashType: 'BOOLEAN',
+ slashType: ApplicationCommandOptionType.Boolean,
optional: true
},
{
@@ -37,13 +37,14 @@ export default class PurgeCommand extends BushCommand {
match: 'option',
type: 'user',
flag: '--user',
- slashType: 'BOOLEAN',
+ slashType: ApplicationCommandOptionType.Boolean,
optional: true
}
],
slash: true,
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_MESSAGES', 'EMBED_LINKS'], true),
- userPermissions: ['MANAGE_MESSAGES'],
+ clientPermissions: (m) =>
+ util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES, Permissions.FLAGS.EMBED_LINKS], true),
+ userPermissions: [Permissions.FLAGS.MANAGE_MESSAGES],
channel: 'guild'
});
}
@@ -53,7 +54,7 @@ export default class PurgeCommand extends BushCommand {
args: { amount: number; bot: boolean; user: ArgType<'user'> }
) {
assert(message.channel);
- if (message.channel.type === 'DM') return message.util.reply(`${util.emojis.error} You cannot run this command in dms.`);
+ if (!message.inGuild()) return message.util.reply(`${util.emojis.error} You cannot run this command in dms.`);
if (args.amount > 100 || args.amount < 1) return message.util.reply(`${util.emojis.error} `);
const messageFilter = (filterMessage: BushMessage): boolean => {
diff --git a/src/commands/moderation/removeReactionEmoji.ts b/src/commands/moderation/removeReactionEmoji.ts
index 919ee40..61759ae 100644
--- a/src/commands/moderation/removeReactionEmoji.ts
+++ b/src/commands/moderation/removeReactionEmoji.ts
@@ -1,6 +1,6 @@
import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
import assert from 'assert';
-import { Message, type Emoji } from 'discord.js';
+import { ApplicationCommandOptionType, Message, Permissions, type Emoji } from 'discord.js';
export default class RemoveReactionEmojiCommand extends BushCommand {
public constructor() {
@@ -17,7 +17,7 @@ export default class RemoveReactionEmojiCommand extends BushCommand {
type: 'guildMessage',
prompt: 'What message would you like to remove a reaction from?',
retry: '{error} Please pick a valid message.',
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
},
{
id: 'emoji',
@@ -27,13 +27,14 @@ export default class RemoveReactionEmojiCommand extends BushCommand {
match: 'restContent',
prompt: 'What emoji would you like to remove?',
retry: '{error} Please pick a valid emoji.',
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
}
],
slash: true,
channel: 'guild',
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_MESSAGES', 'EMBED_LINKS'], true),
- userPermissions: ['MANAGE_MESSAGES', 'MANAGE_EMOJIS_AND_STICKERS'] // Can't undo the removal of 1000s of reactions
+ clientPermissions: (m) =>
+ util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES, Permissions.FLAGS.EMBED_LINKS], true),
+ userPermissions: [Permissions.FLAGS.MANAGE_MESSAGES, Permissions.FLAGS.MANAGE_EMOJIS_AND_STICKERS] // Can't undo the removal of 1000s of reactions
});
}
diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts
index f0d0448..0d4d91b 100644
--- a/src/commands/moderation/role.ts
+++ b/src/commands/moderation/role.ts
@@ -9,7 +9,7 @@ import {
type OptionalArgType
} from '#lib';
import { type ArgumentOptions, type Flag } from 'discord-akairo';
-import { type Snowflake } from 'discord.js';
+import { ApplicationCommandOptionType, Permissions, type Snowflake } from 'discord.js';
export default class RoleCommand extends BushCommand {
public constructor() {
@@ -24,7 +24,7 @@ export default class RoleCommand extends BushCommand {
id: 'action',
description: 'Whether to add or remove a role for the the user.',
prompt: 'Would you like to add or remove a role?',
- slashType: 'STRING',
+ slashType: ApplicationCommandOptionType.String,
choices: [
{ name: 'add', value: 'add' },
{ name: 'remove', value: 'remove' }
@@ -35,8 +35,8 @@ export default class RoleCommand extends BushCommand {
id: 'member',
description: 'The user to add/remove a role to/from.',
prompt: 'What user do you want to add/remove a role to/from?',
- slashType: 'USER',
- slashResolve: 'member',
+ slashType: ApplicationCommandOptionType.User,
+ slashResolve: 'Member',
optional: true,
only: 'slash'
},
@@ -44,7 +44,7 @@ export default class RoleCommand extends BushCommand {
id: 'role',
description: 'The role you would like to add/remove from the to/from.',
prompt: 'What role would you like to add/remove from the user?',
- slashType: 'ROLE',
+ slashType: ApplicationCommandOptionType.Role,
optional: true,
only: 'slash'
},
@@ -52,7 +52,7 @@ export default class RoleCommand extends BushCommand {
id: 'duration',
description: 'The time before the role will be removed (ignored if removing a role).',
prompt: 'How long would you like to role to last?',
- slashType: 'STRING',
+ slashType: ApplicationCommandOptionType.String,
optional: true,
only: 'slash'
}
@@ -60,7 +60,8 @@ export default class RoleCommand extends BushCommand {
slash: true,
channel: 'guild',
typing: true,
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_ROLES', 'EMBED_LINKS'], true),
+ clientPermissions: (m) =>
+ util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_ROLES, Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: []
});
}
@@ -129,7 +130,7 @@ export default class RoleCommand extends BushCommand {
if (!args.role) return await message.util.reply(`${util.emojis.error} You must specify a role.`);
if (args.duration === null) args.duration = 0;
if (
- !message.member!.permissions.has('MANAGE_ROLES') &&
+ !message.member!.permissions.has(Permissions.FLAGS.MANAGE_ROLES) &&
message.member!.id !== message.guild?.ownerId &&
!message.member!.user.isOwner()
) {
@@ -202,6 +203,8 @@ export default class RoleCommand extends BushCommand {
return `${util.emojis.success} Successfully ${args.action === 'add' ? 'added' : 'removed'} <@&${args.role.id}> ${
args.action === 'add' ? 'to' : 'from'
} ${victim}${args.duration ? ` for ${util.humanizeDuration(args.duration)}` : ''}.`;
+ default:
+ return `${util.emojis.error} An error occurred: ${util.format.input(responseCode)}}`;
}
};
diff --git a/src/commands/moderation/slowmode.ts b/src/commands/moderation/slowmode.ts
index bfa6462..a724006 100644
--- a/src/commands/moderation/slowmode.ts
+++ b/src/commands/moderation/slowmode.ts
@@ -1,6 +1,6 @@
import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
import { Argument } from 'discord-akairo';
-import { type TextChannel, type ThreadChannel } from 'discord.js';
+import { ApplicationCommandOptionType, ChannelType, Permissions, type TextChannel, type ThreadChannel } from 'discord.js';
export default class SlowmodeCommand extends BushCommand {
public constructor() {
@@ -19,7 +19,7 @@ export default class SlowmodeCommand extends BushCommand {
prompt: 'What would you like to set the slowmode to?',
retry: '{error} Please set the slowmode to a valid length.',
optional: true,
- slashType: 'INTEGER'
+ slashType: ApplicationCommandOptionType.Integer
},
{
id: 'channel',
@@ -28,14 +28,15 @@ export default class SlowmodeCommand extends BushCommand {
prompt: 'What channel would you like to change?',
retry: '{error} Choose a valid channel.',
optional: true,
- slashType: 'CHANNEL',
- channelTypes: ['GUILD_TEXT', 'GUILD_PRIVATE_THREAD', 'GUILD_PUBLIC_THREAD']
+ slashType: ApplicationCommandOptionType.Channel,
+ channelTypes: ['GuildText', 'GuildPrivateThread', 'GuildPublicThread']
}
],
slash: true,
channel: 'guild',
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_CHANNELS', 'EMBED_LINKS'], true),
- userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES'])
+ clientPermissions: (m) =>
+ util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_CHANNELS, Permissions.FLAGS.EMBED_LINKS], true),
+ userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES])
});
}
@@ -49,10 +50,10 @@ export default class SlowmodeCommand extends BushCommand {
channel: ArgType<'channel'>;
}
) {
- if (message.channel!.type === 'DM')
+ if (message.channel!.type === ChannelType.DM)
return await message.util.reply(`${util.emojis.error} This command cannot be run in dms.`);
if (!channel) channel = message.channel as any;
- if (!(['GUILD_TEXT', 'GUILD_PRIVATE_THREAD', 'GUILD_PUBLIC_THREAD'] as const).includes(channel.type))
+ if (![ChannelType.GuildText, ChannelType.GuildPrivateThread, ChannelType.GuildPublicThread].includes(channel.type))
return await message.util.reply(`${util.emojis.error} <#${channel.id}> is not a text or thread channel.`);
if (length) {
length =
diff --git a/src/commands/moderation/timeout.ts b/src/commands/moderation/timeout.ts
index ec79271..73b9d50 100644
--- a/src/commands/moderation/timeout.ts
+++ b/src/commands/moderation/timeout.ts
@@ -8,6 +8,7 @@ import {
type BushSlashMessage
} from '#lib';
import assert from 'assert';
+import { ApplicationCommandOptionType, Permissions } from 'discord.js';
export default class TimeoutCommand extends BushCommand {
public constructor() {
@@ -24,7 +25,7 @@ export default class TimeoutCommand extends BushCommand {
type: 'user',
prompt: 'What user would you like to timeout?',
retry: '{error} Choose a valid user to timeout.',
- slashType: 'USER'
+ slashType: ApplicationCommandOptionType.User
},
{
id: 'reason_and_duration',
@@ -33,7 +34,7 @@ export default class TimeoutCommand extends BushCommand {
match: 'rest',
prompt: 'Why should this user be timed out and for how long?',
retry: '{error} Choose a valid timeout reason and duration.',
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
},
{
id: 'force',
@@ -48,8 +49,8 @@ export default class TimeoutCommand extends BushCommand {
],
slash: true,
channel: 'guild',
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MODERATE_MEMBERS']),
- userPermissions: ['MODERATE_MEMBERS']
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MODERATE_MEMBERS]),
+ userPermissions: [Permissions.FLAGS.MODERATE_MEMBERS]
});
}
@@ -101,6 +102,8 @@ export default class TimeoutCommand extends BushCommand {
return `${util.emojis.warn} Timed out ${victim} however I could not send them a dm.`;
case timeoutResponse.SUCCESS:
return `${util.emojis.success} Successfully timed out ${victim}.`;
+ default:
+ return `${util.emojis.error} An error occurred: ${util.format.input(responseCode)}}`;
}
};
return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() });
diff --git a/src/commands/moderation/unban.ts b/src/commands/moderation/unban.ts
index c939792..b2bdd72 100644
--- a/src/commands/moderation/unban.ts
+++ b/src/commands/moderation/unban.ts
@@ -7,6 +7,7 @@ import {
type BushSlashMessage,
type OptionalArgType
} from '#lib';
+import { ApplicationCommandOptionType, Permissions } from 'discord.js';
export default class UnbanCommand extends BushCommand {
public constructor() {
@@ -23,7 +24,7 @@ export default class UnbanCommand extends BushCommand {
type: 'globalUser',
prompt: 'What user would you like to unban?',
retry: '{error} Choose a valid user to unban.',
- slashType: 'USER'
+ slashType: ApplicationCommandOptionType.User
},
{
id: 'reason',
@@ -33,15 +34,16 @@ export default class UnbanCommand extends BushCommand {
prompt: 'Why should this user be unbanned?',
retry: '{error} Choose a valid unban reason.',
optional: true,
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
}
],
slash: true,
channel: 'guild',
- clientPermissions: ['BAN_MEMBERS'],
- userPermissions: ['BAN_MEMBERS']
+ clientPermissions: [Permissions.FLAGS.BAN_MEMBERS],
+ userPermissions: [Permissions.FLAGS.BAN_MEMBERS]
});
}
+
public override async exec(
message: BushMessage | BushSlashMessage,
{ user, reason }: { user: ArgType<'user'>; reason: OptionalArgType<'string'> }
@@ -68,6 +70,8 @@ export default class UnbanCommand extends BushCommand {
case unbanResponse.DM_ERROR:
case unbanResponse.SUCCESS:
return `${util.emojis.success} Successfully unbanned ${victim}.`;
+ default:
+ return `${util.emojis.error} An error occurred: ${util.format.input(responseCode)}}`;
}
};
return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() });
diff --git a/src/commands/moderation/unblock.ts b/src/commands/moderation/unblock.ts
index 454de8b..1abf2be 100644
--- a/src/commands/moderation/unblock.ts
+++ b/src/commands/moderation/unblock.ts
@@ -11,6 +11,7 @@ import {
type OptionalArgType
} from '#lib';
import assert from 'assert';
+import { ApplicationCommandOptionType, Permissions } from 'discord.js';
export default class UnblockCommand extends BushCommand {
public constructor() {
@@ -27,7 +28,7 @@ export default class UnblockCommand extends BushCommand {
type: 'user',
prompt: 'What user would you like to unblock?',
retry: '{error} Choose a valid user to unblock.',
- slashType: 'USER'
+ slashType: ApplicationCommandOptionType.User
},
{
id: 'reason',
@@ -37,7 +38,7 @@ export default class UnblockCommand extends BushCommand {
prompt: 'Why should this user be blocked and for how long?',
retry: '{error} Choose a valid block reason and duration.',
optional: true,
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
},
{
id: 'force',
@@ -52,8 +53,8 @@ export default class UnblockCommand extends BushCommand {
],
slash: true,
channel: 'guild',
- clientPermissions: (m) => util.clientSendAndPermCheck(m, 'MANAGE_CHANNELS'),
- userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES'])
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_CHANNELS]),
+ userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES])
});
}
@@ -102,6 +103,8 @@ export default class UnblockCommand extends BushCommand {
return `${util.emojis.warn} Unblocked ${victim} however I could not send them a dm.`;
case unblockResponse.SUCCESS:
return `${util.emojis.success} Successfully unblocked ${victim}.`;
+ default:
+ return `${util.emojis.error} An error occurred: ${util.format.input(responseCode)}}`;
}
};
return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() });
diff --git a/src/commands/moderation/unlockdown.ts b/src/commands/moderation/unlockdown.ts
index 3d363ac..d7ba5ee 100644
--- a/src/commands/moderation/unlockdown.ts
+++ b/src/commands/moderation/unlockdown.ts
@@ -1,5 +1,6 @@
import { LockdownCommand } from '#commands';
import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage, type OptionalArgType } from '#lib';
+import { ApplicationCommandOptionType, Permissions } from 'discord.js';
export default class UnlockdownCommand extends BushCommand {
public constructor() {
@@ -15,8 +16,8 @@ export default class UnlockdownCommand extends BushCommand {
description: 'Specify a different channel to unlockdown instead of the one you trigger the command in.',
type: util.arg.union('textChannel', 'newsChannel', 'threadChannel'),
prompt: 'What channel would you like to unlockdown?',
- slashType: 'CHANNEL',
- channelTypes: ['GUILD_TEXT', 'GUILD_NEWS', 'GUILD_NEWS_THREAD', 'GUILD_PUBLIC_THREAD', 'GUILD_PRIVATE_THREAD'],
+ slashType: ApplicationCommandOptionType.Channel,
+ channelTypes: ['GuildText', 'GuildNews', 'GuildNewsThread', 'GuildPublicThread', 'GuildPrivateThread'],
optional: true
},
{
@@ -25,7 +26,7 @@ export default class UnlockdownCommand extends BushCommand {
type: 'string',
match: 'rest',
prompt: 'What is the reason for the unlock?',
- slashType: 'STRING',
+ slashType: ApplicationCommandOptionType.String,
optional: true
},
{
@@ -34,14 +35,14 @@ export default class UnlockdownCommand extends BushCommand {
match: 'flag',
flag: '--all',
prompt: 'Would you like to unlockdown all configured channels?',
- slashType: 'BOOLEAN',
+ slashType: ApplicationCommandOptionType.Boolean,
optional: true
}
],
slash: true,
channel: 'guild',
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_CHANNELS']),
- userPermissions: ['MANAGE_CHANNELS']
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_CHANNELS]),
+ userPermissions: [Permissions.FLAGS.MANAGE_CHANNELS]
});
}
diff --git a/src/commands/moderation/unmute.ts b/src/commands/moderation/unmute.ts
index 3bd399f..9974b8d 100644
--- a/src/commands/moderation/unmute.ts
+++ b/src/commands/moderation/unmute.ts
@@ -9,6 +9,7 @@ import {
type BushSlashMessage,
type OptionalArgType
} from '#lib';
+import { ApplicationCommandOptionType, Permissions } from 'discord.js';
export default class UnmuteCommand extends BushCommand {
public constructor() {
@@ -25,7 +26,7 @@ export default class UnmuteCommand extends BushCommand {
type: 'user',
prompt: 'What user would you like to unmute?',
retry: '{error} Choose a valid user to unmute.',
- slashType: 'USER'
+ slashType: ApplicationCommandOptionType.User
},
{
id: 'reason',
@@ -35,7 +36,7 @@ export default class UnmuteCommand extends BushCommand {
prompt: 'Why should this user be unmuted?',
retry: '{error} Choose a valid unmute reason.',
optional: true,
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
},
{
id: 'force',
@@ -50,8 +51,8 @@ export default class UnmuteCommand extends BushCommand {
],
slash: true,
channel: 'guild',
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_ROLES']),
- userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES'])
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_ROLES]),
+ userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES])
});
}
@@ -98,6 +99,8 @@ export default class UnmuteCommand extends BushCommand {
return `${util.emojis.warn} unmuted ${victim} however I could not send them a dm.`;
case unmuteResponse.SUCCESS:
return `${util.emojis.success} Successfully unmuted ${victim}.`;
+ default:
+ return `${util.emojis.error} An error occurred: ${util.format.input(responseCode)}}`;
}
};
return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() });
diff --git a/src/commands/moderation/untimeout.ts b/src/commands/moderation/untimeout.ts
index c5518b4..6ebd777 100644
--- a/src/commands/moderation/untimeout.ts
+++ b/src/commands/moderation/untimeout.ts
@@ -9,6 +9,7 @@ import {
type OptionalArgType
} from '#lib';
import assert from 'assert';
+import { ApplicationCommandOptionType, Permissions } from 'discord.js';
export default class UntimeoutCommand extends BushCommand {
public constructor() {
@@ -25,7 +26,7 @@ export default class UntimeoutCommand extends BushCommand {
type: 'user',
prompt: 'What user would you like to untimeout?',
retry: '{error} Choose a valid user to untimeout.',
- slashType: 'USER'
+ slashType: ApplicationCommandOptionType.User
},
{
id: 'reason',
@@ -34,7 +35,7 @@ export default class UntimeoutCommand extends BushCommand {
match: 'rest',
prompt: 'Why should this user have their timeout removed?',
retry: '{error} Choose a valid reason to remove the timeout.',
- slashType: 'STRING',
+ slashType: ApplicationCommandOptionType.String,
optional: true
},
{
@@ -50,8 +51,8 @@ export default class UntimeoutCommand extends BushCommand {
],
slash: true,
channel: 'guild',
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MODERATE_MEMBERS']),
- userPermissions: ['MODERATE_MEMBERS']
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MODERATE_MEMBERS]),
+ userPermissions: [Permissions.FLAGS.MODERATE_MEMBERS]
});
}
@@ -92,6 +93,8 @@ export default class UntimeoutCommand extends BushCommand {
return `${util.emojis.warn} Removed ${victim}'s timeout however I could not send them a dm.`;
case removeTimeoutResponse.SUCCESS:
return `${util.emojis.success} Successfully removed ${victim}'s timeout.`;
+ default:
+ return `${util.emojis.error} An error occurred: ${util.format.input(responseCode)}}`;
}
};
return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() });
diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts
index aebf300..af45782 100644
--- a/src/commands/moderation/warn.ts
+++ b/src/commands/moderation/warn.ts
@@ -9,6 +9,7 @@ import {
type BushSlashMessage,
type OptionalArgType
} from '#lib';
+import { ApplicationCommandOptionType, Permissions } from 'discord.js';
export default class WarnCommand extends BushCommand {
public constructor() {
@@ -25,7 +26,7 @@ export default class WarnCommand extends BushCommand {
type: 'user',
prompt: 'What user would you like to warn?',
retry: '{error} Choose a valid user to warn.',
- slashType: 'USER'
+ slashType: ApplicationCommandOptionType.User
},
{
id: 'reason',
@@ -33,7 +34,7 @@ export default class WarnCommand extends BushCommand {
match: 'rest',
prompt: 'Why should this user be warned?',
retry: '{error} Choose a valid warn reason.',
- slashType: 'STRING',
+ slashType: ApplicationCommandOptionType.String,
optional: true
},
{
@@ -50,7 +51,7 @@ export default class WarnCommand extends BushCommand {
slash: true,
channel: 'guild',
clientPermissions: (m) => util.clientSendAndPermCheck(m),
- userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES'])
+ userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES])
});
}
@@ -85,6 +86,8 @@ export default class WarnCommand extends BushCommand {
)} time, however I could not send them a dm.`;
case warnResponse.SUCCESS:
return `${util.emojis.success} Successfully warned ${victim} for the ${util.ordinal(caseNum ?? 0)} time.`;
+ default:
+ return `${util.emojis.error} An error occurred: ${util.format.input(response)}}`;
}
};
return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() });
diff --git a/src/commands/moulberry-bush/capePermissions.ts b/src/commands/moulberry-bush/capePermissions.ts
index c873095..19c1381 100644
--- a/src/commands/moulberry-bush/capePermissions.ts
+++ b/src/commands/moulberry-bush/capePermissions.ts
@@ -1,5 +1,5 @@
import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
-import { MessageEmbed } from 'discord.js';
+import { ApplicationCommandOptionType, MessageEmbed, Permissions } from 'discord.js';
import got from 'got';
export default class CapePermissionsCommand extends BushCommand {
@@ -17,11 +17,11 @@ export default class CapePermissionsCommand extends BushCommand {
type: 'string',
prompt: 'Who would you like to see the cape permissions of?',
retry: '{error} Choose someone to see the capes their available capes.',
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
}
],
slash: true,
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: [],
channel: 'guild'
});
diff --git a/src/commands/moulberry-bush/capes.ts b/src/commands/moulberry-bush/capes.ts
index 117fd1c..3a956fc 100644
--- a/src/commands/moulberry-bush/capes.ts
+++ b/src/commands/moulberry-bush/capes.ts
@@ -1,8 +1,9 @@
import { BushCommand, ButtonPaginator, DeleteButton, type BushMessage, type OptionalArgType } from '#lib';
import assert from 'assert';
-import { AutocompleteInteraction, type MessageEmbedOptions } from 'discord.js';
+import { ApplicationCommandOptionType, AutocompleteInteraction, Permissions, type MessageEmbedOptions } from 'discord.js';
import Fuse from 'fuse.js';
import got from 'got';
+
assert(Fuse);
assert(got);
@@ -22,12 +23,12 @@ export default class CapesCommand extends BushCommand {
prompt: 'What cape would you like to see?',
retry: '{error} Choose a cape to see.',
optional: true,
- slashType: 'STRING',
+ slashType: ApplicationCommandOptionType.String,
autocomplete: true
}
],
slash: true,
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: []
});
}
diff --git a/src/commands/moulberry-bush/giveawayPing.ts b/src/commands/moulberry-bush/giveawayPing.ts
index 28f920a..dbbb613 100644
--- a/src/commands/moulberry-bush/giveawayPing.ts
+++ b/src/commands/moulberry-bush/giveawayPing.ts
@@ -1,4 +1,5 @@
import { AllowedMentions, BushCommand, type BushMessage } from '#lib';
+import { Permissions } from 'discord.js';
export default class GiveawayPingCommand extends BushCommand {
public constructor() {
@@ -8,8 +9,14 @@ export default class GiveawayPingCommand extends BushCommand {
description: 'Pings the giveaway role.',
usage: ['giveaway-ping'],
examples: ['giveaway-ping'],
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_MESSAGES'], true),
- userPermissions: ['MANAGE_GUILD', 'MANAGE_MESSAGES', 'BAN_MEMBERS', 'KICK_MEMBERS', 'VIEW_CHANNEL'],
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES], true),
+ userPermissions: [
+ Permissions.FLAGS.MANAGE_GUILD,
+ Permissions.FLAGS.MANAGE_MESSAGES,
+ Permissions.FLAGS.BAN_MEMBERS,
+ Permissions.FLAGS.KICK_MEMBERS,
+ Permissions.FLAGS.VIEW_CHANNEL
+ ],
channel: 'guild',
ignoreCooldown: [],
ignorePermissions: [],
@@ -22,7 +29,7 @@ export default class GiveawayPingCommand extends BushCommand {
}
public override async exec(message: BushMessage) {
- if (!message.member!.permissions.has('MANAGE_GUILD') && !message.member!.user.isOwner())
+ if (!message.member!.permissions.has(Permissions.FLAGS.MANAGE_GUILD) && !message.member!.user.isOwner())
await message.util.reply(`${util.emojis.error} You are missing the **MANAGE_GUILD** permission.`);
await message.delete().catch(() => {});
@@ -47,7 +54,7 @@ export default class GiveawayPingCommand extends BushCommand {
content:
'🎉 <@&767782793261875210> Giveaway.\n\n<:mad:783046135392239626> Spamming, line breaking, gibberish etc. disqualifies you from winning. We can and will ban you from giveaways. Winners will all be checked and rerolled if needed.',
username: `${message.member.nickname || message.author.username}`,
- avatarURL: message.author.avatarURL({ dynamic: true }),
+ avatarURL: message.author.avatarURL(),
allowedMentions: AllowedMentions.roles()
}); */
}
diff --git a/src/commands/moulberry-bush/moulHammer.ts b/src/commands/moulberry-bush/moulHammer.ts
index 6d87571..4cf3f35 100644
--- a/src/commands/moulberry-bush/moulHammer.ts
+++ b/src/commands/moulberry-bush/moulHammer.ts
@@ -1,5 +1,5 @@
import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
-import { MessageEmbed } from 'discord.js';
+import { ApplicationCommandOptionType, MessageEmbed, Permissions } from 'discord.js';
export default class MoulHammerCommand extends BushCommand {
public constructor() {
@@ -16,13 +16,13 @@ export default class MoulHammerCommand extends BushCommand {
type: 'user',
prompt: 'What user would you like to moul hammer?',
retry: '{error} Choose a valid user to moul hammer',
- slashType: 'USER'
+ slashType: ApplicationCommandOptionType.User
}
],
slash: true,
slashGuilds: ['516977525906341928'],
restrictedGuilds: ['516977525906341928'],
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: []
});
}
diff --git a/src/commands/moulberry-bush/report.ts b/src/commands/moulberry-bush/report.ts
index 90abc97..f2c10bc 100644
--- a/src/commands/moulberry-bush/report.ts
+++ b/src/commands/moulberry-bush/report.ts
@@ -1,7 +1,8 @@
import { AllowedMentions, BushCommand, type ArgType, type BushMessage } from '#lib';
import assert from 'assert';
-import { MessageEmbed } from 'discord.js';
+import { ApplicationCommandOptionType, MessageEmbed, Permissions } from 'discord.js';
import moment from 'moment';
+
assert(moment);
export default class ReportCommand extends BushCommand {
@@ -19,7 +20,7 @@ export default class ReportCommand extends BushCommand {
type: 'member',
prompt: 'Who would you like to report?',
retry: '{error} Choose a valid user to report.',
- slashType: 'USER'
+ slashType: ApplicationCommandOptionType.User
},
{
id: 'evidence',
@@ -29,11 +30,11 @@ export default class ReportCommand extends BushCommand {
prompt: 'What did the user do wrong?',
retry: '{error} Provide evidence.',
optional: true,
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
}
],
slash: true,
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: [],
channel: 'guild'
});
@@ -66,7 +67,7 @@ export default class ReportCommand extends BushCommand {
.setTimestamp()
.setAuthor({
name: `Report From: ${message.author.tag}`,
- iconURL: message.author.avatarURL({ dynamic: true }) ?? undefined
+ iconURL: message.author.avatarURL() ?? undefined
})
.setTitle('New Report')
.setColor(util.colors.red)
diff --git a/src/commands/moulberry-bush/rule.ts b/src/commands/moulberry-bush/rule.ts
index 28483a4..1bfcfe7 100644
--- a/src/commands/moulberry-bush/rule.ts
+++ b/src/commands/moulberry-bush/rule.ts
@@ -1,5 +1,5 @@
import { AllowedMentions, BushCommand, BushSlashMessage, type BushMessage, type OptionalArgType } from '#lib';
-import { MessageEmbed } from 'discord.js';
+import { ApplicationCommandOptionType, MessageEmbed, Permissions } from 'discord.js';
const rules = [
{
@@ -68,7 +68,7 @@ export default class RuleCommand extends BushCommand {
prompt: 'What rule would you like to have cited?',
retry: '{error} Choose a valid rule.',
optional: true,
- slashType: 'INTEGER',
+ slashType: ApplicationCommandOptionType.Integer,
minValue: 1,
maxValue: rules.length
},
@@ -79,13 +79,13 @@ export default class RuleCommand extends BushCommand {
prompt: 'What user would you like to mention?',
retry: '{error} Choose a valid user to mention.',
optional: true,
- slashType: 'USER'
+ slashType: ApplicationCommandOptionType.User
}
],
slash: true,
slashGuilds: ['516977525906341928'],
channel: 'guild',
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: [],
restrictedGuilds: ['516977525906341928']
});
@@ -99,7 +99,7 @@ export default class RuleCommand extends BushCommand {
.setColor('#ef3929')
.setFooter({
text: `Triggered by ${message.author.tag}`,
- iconURL: message.author.avatarURL({ dynamic: true }) ?? undefined
+ iconURL: message.author.avatarURL() ?? undefined
})
.setTimestamp();
diff --git a/src/commands/moulberry-bush/serverStatus.ts b/src/commands/moulberry-bush/serverStatus.ts
index 3d8e780..28b38a5 100644
--- a/src/commands/moulberry-bush/serverStatus.ts
+++ b/src/commands/moulberry-bush/serverStatus.ts
@@ -1,7 +1,8 @@
import { BushCommand, type BushMessage } from '#lib';
import assert from 'assert';
-import { MessageEmbed } from 'discord.js';
+import { MessageEmbed, Permissions } from 'discord.js';
import got from 'got';
+
assert(got);
export default class ServerStatusCommand extends BushCommand {
@@ -12,7 +13,7 @@ export default class ServerStatusCommand extends BushCommand {
description: "Gives the status of moulberry's server",
usage: ['server-status'],
examples: ['server-status', 'ss'],
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: [],
slash: true
});
diff --git a/src/commands/utilities/activity.ts b/src/commands/utilities/activity.ts
index 28d466b..948f82a 100644
--- a/src/commands/utilities/activity.ts
+++ b/src/commands/utilities/activity.ts
@@ -1,6 +1,6 @@
import { BushCommand, type ArgType, type BushArgumentTypeCaster, type BushMessage, type BushSlashMessage } from '#lib';
import { type ArgumentOptions, type ArgumentTypeCaster, type Flag } from 'discord-akairo';
-import { type DiscordAPIError, type Snowflake } from 'discord.js';
+import { ApplicationCommandOptionType, ChannelType, type DiscordAPIError, type Snowflake } from 'discord.js';
const activityMap = {
'Poker Night': {
@@ -93,8 +93,8 @@ export default class ActivityCommand extends BushCommand {
description: 'The channel to create the activity in.',
type: 'voiceChannel',
prompt: 'What channel would you like to use?',
- slashType: 'CHANNEL',
- channelTypes: ['GUILD_VOICE'],
+ slashType: ApplicationCommandOptionType.Channel,
+ channelTypes: ['GuildVoice'],
only: 'slash'
},
{
@@ -107,7 +107,7 @@ export default class ActivityCommand extends BushCommand {
.flatMap((a) => a.aliases)
.map((a) => `\`${a}\``)
.join(', ')}.`,
- slashType: 'STRING',
+ slashType: ApplicationCommandOptionType.String,
choices: Object.keys(activityMap).map((key) => ({
name: key,
value: activityMap[key as keyof typeof activityMap].id
@@ -155,7 +155,7 @@ export default class ActivityCommand extends BushCommand {
args: { channel: ArgType<'voiceChannel'>; activity: string }
) {
const channel = typeof args.channel === 'string' ? message.guild?.channels.cache.get(args.channel) : args.channel;
- if (!channel || channel.type !== 'GUILD_VOICE')
+ if (!channel || channel.type !== ChannelType.GuildVoice)
return await message.util.reply(`${util.emojis.error} Choose a valid voice channel`);
const target_application_id = message.util.isSlashMessage(message)
diff --git a/src/commands/utilities/calculator.ts b/src/commands/utilities/calculator.ts
index 2eeb3a6..df79cc2 100644
--- a/src/commands/utilities/calculator.ts
+++ b/src/commands/utilities/calculator.ts
@@ -1,7 +1,8 @@
import { AllowedMentions, BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
import assert from 'assert';
-import { MessageEmbed } from 'discord.js';
+import { ApplicationCommandOptionType, MessageEmbed } from 'discord.js';
import { evaluate } from 'mathjs';
+
assert(evaluate);
export default class CalculatorCommand extends BushCommand {
@@ -20,7 +21,7 @@ export default class CalculatorCommand extends BushCommand {
match: 'rest',
prompt: 'What would you like to calculate?',
retry: '{error} Pick something to calculate.',
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
}
],
slash: true,
@@ -28,6 +29,7 @@ export default class CalculatorCommand extends BushCommand {
userPermissions: []
});
}
+
public override async exec(message: BushMessage | BushSlashMessage, args: { expression: string }) {
const decodedEmbed = new MessageEmbed().addField('📥 Input', await util.inspectCleanRedactCodeblock(args.expression, 'mma'));
try {
diff --git a/src/commands/utilities/decode.ts b/src/commands/utilities/decode.ts
index 76f735b..f5d8920 100644
--- a/src/commands/utilities/decode.ts
+++ b/src/commands/utilities/decode.ts
@@ -1,6 +1,6 @@
import { AllowedMentions, BushCommand, type BushMessage } from '#lib';
import { type AkairoMessage } from 'discord-akairo';
-import { MessageEmbed } from 'discord.js';
+import { ApplicationCommandOptionType, MessageEmbed } from 'discord.js';
const encodingTypesArray = ['ascii', 'utf8', 'utf-8', 'utf16le', 'ucs2', 'ucs-2', 'base64', 'latin1', 'binary', 'hex'];
const encodingTypesString = encodingTypesArray.map((e) => `\`${e}\``).join(', ');
@@ -20,7 +20,7 @@ export default class DecodeCommand extends BushCommand {
customType: encodingTypesArray,
prompt: 'What is the encoding of the original data?',
retry: `{error} Choose one of the following ${encodingTypesString} for the encoding of the original data.`,
- slashType: 'STRING',
+ slashType: ApplicationCommandOptionType.String,
choices: encodingTypesArray.map((e) => ({ name: e, value: e }))
},
{
@@ -29,7 +29,7 @@ export default class DecodeCommand extends BushCommand {
customType: encodingTypesArray,
prompt: 'What would you like the encoding of the resulting data to be?',
retry: `{error} Choose one of the following ${encodingTypesString} for the encoding of the resulting data.`,
- slashType: 'STRING',
+ slashType: ApplicationCommandOptionType.String,
choices: encodingTypesArray.map((e) => ({ name: e, value: e }))
},
{
@@ -39,7 +39,7 @@ export default class DecodeCommand extends BushCommand {
match: 'restContent',
prompt: 'What would you to decode.',
retry: '{error} Choose a valid string to decode.',
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
}
],
slash: true,
diff --git a/src/commands/utilities/hash.ts b/src/commands/utilities/hash.ts
index 7e892f5..7cc59f3 100644
--- a/src/commands/utilities/hash.ts
+++ b/src/commands/utilities/hash.ts
@@ -1,7 +1,9 @@
import { BushCommand, type BushMessage } from '#lib';
import assert from 'assert';
import crypto from 'crypto';
+import { ApplicationCommandOptionType } from 'discord.js';
import got from 'got';
+
assert(crypto);
assert(got);
@@ -20,7 +22,7 @@ export default class HashCommand extends BushCommand {
type: 'url',
prompt: 'What url would you like to find the hash of?',
retry: '{error} Enter a valid url.',
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
}
],
clientPermissions: (m) => util.clientSendAndPermCheck(m),
diff --git a/src/commands/utilities/price.ts b/src/commands/utilities/price.ts
index 409f544..9fb79bc 100644
--- a/src/commands/utilities/price.ts
+++ b/src/commands/utilities/price.ts
@@ -1,8 +1,9 @@
import { BushCommand, type BushMessage } from '#lib';
import assert from 'assert';
-import { AutocompleteInteraction, MessageEmbed } from 'discord.js';
+import { ApplicationCommandOptionType, AutocompleteInteraction, MessageEmbed, Permissions } from 'discord.js';
import Fuse from 'fuse.js';
import got from 'got';
+
assert(Fuse);
assert(got);
@@ -24,7 +25,7 @@ export default class PriceCommand extends BushCommand {
match: 'content',
prompt: 'What item would you like to find the price of?',
retry: '{error} Choose a valid item.',
- slashType: 'STRING',
+ slashType: ApplicationCommandOptionType.String,
autocomplete: true
},
{
@@ -34,11 +35,11 @@ export default class PriceCommand extends BushCommand {
flag: '--strict',
prompt: 'Would you like to bypass the fuzzy search?',
optional: true,
- slashType: 'BOOLEAN'
+ slashType: ApplicationCommandOptionType.Boolean
}
],
slash: true,
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: [],
typing: true
});
diff --git a/src/commands/utilities/remind.ts b/src/commands/utilities/remind.ts
index 6339343..4b7ccb9 100644
--- a/src/commands/utilities/remind.ts
+++ b/src/commands/utilities/remind.ts
@@ -1,4 +1,5 @@
import { BushCommand, Reminder, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { ApplicationCommandOptionType } from 'discord.js';
export default class RemindCommand extends BushCommand {
public constructor() {
@@ -17,7 +18,7 @@ export default class RemindCommand extends BushCommand {
prompt: 'What would you like to be reminded about and when?',
retry: '{error} Choose a reason to be reminded about with a duration for when to be notified.',
optional: true,
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
}
],
slash: true,
diff --git a/src/commands/utilities/reminders.ts b/src/commands/utilities/reminders.ts
index 8b4124d..40ec9a2 100644
--- a/src/commands/utilities/reminders.ts
+++ b/src/commands/utilities/reminders.ts
@@ -1,7 +1,8 @@
import { BushCommand, ButtonPaginator, Reminder, type BushMessage, type BushSlashMessage } from '#lib';
import assert from 'assert';
-import { type MessageEmbedOptions } from 'discord.js';
+import { Permissions, type MessageEmbedOptions } from 'discord.js';
import { Op } from 'sequelize';
+
assert(Op);
export default class RemindersCommand extends BushCommand {
@@ -13,7 +14,7 @@ export default class RemindersCommand extends BushCommand {
usage: ['reminder'],
examples: ['reminders'],
slash: true,
- clientPermissions: (m) => util.clientSendAndPermCheck(m, 'EMBED_LINKS'),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS]),
userPermissions: []
});
}
diff --git a/src/commands/utilities/steal.ts b/src/commands/utilities/steal.ts
index 834fc10..a963746 100644
--- a/src/commands/utilities/steal.ts
+++ b/src/commands/utilities/steal.ts
@@ -1,8 +1,10 @@
import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
import assert from 'assert';
import { type ArgumentOptions, type ArgumentType, type ArgumentTypeCaster, type Flag } from 'discord-akairo';
+import { ApplicationCommandOptionType, Permissions } from 'discord.js';
import _ from 'lodash';
import { URL } from 'url';
+
assert(_);
export default class StealCommand extends BushCommand {
@@ -23,7 +25,7 @@ export default class StealCommand extends BushCommand {
retry: '{error} Pick a valid emoji, emoji id, or image url.',
optional: true,
only: 'slash',
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
},
{
id: 'name',
@@ -32,13 +34,13 @@ export default class StealCommand extends BushCommand {
retry: '{error} Choose a valid name fore the emoji.',
optional: true,
only: 'slash',
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
}
],
slash: true,
channel: 'guild',
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_EMOJIS_AND_STICKERS']),
- userPermissions: ['MANAGE_EMOJIS_AND_STICKERS']
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_EMOJIS_AND_STICKERS]),
+ userPermissions: [Permissions.FLAGS.MANAGE_EMOJIS_AND_STICKERS]
});
}
@@ -106,9 +108,10 @@ export default class StealCommand extends BushCommand {
if (!(creationSuccess instanceof Error))
return await message.util.reply(`${util.emojis.success} You successfully stole ${creationSuccess}.`);
- else
+ else {
return await message.util.reply(
`${util.emojis.error} The was an error stealing that emoji \`${creationSuccess.message}\`.`
);
+ }
}
}
diff --git a/src/commands/utilities/uuid.ts b/src/commands/utilities/uuid.ts
index d842b58..4df9132 100644
--- a/src/commands/utilities/uuid.ts
+++ b/src/commands/utilities/uuid.ts
@@ -1,4 +1,5 @@
import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
+import { ApplicationCommandOptionType } from 'discord.js';
export default class UuidCommand extends BushCommand {
public constructor() {
@@ -16,7 +17,7 @@ export default class UuidCommand extends BushCommand {
readableType: 'ign',
prompt: 'What ign would you like to find the uuid of?',
retry: '{error} Choose a valid ign.',
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
},
{
id: 'dashed',
@@ -24,7 +25,7 @@ export default class UuidCommand extends BushCommand {
match: 'flag',
flag: '--dashed',
prompt: 'Would you like to include dashes in the uuid?',
- slashType: 'BOOLEAN',
+ slashType: ApplicationCommandOptionType.Boolean,
optional: true
}
],
diff --git a/src/commands/utilities/viewRaw.ts b/src/commands/utilities/viewRaw.ts
index b524b3c..4b1ff1e 100644
--- a/src/commands/utilities/viewRaw.ts
+++ b/src/commands/utilities/viewRaw.ts
@@ -7,7 +7,7 @@ import {
type BushTextChannel,
type OptionalArgType
} from '#lib';
-import { Message, MessageEmbed, type Snowflake } from 'discord.js';
+import { ApplicationCommandOptionType, Message, MessageEmbed, Permissions, type Snowflake } from 'discord.js';
export default class ViewRawCommand extends BushCommand {
public constructor() {
@@ -25,7 +25,7 @@ export default class ViewRawCommand extends BushCommand {
readableType: 'guildMessage|messageLink',
prompt: 'What message would you like to view?',
retry: '{error} Choose a valid message.',
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
},
{
id: 'channel',
@@ -34,8 +34,8 @@ export default class ViewRawCommand extends BushCommand {
prompt: 'What channel is the message in?',
retry: '{error} Choose a valid channel.',
optional: true,
- slashType: 'CHANNEL',
- channelTypes: util.discordConstants.TextBasedChannelTypes
+ slashType: ApplicationCommandOptionType.Channel,
+ channelTypes: ['GuildText', 'DM', 'GuildNews', 'GuildNewsThread', 'GuildPublicThread', 'GuildPrivateThread']
},
{
id: 'json',
@@ -43,7 +43,7 @@ export default class ViewRawCommand extends BushCommand {
match: 'flag',
flag: '--json',
prompt: 'Would you like to view the raw JSON message data?',
- slashType: 'BOOLEAN',
+ slashType: ApplicationCommandOptionType.Boolean,
optional: true
},
{
@@ -52,13 +52,13 @@ export default class ViewRawCommand extends BushCommand {
match: 'flag',
flag: '--js',
prompt: 'Would you like to view the raw message data?',
- slashType: 'BOOLEAN',
+ slashType: ApplicationCommandOptionType.Boolean,
optional: true
}
],
slash: true,
channel: 'guild',
- clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true),
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true),
userPermissions: []
});
}
@@ -96,7 +96,7 @@ export default class ViewRawCommand extends BushCommand {
: message.content || '[No Content]';
const lang = options.json ? 'json' : options.js ? 'js' : undefined;
return new MessageEmbed()
- .setFooter({ text: message.author.tag, iconURL: message.author.avatarURL({ dynamic: true }) ?? undefined })
+ .setFooter({ text: message.author.tag, iconURL: message.author.avatarURL() ?? undefined })
.setTimestamp(message.createdTimestamp)
.setColor(message.member?.roles?.color?.color ?? util.colors.default)
.setTitle('Raw Message Information')
diff --git a/src/commands/utilities/whoHasRole.ts b/src/commands/utilities/whoHasRole.ts
index 60543c1..4993528 100644
--- a/src/commands/utilities/whoHasRole.ts
+++ b/src/commands/utilities/whoHasRole.ts
@@ -1,5 +1,5 @@
import { BushCommand, ButtonPaginator, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
-import { Util, type CommandInteraction } from 'discord.js';
+import { ApplicationCommandOptionType, Util, type CommandInteraction } from 'discord.js';
export default class WhoHasRoleCommand extends BushCommand {
public constructor() {
@@ -17,7 +17,7 @@ export default class WhoHasRoleCommand extends BushCommand {
prompt: 'What role would you like to find the users of?',
retry: '{error} Pick a valid role.',
optional: false,
- slashType: 'ROLE'
+ slashType: ApplicationCommandOptionType.Role
}
],
slash: true,
@@ -27,6 +27,7 @@ export default class WhoHasRoleCommand extends BushCommand {
typing: true
});
}
+
public override async exec(message: BushMessage | BushSlashMessage, args: { role: ArgType<'role'> }) {
if (message.util.isSlash) await (message.interaction as CommandInteraction).deferReply();
const roleMembers = args.role.members.map((member) => `${member.user} (${Util.escapeMarkdown(member.user.tag)})`);
diff --git a/src/commands/utilities/wolframAlpha.ts b/src/commands/utilities/wolframAlpha.ts
index 6d8342c..984d617 100644
--- a/src/commands/utilities/wolframAlpha.ts
+++ b/src/commands/utilities/wolframAlpha.ts
@@ -1,7 +1,8 @@
import { AllowedMentions, BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
import { initializeClass as WolframAlphaAPI } from '@notenoughupdates/wolfram-alpha-api';
import assert from 'assert';
-import { MessageEmbed, type MessageOptions } from 'discord.js';
+import { ApplicationCommandOptionType, MessageEmbed, type MessageOptions } from 'discord.js';
+
assert(WolframAlphaAPI);
export default class WolframAlphaCommand extends BushCommand {
@@ -20,7 +21,7 @@ export default class WolframAlphaCommand extends BushCommand {
match: 'rest',
prompt: 'What would you like to look up?',
retry: '{error} Pick something to look up.',
- slashType: 'STRING'
+ slashType: ApplicationCommandOptionType.String
},
{
id: 'image',
@@ -28,7 +29,7 @@ export default class WolframAlphaCommand extends BushCommand {
match: 'flag',
flag: '--image',
prompt: 'Would you like to use the Simple API instead of the Short Answers API?',
- slashType: 'BOOLEAN',
+ slashType: ApplicationCommandOptionType.Boolean,
optional: true
}
],
@@ -37,6 +38,7 @@ export default class WolframAlphaCommand extends BushCommand {
userPermissions: []
});
}
+
public override async exec(message: BushMessage | BushSlashMessage, args: { expression: string; image: boolean }) {
if (message.util.isSlashMessage(message)) await message.interaction.deferReply();