diff --git a/src/client/base.ts b/src/client/base.ts index 46b35bd..6b749a0 100644 --- a/src/client/base.ts +++ b/src/client/base.ts @@ -419,9 +419,10 @@ export class BaseClient { for (const i in locations) { const key = i as keyof typeof locations; - const location = locations[i as keyof typeof locations]; - if (!location || locationsFullPaths[key]) continue; - locationsFullPaths[key] = join(process.cwd(), locations.output, location); + const location = locations[key]; + if (key in locationsFullPaths) continue; + if (typeof location === 'string') locationsFullPaths[key] = join(process.cwd(), locations.output, location); + else locationsFullPaths[key] = location as any; } const obj = { diff --git a/src/commands/handle.ts b/src/commands/handle.ts index f117e3d..dead1d6 100644 --- a/src/commands/handle.ts +++ b/src/commands/handle.ts @@ -95,21 +95,12 @@ export class HandleCommand { } } - async contextMenuMessage( + async contextMenu( command: ContextMenuCommand, - interaction: MessageCommandInteraction, - context: MenuCommandContext, + interaction: MessageCommandInteraction | UserCommandInteraction, + context: MenuCommandContext, ) { - // @ts-expect-error - return this.contextMenuUser(command, interaction, context); - } - - async contextMenuUser( - command: ContextMenuCommand, - interaction: UserCommandInteraction, - context: MenuCommandContext, - ) { - if (context.guildId && command.botPermissions && interaction.appPermissions) { + if (context.guildId && command.botPermissions) { const permissions = this.checkPermissions(interaction.appPermissions, command.botPermissions); if (permissions) return command.onBotPermissionsFail(context, permissions); } @@ -136,8 +127,24 @@ export class HandleCommand { } } + contextMenuMessage( + command: ContextMenuCommand, + interaction: MessageCommandInteraction, + context: MenuCommandContext, + ) { + return this.contextMenu(command, interaction, context); + } + + contextMenuUser( + command: ContextMenuCommand, + interaction: UserCommandInteraction, + context: MenuCommandContext, + ) { + return this.contextMenu(command, interaction, context); + } + async entryPoint(command: EntryPointCommand, interaction: EntryPointInteraction, context: EntryPointContext) { - if (context.guildId && command.botPermissions && interaction.appPermissions) { + if (context.guildId && command.botPermissions) { const permissions = this.checkPermissions(interaction.appPermissions, command.botPermissions); if (permissions) return command.onBotPermissionsFail(context, permissions); } @@ -170,7 +177,7 @@ export class HandleCommand { resolver: OptionResolverStructure, context: CommandContext, ) { - if (context.guildId && interaction.appPermissions) { + if (context.guildId) { if (command.botPermissions) { const permissions = this.checkPermissions(interaction.appPermissions, command.botPermissions); if (permissions) return command.onBotPermissionsFail?.(context, permissions); @@ -243,20 +250,21 @@ export class HandleCommand { case ApplicationCommandType.Message: { const data = this.makeMenuCommand(body, shardId, __reply); if (!data) return; - - this.contextMenuMessage( + await this.contextMenuMessage( data.command, - // @ts-expect-error - data.interaction, - data.context, + data.interaction as MessageCommandInteraction, + data.context as MenuCommandContext, ); break; } case ApplicationCommandType.User: { const data = this.makeMenuCommand(body, shardId, __reply); if (!data) return; - // @ts-expect-error - this.contextMenuUser(data.command, data.interaction, data.context); + await this.contextMenuUser( + data.command, + data.interaction as UserCommandInteraction, + data.context as MenuCommandContext, + ); break; } case ApplicationCommandType.PrimaryEntryPoint: { @@ -278,10 +286,10 @@ export class HandleCommand { body.guild_id, body.data.resolved as ContextOptionsResolved, ); - const interaction = BaseInteraction.from(this.client, body, __reply) as ChatInputCommandInteraction; const command = optionsResolver.getCommand(); if (!command?.run) return this.client.logger.warn(`${optionsResolver.fullCommandName} command does not have 'run' callback`); + const interaction = BaseInteraction.from(this.client, body, __reply) as ChatInputCommandInteraction; const context = new CommandContext(this.client, interaction, optionsResolver, shardId, command); const extendContext = this.client.options?.context?.(interaction) ?? {}; Object.assign(context, extendContext); diff --git a/src/structures/Interaction.ts b/src/structures/Interaction.ts index f6aec66..7cb0f65 100644 --- a/src/structures/Interaction.ts +++ b/src/structures/Interaction.ts @@ -102,7 +102,7 @@ export class BaseInteraction< channel?: AllChannels; message?: MessageStructure; replied?: Promise | boolean; - appPermissions?: PermissionsBitField; + appPermissions: PermissionsBitField; entitlements: EntitlementStructure[]; constructor( @@ -122,9 +122,7 @@ export class BaseInteraction< if (interaction.message) { this.message = Transformers.Message(client, interaction.message); } - if (interaction.app_permissions) { - this.appPermissions = new PermissionsBitField(Number(interaction.app_permissions)); - } + this.appPermissions = new PermissionsBitField(Number(interaction.app_permissions)); if (interaction.channel) { this.channel = channelFrom(interaction.channel, client); }