diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-04-20 18:37:22 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-04-20 18:37:22 -0400 |
commit | f01be2e3ce820e5737416180efa3e5852ece72c4 (patch) | |
tree | a972af929940173e4e2d9f843124a8dfb293bc90 /src/lib/extensions/discord-akairo | |
parent | bcb3dc5fcd21f7626d4c5a8c009dca5658a4436b (diff) | |
download | tanzanite-f01be2e3ce820e5737416180efa3e5852ece72c4.tar.gz tanzanite-f01be2e3ce820e5737416180efa3e5852ece72c4.tar.bz2 tanzanite-f01be2e3ce820e5737416180efa3e5852ece72c4.zip |
fix invite link, remove store channel, update to use builder methods, fix breaking changes
Diffstat (limited to 'src/lib/extensions/discord-akairo')
-rw-r--r-- | src/lib/extensions/discord-akairo/BushClient.ts | 24 | ||||
-rw-r--r-- | src/lib/extensions/discord-akairo/BushClientUtil.ts | 18 | ||||
-rw-r--r-- | src/lib/extensions/discord-akairo/BushCommand.ts | 5 |
3 files changed, 27 insertions, 20 deletions
diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts index 2fb559c..6516161 100644 --- a/src/lib/extensions/discord-akairo/BushClient.ts +++ b/src/lib/extensions/discord-akairo/BushClient.ts @@ -22,10 +22,11 @@ import type { } from '#lib'; import { patch, type PatchedElements } from '@notenoughupdates/events-intercept'; import * as Sentry from '@sentry/node'; -import { AkairoClient, ContextMenuCommandHandler, version as akairoVersion } from 'discord-akairo'; -import { GatewayIntentBits } from 'discord-api-types/v9'; +import { AkairoClient, ContextMenuCommandHandler, PromptContentModifier, version as akairoVersion } from 'discord-akairo'; +import { GatewayIntentBits } from 'discord-api-types/v10'; import { ActivityType, + MessagePayload, Options, Partials, Structures, @@ -36,7 +37,6 @@ import { type Message, type MessageEditOptions, type MessageOptions, - type MessagePayload, type ReplyMessageOptions, type Snowflake, type WebhookEditMessageOptions @@ -78,7 +78,6 @@ import { BushNewsChannel } from '../discord.js/BushNewsChannel.js'; import { BushPresence } from '../discord.js/BushPresence.js'; import { BushRole } from '../discord.js/BushRole.js'; import { BushSelectMenuInteraction } from '../discord.js/BushSelectMenuInteraction.js'; -import { BushStoreChannel } from '../discord.js/BushStoreChannel.js'; import { BushTextChannel } from '../discord.js/BushTextChannel.js'; import { BushThreadChannel } from '../discord.js/BushThreadChannel.js'; import { BushThreadMember } from '../discord.js/BushThreadMember.js'; @@ -235,6 +234,17 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re directory: path.join(__dirname, '..', '..', '..', 'tasks'), automateCategories: true }); + + const modify: PromptContentModifier = async (message, text, data) => { + const ending = '\n\n Type **cancel** to cancel the command'; + const options = typeof text === 'function' ? await text(message, data) : text; + if (typeof options === 'string') return text + ending; + if (options instanceof MessagePayload) { + if (options.options.content) options.options.content += ending; + } else options.content += ending; + return options; + }; + this.commandHandler = new BushCommandHandler(this, { directory: path.join(__dirname, '..', '..', '..', 'commands'), prefix: async ({ guild }: Message) => { @@ -251,9 +261,8 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re prompt: { start: 'Placeholder argument prompt. **If you see this please tell my developers**.', retry: 'Placeholder failed argument prompt. **If you see this please tell my developers**.', - modifyStart: (_: Message, str: string): string => `${str}\n\n Type \`cancel\` to cancel the command`, - modifyRetry: (_: Message, str: string): string => - `${str.replace('{error}', this.util.emojis.error)}\n\n Type \`cancel\` to cancel the command`, + modifyStart: modify, + modifyRetry: modify, timeout: ':hourglass: You took too long the command has been cancelled.', ended: 'You exceeded the maximum amount of tries the command has been cancelled', cancel: 'The command has been cancelled', @@ -317,7 +326,6 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re Structures.extend('VoiceChannel', () => BushVoiceChannel); Structures.extend('CategoryChannel', () => BushCategoryChannel); Structures.extend('NewsChannel', () => BushNewsChannel); - Structures.extend('StoreChannel', () => BushStoreChannel); Structures.extend('ThreadChannel', () => BushThreadChannel); Structures.extend('GuildMember', () => BushGuildMember); Structures.extend('ThreadMember', () => BushThreadMember); diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts index e92abe7..563df3d 100644 --- a/src/lib/extensions/discord-akairo/BushClientUtil.ts +++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts @@ -22,10 +22,10 @@ import assert from 'assert'; import { exec } from 'child_process'; import deepLock from 'deep-lock'; import { ClientUtil, Util as AkairoUtil } from 'discord-akairo'; -import { APIEmbed, APIMessage, OAuth2Scopes, Routes } from 'discord-api-types/v9'; +import { APIEmbed, APIMessage, OAuth2Scopes, Routes } from 'discord-api-types/v10'; import { Constants as DiscordConstants, - Embed, + EmbedBuilder, GuildMember, Message, PermissionFlagsBits, @@ -920,7 +920,11 @@ export class BushClientUtil extends ClientUtil { */ public get invite() { return client.generateInvite({ - permissions: PermissionsBitField.All, + permissions: + PermissionsBitField.All - + PermissionFlagsBits.UseEmbeddedActivities - + PermissionFlagsBits.ViewGuildInsights - + PermissionFlagsBits.Stream, scopes: [OAuth2Scopes.Bot, OAuth2Scopes.ApplicationsCommands] }); } @@ -970,17 +974,17 @@ export class BushClientUtil extends ClientUtil { * @param embed The options to be applied to the (first) embed. * @param lines Each line of the description as an element in an array. */ - public overflowEmbed(embed: Omit<APIEmbed, 'description'>, lines: string[], maxLength = 4096): Embed[] { - const embeds: Embed[] = []; + public overflowEmbed(embed: Omit<APIEmbed, 'description'>, lines: string[], maxLength = 4096): EmbedBuilder[] { + const embeds: EmbedBuilder[] = []; const makeEmbed = () => { - embeds.push(new Embed().setColor(embed.color ?? null)); + embeds.push(new EmbedBuilder().setColor(embed.color ?? null)); return embeds.at(-1)!; }; for (const line of lines) { let current = embeds.length ? embeds.at(-1)! : makeEmbed(); - const joined = current.description ? `${current.description}\n${line}` : line; + const joined = current.data.description ? `${current.data.description}\n${line}` : line; if (joined.length >= maxLength) current = makeEmbed(); current.setDescription(joined); diff --git a/src/lib/extensions/discord-akairo/BushCommand.ts b/src/lib/extensions/discord-akairo/BushCommand.ts index ff3748e..febe95a 100644 --- a/src/lib/extensions/discord-akairo/BushCommand.ts +++ b/src/lib/extensions/discord-akairo/BushCommand.ts @@ -18,7 +18,6 @@ import { type BushRole, type BushSlashMessage, type BushStageChannel, - type BushStoreChannel, type BushTask, type BushTextChannel, type BushThreadChannel, @@ -72,10 +71,6 @@ export interface OverriddenBaseArgumentType extends BaseArgumentType { categoryChannels: Collection<string, BushCategoryChannel> | null; newsChannel: BushNewsChannel | null; newsChannels: Collection<string, BushNewsChannel> | null; - // eslint-disable-next-line deprecation/deprecation - storeChannel: BushStoreChannel | null; - // eslint-disable-next-line deprecation/deprecation - storeChannels: Collection<string, BushStoreChannel> | null; stageChannel: BushStageChannel | null; stageChannels: Collection<string, BushStageChannel> | null; threadChannel: BushThreadChannel | null; |