From 4ca474ca0fb5809a4c65faf730f8465a96a355d9 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sun, 7 Nov 2021 09:43:35 -0500 Subject: fix some errors I hope --- src/commands/info/pronouns.ts | 2 + src/commands/info/userInfo.ts | 4 +- src/lib/extensions/discord-akairo/BushClient.ts | 136 ++++++++++++------------ 3 files changed, 72 insertions(+), 70 deletions(-) (limited to 'src') diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts index db1a3a4..fbbc5af 100644 --- a/src/commands/info/pronouns.ts +++ b/src/commands/info/pronouns.ts @@ -39,6 +39,8 @@ export default class PronounsCommand extends BushCommand { const user = args.user ?? message.author; const author = user.id === message.author.id; + if (message.util.isSlashMessage(message)) await message.interaction.deferReply() + const pronouns = await util.getPronounsOf(user); if (!pronouns) { return await message.util.reply( diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts index 3afdff2..2b87d0b 100644 --- a/src/commands/info/userInfo.ts +++ b/src/commands/info/userInfo.ts @@ -95,8 +95,8 @@ export default class UserInfoCommand extends BushCommand { 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 })})`); - const pronouns = await util.getPronounsOf(user); - if (pronouns) generalInfo.push(`**Pronouns:** ${pronouns}`); + const pronouns = await Promise.race([util.getPronounsOf(user), util.sleep(2)]); + if (pronouns && typeof pronouns === 'string') generalInfo.push(`**Pronouns:** ${pronouns}`); userEmbed.addField('ยป General Info', generalInfo.join('\n')); diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts index 0fb84f3..c2d8970 100644 --- a/src/lib/extensions/discord-akairo/BushClient.ts +++ b/src/lib/extensions/discord-akairo/BushClient.ts @@ -83,7 +83,6 @@ import { BushListenerHandler } from './BushListenerHandler.js'; import { BushTaskHandler } from './BushTaskHandler.js'; const { Sequelize } = (await import('sequelize')).default; - export type BushReplyMessageType = string | MessagePayload | ReplyMessageOptions; export type BushEditMessageType = string | MessageEditOptions | MessagePayload; export type BushSlashSendMessageType = string | MessagePayload | InteractionReplyOptions; @@ -118,29 +117,6 @@ type If = T extends true ? A : T extends false ? const __dirname = dirname(fileURLToPath(import.meta.url)); export class BushClient extends AkairoClient { - public static init(): void { - Structures.extend('GuildEmoji', () => BushGuildEmoji); - Structures.extend('DMChannel', () => BushDMChannel); - Structures.extend('TextChannel', () => BushTextChannel); - 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); - Structures.extend('Guild', () => BushGuild); - Structures.extend('Message', () => BushMessage); - Structures.extend('MessageReaction', () => BushMessageReaction); - Structures.extend('Presence', () => BushPresence); - Structures.extend('VoiceState', () => BushVoiceState); - Structures.extend('Role', () => BushRole); - Structures.extend('User', () => BushUser); - Structures.extend('CommandInteraction', () => BushCommandInteraction); - Structures.extend('ButtonInteraction', () => BushButtonInteraction); - Structures.extend('SelectMenuInteraction', () => BushSelectMenuInteraction); - } - public declare channels: BushChannelManager; public declare readonly emojis: BushBaseGuildEmojiManager; public declare guilds: BushGuildManager; @@ -163,49 +139,6 @@ export class BushClient extends AkairoClient( - event: K, - listener: (...args: BushClientEvents[K]) => Awaitable - ): this; - public override on( - event: Exclude, - listener: (...args: any[]) => Awaitable - ): this { - return super.on(event as any, listener); - } - - public override once( - event: K, - listener: (...args: BushClientEvents[K]) => Awaitable - ): this; - public override once( - event: Exclude, - listener: (...args: any[]) => Awaitable - ): this { - return super.once(event as any, listener); - } - - public override emit(event: K, ...args: BushClientEvents[K]): boolean; - public override emit(event: Exclude, ...args: unknown[]): boolean { - return super.emit(event as any, ...args); - } - - public override off( - event: K, - listener: (...args: BushClientEvents[K]) => Awaitable - ): this; - public override off( - event: Exclude, - listener: (...args: any[]) => Awaitable - ): this { - return super.off(event as any, listener); - } - - public override removeAllListeners(event?: K): this; - public override removeAllListeners(event?: Exclude): this { - return super.removeAllListeners(event as any); - } - public constructor(config: Config) { super({ ownerID: config.owners, @@ -221,7 +154,8 @@ export class BushClient extends AkairoClient; @@ -305,6 +239,29 @@ export class BushClient extends AkairoClient BushGuildEmoji); + Structures.extend('DMChannel', () => BushDMChannel); + Structures.extend('TextChannel', () => BushTextChannel); + 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); + Structures.extend('Guild', () => BushGuild); + Structures.extend('Message', () => BushMessage); + Structures.extend('MessageReaction', () => BushMessageReaction); + Structures.extend('Presence', () => BushPresence); + Structures.extend('VoiceState', () => BushVoiceState); + Structures.extend('Role', () => BushRole); + Structures.extend('User', () => BushUser); + Structures.extend('CommandInteraction', () => BushCommandInteraction); + Structures.extend('ButtonInteraction', () => BushButtonInteraction); + Structures.extend('SelectMenuInteraction', () => BushSelectMenuInteraction); + } + // Initialize everything async #init() { this.commandHandler.useListenerHandler(this.listenerHandler); @@ -429,4 +386,47 @@ export class BushClient extends AkairoClient( + event: K, + listener: (...args: BushClientEvents[K]) => Awaitable + ): this; + public override on( + event: Exclude, + listener: (...args: any[]) => Awaitable + ): this { + return super.on(event as any, listener); + } + + public override once( + event: K, + listener: (...args: BushClientEvents[K]) => Awaitable + ): this; + public override once( + event: Exclude, + listener: (...args: any[]) => Awaitable + ): this { + return super.once(event as any, listener); + } + + public override emit(event: K, ...args: BushClientEvents[K]): boolean; + public override emit(event: Exclude, ...args: unknown[]): boolean { + return super.emit(event as any, ...args); + } + + public override off( + event: K, + listener: (...args: BushClientEvents[K]) => Awaitable + ): this; + public override off( + event: Exclude, + listener: (...args: any[]) => Awaitable + ): this { + return super.off(event as any, listener); + } + + public override removeAllListeners(event?: K): this; + public override removeAllListeners(event?: Exclude): this { + return super.removeAllListeners(event as any); + } } -- cgit