aboutsummaryrefslogtreecommitdiff
path: root/src/commands/config
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/config
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/config')
-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
6 files changed, 84 insertions, 58 deletions
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]
});
}