diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-01-25 23:47:40 -0500 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-01-25 23:47:40 -0500 |
commit | 840cca672d681c36f980a06fb79a4e2c01bd69ac (patch) | |
tree | 82c40a7fe3e1a2bc6367fed6e3d26b6c7dceb256 /src/commands/utilities | |
parent | 6ca99336a416389dd2b0b8c4c6a7b2ef87bc9fef (diff) | |
download | tanzanite-840cca672d681c36f980a06fb79a4e2c01bd69ac.tar.gz tanzanite-840cca672d681c36f980a06fb79a4e2c01bd69ac.tar.bz2 tanzanite-840cca672d681c36f980a06fb79a4e2c01bd69ac.zip |
I love breaking changes!!!!
Diffstat (limited to 'src/commands/utilities')
-rw-r--r-- | src/commands/utilities/activity.ts | 2 | ||||
-rw-r--r-- | src/commands/utilities/calculator.ts | 11 | ||||
-rw-r--r-- | src/commands/utilities/decode.ts | 17 | ||||
-rw-r--r-- | src/commands/utilities/price.ts | 29 | ||||
-rw-r--r-- | src/commands/utilities/reminders.ts | 5 | ||||
-rw-r--r-- | src/commands/utilities/suicide.ts | 20 | ||||
-rw-r--r-- | src/commands/utilities/viewRaw.ts | 19 | ||||
-rw-r--r-- | src/commands/utilities/wolframAlpha.ts | 13 |
8 files changed, 68 insertions, 48 deletions
diff --git a/src/commands/utilities/activity.ts b/src/commands/utilities/activity.ts index 948f82a..5a56978 100644 --- a/src/commands/utilities/activity.ts +++ b/src/commands/utilities/activity.ts @@ -94,7 +94,7 @@ export default class ActivityCommand extends BushCommand { type: 'voiceChannel', prompt: 'What channel would you like to use?', slashType: ApplicationCommandOptionType.Channel, - channelTypes: ['GuildVoice'], + channelTypes: [ChannelType.GuildVoice], only: 'slash' }, { diff --git a/src/commands/utilities/calculator.ts b/src/commands/utilities/calculator.ts index df79cc2..7492fc5 100644 --- a/src/commands/utilities/calculator.ts +++ b/src/commands/utilities/calculator.ts @@ -1,6 +1,6 @@ import { AllowedMentions, BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; import assert from 'assert'; -import { ApplicationCommandOptionType, MessageEmbed } from 'discord.js'; +import { ApplicationCommandOptionType, Embed } from 'discord.js'; import { evaluate } from 'mathjs'; assert(evaluate); @@ -31,18 +31,21 @@ export default class CalculatorCommand extends BushCommand { } public override async exec(message: BushMessage | BushSlashMessage, args: { expression: string }) { - const decodedEmbed = new MessageEmbed().addField('📥 Input', await util.inspectCleanRedactCodeblock(args.expression, 'mma')); + const decodedEmbed = new Embed().addField({ + name: '📥 Input', + value: await util.inspectCleanRedactCodeblock(args.expression, 'mma') + }); try { const calculated = /^(9\s*?\+\s*?10)|(10\s*?\+\s*?9)$/.test(args.expression) ? '21' : evaluate(args.expression); decodedEmbed .setTitle(`${util.emojis.successFull} Successfully Calculated Expression`) .setColor(util.colors.success) - .addField('📤 Output', await util.inspectCleanRedactCodeblock(calculated.toString(), 'mma')); + .addField({ name: '📤 Output', value: await util.inspectCleanRedactCodeblock(calculated.toString(), 'mma') }); } catch (error) { decodedEmbed .setTitle(`${util.emojis.errorFull} Unable to Calculate Expression`) .setColor(util.colors.error) - .addField(`📤 Error`, await util.inspectCleanRedactCodeblock(`${error.name}: ${error.message}`, 'js')); + .addField({ name: `📤 Error`, value: await util.inspectCleanRedactCodeblock(`${error.name}: ${error.message}`, 'js') }); } return await message.util.reply({ embeds: [decodedEmbed], allowedMentions: AllowedMentions.none() }); } diff --git a/src/commands/utilities/decode.ts b/src/commands/utilities/decode.ts index f5d8920..00420da 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 { ApplicationCommandOptionType, MessageEmbed } from 'discord.js'; +import { ApplicationCommandOptionType, Embed } from 'discord.js'; const encodingTypesArray = ['ascii', 'utf8', 'utf-8', 'utf16le', 'ucs2', 'ucs-2', 'base64', 'latin1', 'binary', 'hex']; const encodingTypesString = encodingTypesArray.map((e) => `\`${e}\``).join(', '); @@ -53,16 +53,19 @@ export default class DecodeCommand extends BushCommand { { from, to, data }: { from: BufferEncoding; to: BufferEncoding; data: string } ) { const encodeOrDecode = util.capitalizeFirstLetter(message?.util?.parsed?.alias ?? 'decoded'); - const decodedEmbed = new MessageEmbed() + const decodedEmbed = new Embed() .setTitle(`${encodeOrDecode} Information`) - .addField('📥 Input', await util.inspectCleanRedactCodeblock(data)); + .addField({ name: '📥 Input', value: await util.inspectCleanRedactCodeblock(data) }); try { const decoded = Buffer.from(data, from).toString(to); - decodedEmbed.setColor(util.colors.success).addField('📤 Output', await util.inspectCleanRedactCodeblock(decoded)); - } catch (error) { decodedEmbed - .setColor(util.colors.error) - .addField(`📤 Error ${encodeOrDecode.slice(1)}ing`, await util.inspectCleanRedactCodeblock(error?.stack ?? error)); + .setColor(util.colors.success) + .addField({ name: '📤 Output', value: await util.inspectCleanRedactCodeblock(decoded) }); + } catch (error) { + decodedEmbed.setColor(util.colors.error).addField({ + name: `📤 Error ${encodeOrDecode.slice(1)}ing`, + value: await util.inspectCleanRedactCodeblock(error?.stack ?? error) + }); } return await message.util.reply({ embeds: [decodedEmbed], allowedMentions: AllowedMentions.none() }); } diff --git a/src/commands/utilities/price.ts b/src/commands/utilities/price.ts index 9fb79bc..2df70b7 100644 --- a/src/commands/utilities/price.ts +++ b/src/commands/utilities/price.ts @@ -1,6 +1,6 @@ import { BushCommand, type BushMessage } from '#lib'; import assert from 'assert'; -import { ApplicationCommandOptionType, AutocompleteInteraction, MessageEmbed, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, AutocompleteInteraction, Embed, Permissions } from 'discord.js'; import Fuse from 'fuse.js'; import got from 'got'; @@ -58,7 +58,7 @@ export default class PriceCommand extends BushCommand { ])) as [Bazaar, LowestBIN, LowestBIN, AuctionAverages]; let parsedItem = item.toString().toUpperCase().replace(/ /g, '_').replace(/'S/g, ''); - const priceEmbed = new MessageEmbed(); + const priceEmbed = new Embed(); if (bazaar?.success === false) errors.push('bazaar'); @@ -86,17 +86,17 @@ export default class PriceCommand extends BushCommand { // if its a bazaar item then it there should not be any ah data if (bazaar['products']?.[parsedItem]) { - const bazaarPriceEmbed = new MessageEmbed() + const bazaarPriceEmbed = new Embed() .setColor(errors?.length ? util.colors.warn : util.colors.success) .setTitle(`Bazaar Information for **${parsedItem}**`) - .addField('Sell Price', addBazaarInformation('sellPrice', 2, true)) - .addField('Buy Price', addBazaarInformation('buyPrice', 2, true)) - .addField( - 'Margin', - (+addBazaarInformation('buyPrice', 2, false) - +addBazaarInformation('sellPrice', 2, false)).toLocaleString() - ) - .addField('Current Sell Orders', addBazaarInformation('sellOrders', 0, true)) - .addField('Current Buy Orders', addBazaarInformation('buyOrders', 0, true)); + .addField({ name: 'Sell Price', value: addBazaarInformation('sellPrice', 2, true) }) + .addField({ name: 'Buy Price', value: addBazaarInformation('buyPrice', 2, true) }) + .addField({ + name: 'Margin', + value: (+addBazaarInformation('buyPrice', 2, false) - +addBazaarInformation('sellPrice', 2, false)).toLocaleString() + }) + .addField({ name: 'Current Sell Orders', value: addBazaarInformation('sellOrders', 0, true) }) + .addField({ name: 'Current Buy Orders', value: addBazaarInformation('buyOrders', 0, true) }); return await message.util.reply({ embeds: [bazaarPriceEmbed] }); } @@ -107,7 +107,7 @@ export default class PriceCommand extends BushCommand { .setTitle(`Price Information for \`${parsedItem}\``) .setFooter({ text: 'All information is based on the last 3 days.' }); } else { - const errorEmbed = new MessageEmbed(); + const errorEmbed = new Embed(); errorEmbed .setColor(util.colors.error) .setDescription(`${util.emojis.error} \`${parsedItem}\` is not a valid item id, or it has no auction data.`); @@ -136,7 +136,10 @@ export default class PriceCommand extends BushCommand { } function addPrice(name: string, price: number | undefined) { if (price) - priceEmbed.addField(name, price.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })); + priceEmbed.addField({ + name: name, + value: price.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 }) + }); } } diff --git a/src/commands/utilities/reminders.ts b/src/commands/utilities/reminders.ts index 40ec9a2..369a1a5 100644 --- a/src/commands/utilities/reminders.ts +++ b/src/commands/utilities/reminders.ts @@ -1,6 +1,7 @@ import { BushCommand, ButtonPaginator, Reminder, type BushMessage, type BushSlashMessage } from '#lib'; import assert from 'assert'; -import { Permissions, type MessageEmbedOptions } from 'discord.js'; +import { APIEmbed } from 'discord-api-types'; +import { Permissions } from 'discord.js'; import { Op } from 'sequelize'; assert(Op); @@ -26,7 +27,7 @@ export default class RemindersCommand extends BushCommand { const formattedReminders = reminders.map((reminder) => `${util.timestamp(reminder.expires, 't')} - ${reminder.content}`); const chunked = util.chunk(formattedReminders, 15); - const embeds: MessageEmbedOptions[] = chunked.map((chunk) => ({ + const embeds: APIEmbed[] = chunked.map((chunk) => ({ title: `Reminders`, description: chunk.join('\n'), color: util.colors.default diff --git a/src/commands/utilities/suicide.ts b/src/commands/utilities/suicide.ts index d880215..293008c 100644 --- a/src/commands/utilities/suicide.ts +++ b/src/commands/utilities/suicide.ts @@ -1,5 +1,5 @@ import { AllowedMentions, BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; -import { MessageEmbed } from 'discord.js'; +import { Embed } from 'discord.js'; export default class SuicideCommand extends BushCommand { public constructor() { @@ -18,7 +18,7 @@ export default class SuicideCommand extends BushCommand { public override async exec(message: BushMessage | BushSlashMessage) { // stolen from https://github.com/dexbiobot/Zeppelin - const suicideEmbed = new MessageEmbed() + const suicideEmbed = new Embed() .setTitle('Mental Health Resources') .setColor(util.colors.red) .setAuthor({ @@ -26,23 +26,23 @@ export default class SuicideCommand extends BushCommand { iconURL: 'https://media.discordapp.net/attachments/770256340639416320/854689949193076737/Medical_31-60_974.jpg?width=523&height=523' }) - .addField( - '**National Suicide Prevention Hotline (U.S.):**', - [ + .addField({ + name: '**National Suicide Prevention Hotline (U.S.):**', + value: [ '**Call:** 1-800-273-8255, available 24/7 for emotional support', '**Text: HOME** to 741741', 'https://suicidepreventionlifeline.org/chat/', '', '**Outside the U.S**: Find a supportive resource on [this Wikipedia list of worldwide crisis hotlines](https://en.wikipedia.org/wiki/List_of_suicide_crisis_lines)' ].join('\n') - ) - .addField( - '**More Support**', - [ + }) + .addField({ + name: '**More Support**', + value: [ 'For Substance Abuse Support, Eating Disorder Support & Child Abuse and Domestic Violence:', "[Click to go to Discord's Health & Safety Page](https://discord.com/safety/360044103771-Mental-health-on-Discord#h_01EGRGT08QSZ5BNCH2E9HN0NYV)" ].join('\n') - ); + }); return message.util.send({ embeds: [suicideEmbed], diff --git a/src/commands/utilities/viewRaw.ts b/src/commands/utilities/viewRaw.ts index 4b1ff1e..fc50e31 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 { ApplicationCommandOptionType, Message, MessageEmbed, Permissions, type Snowflake } from 'discord.js'; +import { ApplicationCommandOptionType, ChannelType, Embed, Message, Permissions, type Snowflake } from 'discord.js'; export default class ViewRawCommand extends BushCommand { public constructor() { @@ -35,7 +35,14 @@ export default class ViewRawCommand extends BushCommand { retry: '{error} Choose a valid channel.', optional: true, slashType: ApplicationCommandOptionType.Channel, - channelTypes: ['GuildText', 'DM', 'GuildNews', 'GuildNewsThread', 'GuildPublicThread', 'GuildPrivateThread'] + channelTypes: [ + ChannelType.GuildText, + ChannelType.DM, + ChannelType.GuildNews, + ChannelType.GuildNewsThread, + ChannelType.GuildPublicThread, + ChannelType.GuildPrivateThread + ] }, { id: 'json', @@ -82,12 +89,12 @@ export default class ViewRawCommand extends BushCommand { `${util.emojis.error} There was an error fetching that message, make sure that is a valid id and if the message is not in this channel, please provide a channel.` ); - const messageEmbed = await ViewRawCommand.getRawData(newMessage as BushMessage, { json: args.json, js: args.js }); + const Embed = await ViewRawCommand.getRawData(newMessage as BushMessage, { json: args.json, js: args.js }); - return await message.util.reply({ embeds: [messageEmbed] }); + return await message.util.reply({ embeds: [Embed] }); } - public static async getRawData(message: BushMessage, options: { json?: boolean; js: boolean }): Promise<MessageEmbed> { + public static async getRawData(message: BushMessage, options: { json?: boolean; js: boolean }): Promise<Embed> { const content = options.json || options.js ? options.json @@ -95,7 +102,7 @@ export default class ViewRawCommand extends BushCommand { : util.inspect(message.toJSON()) || '[No Content]' : message.content || '[No Content]'; const lang = options.json ? 'json' : options.js ? 'js' : undefined; - return new MessageEmbed() + return new Embed() .setFooter({ text: message.author.tag, iconURL: message.author.avatarURL() ?? undefined }) .setTimestamp(message.createdTimestamp) .setColor(message.member?.roles?.color?.color ?? util.colors.default) diff --git a/src/commands/utilities/wolframAlpha.ts b/src/commands/utilities/wolframAlpha.ts index 984d617..f8e5c22 100644 --- a/src/commands/utilities/wolframAlpha.ts +++ b/src/commands/utilities/wolframAlpha.ts @@ -1,7 +1,7 @@ import { AllowedMentions, BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; import { initializeClass as WolframAlphaAPI } from '@notenoughupdates/wolfram-alpha-api'; import assert from 'assert'; -import { ApplicationCommandOptionType, MessageEmbed, type MessageOptions } from 'discord.js'; +import { ApplicationCommandOptionType, Embed, type MessageOptions } from 'discord.js'; assert(WolframAlphaAPI); @@ -45,7 +45,10 @@ export default class WolframAlphaCommand extends BushCommand { args.image && void message.util.reply({ content: `${util.emojis.loading} Loading...`, embeds: [] }); const waApi = WolframAlphaAPI(client.config.credentials.wolframAlphaAppId); - const decodedEmbed = new MessageEmbed().addField('📥 Input', await util.inspectCleanRedactCodeblock(args.expression)); + const decodedEmbed = new Embed().addField({ + name: '📥 Input', + value: await util.inspectCleanRedactCodeblock(args.expression) + }); const sendOptions: MessageOptions = { content: null, allowedMentions: AllowedMentions.none() }; try { const calculated = await (args.image @@ -55,15 +58,15 @@ export default class WolframAlphaCommand extends BushCommand { if (args.image) { decodedEmbed.setImage(await util.uploadImageToImgur(calculated.split(',')[1])); - decodedEmbed.addField('📤 Output', '​'); + decodedEmbed.addField({ name: '📤 Output', value: '​' }); } else { - decodedEmbed.addField('📤 Output', await util.inspectCleanRedactCodeblock(calculated.toString())); + decodedEmbed.addField({ name: '📤 Output', value: await util.inspectCleanRedactCodeblock(calculated.toString()) }); } } catch (error) { decodedEmbed .setTitle(`${util.emojis.errorFull} Unable to Query Expression`) .setColor(util.colors.error) - .addField(`📤 Error`, await util.inspectCleanRedactCodeblock(`${error.name}: ${error.message}`, 'js')); + .addField({ name: `📤 Error`, value: await util.inspectCleanRedactCodeblock(`${error.name}: ${error.message}`, 'js') }); } sendOptions.embeds = [decodedEmbed]; |