mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 20:46:08 +00:00
fix: appPermissions is not optional
This commit is contained in:
parent
537631d488
commit
d3dee668b5
@ -419,9 +419,10 @@ export class BaseClient {
|
|||||||
|
|
||||||
for (const i in locations) {
|
for (const i in locations) {
|
||||||
const key = i as keyof typeof locations;
|
const key = i as keyof typeof locations;
|
||||||
const location = locations[i as keyof typeof locations];
|
const location = locations[key];
|
||||||
if (!location || locationsFullPaths[key]) continue;
|
if (key in locationsFullPaths) continue;
|
||||||
locationsFullPaths[key] = join(process.cwd(), locations.output, location);
|
if (typeof location === 'string') locationsFullPaths[key] = join(process.cwd(), locations.output, location);
|
||||||
|
else locationsFullPaths[key] = location as any;
|
||||||
}
|
}
|
||||||
|
|
||||||
const obj = {
|
const obj = {
|
||||||
|
@ -95,21 +95,12 @@ export class HandleCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async contextMenuMessage(
|
async contextMenu(
|
||||||
command: ContextMenuCommand,
|
command: ContextMenuCommand,
|
||||||
interaction: MessageCommandInteraction,
|
interaction: MessageCommandInteraction | UserCommandInteraction,
|
||||||
context: MenuCommandContext<MessageCommandInteraction>,
|
context: MenuCommandContext<MessageCommandInteraction | UserCommandInteraction>,
|
||||||
) {
|
) {
|
||||||
// @ts-expect-error
|
if (context.guildId && command.botPermissions) {
|
||||||
return this.contextMenuUser(command, interaction, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
async contextMenuUser(
|
|
||||||
command: ContextMenuCommand,
|
|
||||||
interaction: UserCommandInteraction,
|
|
||||||
context: MenuCommandContext<UserCommandInteraction>,
|
|
||||||
) {
|
|
||||||
if (context.guildId && command.botPermissions && interaction.appPermissions) {
|
|
||||||
const permissions = this.checkPermissions(interaction.appPermissions, command.botPermissions);
|
const permissions = this.checkPermissions(interaction.appPermissions, command.botPermissions);
|
||||||
if (permissions) return command.onBotPermissionsFail(context, permissions);
|
if (permissions) return command.onBotPermissionsFail(context, permissions);
|
||||||
}
|
}
|
||||||
@ -136,8 +127,24 @@ export class HandleCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
contextMenuMessage(
|
||||||
|
command: ContextMenuCommand,
|
||||||
|
interaction: MessageCommandInteraction,
|
||||||
|
context: MenuCommandContext<MessageCommandInteraction>,
|
||||||
|
) {
|
||||||
|
return this.contextMenu(command, interaction, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
contextMenuUser(
|
||||||
|
command: ContextMenuCommand,
|
||||||
|
interaction: UserCommandInteraction,
|
||||||
|
context: MenuCommandContext<UserCommandInteraction>,
|
||||||
|
) {
|
||||||
|
return this.contextMenu(command, interaction, context);
|
||||||
|
}
|
||||||
|
|
||||||
async entryPoint(command: EntryPointCommand, interaction: EntryPointInteraction, context: EntryPointContext) {
|
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);
|
const permissions = this.checkPermissions(interaction.appPermissions, command.botPermissions);
|
||||||
if (permissions) return command.onBotPermissionsFail(context, permissions);
|
if (permissions) return command.onBotPermissionsFail(context, permissions);
|
||||||
}
|
}
|
||||||
@ -170,7 +177,7 @@ export class HandleCommand {
|
|||||||
resolver: OptionResolverStructure,
|
resolver: OptionResolverStructure,
|
||||||
context: CommandContext,
|
context: CommandContext,
|
||||||
) {
|
) {
|
||||||
if (context.guildId && interaction.appPermissions) {
|
if (context.guildId) {
|
||||||
if (command.botPermissions) {
|
if (command.botPermissions) {
|
||||||
const permissions = this.checkPermissions(interaction.appPermissions, command.botPermissions);
|
const permissions = this.checkPermissions(interaction.appPermissions, command.botPermissions);
|
||||||
if (permissions) return command.onBotPermissionsFail?.(context, permissions);
|
if (permissions) return command.onBotPermissionsFail?.(context, permissions);
|
||||||
@ -243,20 +250,21 @@ export class HandleCommand {
|
|||||||
case ApplicationCommandType.Message: {
|
case ApplicationCommandType.Message: {
|
||||||
const data = this.makeMenuCommand(body, shardId, __reply);
|
const data = this.makeMenuCommand(body, shardId, __reply);
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
|
await this.contextMenuMessage(
|
||||||
this.contextMenuMessage(
|
|
||||||
data.command,
|
data.command,
|
||||||
// @ts-expect-error
|
data.interaction as MessageCommandInteraction,
|
||||||
data.interaction,
|
data.context as MenuCommandContext<MessageCommandInteraction>,
|
||||||
data.context,
|
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ApplicationCommandType.User: {
|
case ApplicationCommandType.User: {
|
||||||
const data = this.makeMenuCommand(body, shardId, __reply);
|
const data = this.makeMenuCommand(body, shardId, __reply);
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
// @ts-expect-error
|
await this.contextMenuUser(
|
||||||
this.contextMenuUser(data.command, data.interaction, data.context);
|
data.command,
|
||||||
|
data.interaction as UserCommandInteraction,
|
||||||
|
data.context as MenuCommandContext<UserCommandInteraction>,
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ApplicationCommandType.PrimaryEntryPoint: {
|
case ApplicationCommandType.PrimaryEntryPoint: {
|
||||||
@ -278,10 +286,10 @@ export class HandleCommand {
|
|||||||
body.guild_id,
|
body.guild_id,
|
||||||
body.data.resolved as ContextOptionsResolved,
|
body.data.resolved as ContextOptionsResolved,
|
||||||
);
|
);
|
||||||
const interaction = BaseInteraction.from(this.client, body, __reply) as ChatInputCommandInteraction;
|
|
||||||
const command = optionsResolver.getCommand();
|
const command = optionsResolver.getCommand();
|
||||||
if (!command?.run)
|
if (!command?.run)
|
||||||
return this.client.logger.warn(`${optionsResolver.fullCommandName} command does not have 'run' callback`);
|
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 context = new CommandContext(this.client, interaction, optionsResolver, shardId, command);
|
||||||
const extendContext = this.client.options?.context?.(interaction) ?? {};
|
const extendContext = this.client.options?.context?.(interaction) ?? {};
|
||||||
Object.assign(context, extendContext);
|
Object.assign(context, extendContext);
|
||||||
|
@ -102,7 +102,7 @@ export class BaseInteraction<
|
|||||||
channel?: AllChannels;
|
channel?: AllChannels;
|
||||||
message?: MessageStructure;
|
message?: MessageStructure;
|
||||||
replied?: Promise<boolean | RESTPostAPIInteractionCallbackResult | undefined> | boolean;
|
replied?: Promise<boolean | RESTPostAPIInteractionCallbackResult | undefined> | boolean;
|
||||||
appPermissions?: PermissionsBitField;
|
appPermissions: PermissionsBitField;
|
||||||
entitlements: EntitlementStructure[];
|
entitlements: EntitlementStructure[];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ -122,9 +122,7 @@ export class BaseInteraction<
|
|||||||
if (interaction.message) {
|
if (interaction.message) {
|
||||||
this.message = Transformers.Message(client, 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) {
|
if (interaction.channel) {
|
||||||
this.channel = channelFrom(interaction.channel, client);
|
this.channel = channelFrom(interaction.channel, client);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user