aboutsummaryrefslogtreecommitdiff
path: root/src/commands/utilities
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/utilities
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/utilities')
-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
12 files changed, 53 insertions, 39 deletions
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();