mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-03 05:26:07 +00:00
context
This commit is contained in:
parent
e734b8d831
commit
6d4e0589b1
@ -81,7 +81,7 @@ export async function onInteractionCreate(
|
||||
// idc, is a YOU problem
|
||||
if (!command?.run)
|
||||
return self.logger.warn(`${command.name ?? 'Unknown'} command does not have 'run' callback`);
|
||||
const context = new MenuCommandContext(self, interaction, shardId);
|
||||
const context = new MenuCommandContext(self, interaction, shardId, command);
|
||||
const extendContext = self.options?.context?.(interaction) ?? {};
|
||||
Object.assign(context, extendContext);
|
||||
try {
|
||||
@ -145,7 +145,7 @@ export async function onInteractionCreate(
|
||||
const command = optionsResolver.getCommand();
|
||||
if (!command?.run)
|
||||
return self.logger.warn(`${optionsResolver.fullCommandName} command does not have 'run' callback`);
|
||||
const context = new CommandContext(self, interaction, optionsResolver, shardId);
|
||||
const context = new CommandContext(self, interaction, optionsResolver, shardId, command);
|
||||
const extendContext = self.options?.context?.(interaction) ?? {};
|
||||
Object.assign(context, extendContext);
|
||||
try {
|
||||
|
@ -96,7 +96,7 @@ export async function onMessageCreate(
|
||||
const args = (self.options?.commands?.argsParser ?? defaultArgsParser)(content, command);
|
||||
const { options, errors } = await parseOptions(self, command, rawMessage, args, resolved);
|
||||
const optionsResolver = new OptionResolver(self, options, parent as Command, message.guildId, resolved);
|
||||
const context = new CommandContext(self, message, optionsResolver, shardId);
|
||||
const context = new CommandContext(self, message, optionsResolver, shardId, command);
|
||||
try {
|
||||
if (command.botPermissions && message.guildId) {
|
||||
const meMember = await self.cache.members?.get(self.botId, message.guildId);
|
||||
|
@ -20,7 +20,7 @@ import {
|
||||
} from '../../structures';
|
||||
import type { RegisteredMiddlewares } from '../decorators';
|
||||
import type { OptionResolver } from '../optionresolver';
|
||||
import type { ContextOptions, OptionsRecord } from './chat';
|
||||
import type { Command, ContextOptions, OptionsRecord, SubCommand } from './chat';
|
||||
import type { CommandMetadata, ExtendContext, GlobalMetadata, UsingClient } from './shared';
|
||||
|
||||
export interface CommandContext<T extends OptionsRecord = {}, M extends keyof RegisteredMiddlewares = never>
|
||||
@ -33,9 +33,10 @@ export class CommandContext<T extends OptionsRecord = {}, M extends keyof Regist
|
||||
messageResponse?: If<InferWithPrefix, Message | undefined>;
|
||||
constructor(
|
||||
readonly client: UsingClient,
|
||||
data: ChatInputCommandInteraction | Message,
|
||||
public resolver: OptionResolver,
|
||||
readonly data: ChatInputCommandInteraction | Message,
|
||||
readonly resolver: OptionResolver,
|
||||
readonly shardId: number,
|
||||
readonly command: Command | SubCommand,
|
||||
) {
|
||||
if (data instanceof Message) {
|
||||
this.message = data as never;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { CommandContext, type ReturnCache, type WebhookMessage } from '../..';
|
||||
import { CommandContext, type ContextMenuCommand, type ReturnCache, type WebhookMessage } from '../..';
|
||||
import {
|
||||
ApplicationCommandType,
|
||||
MessageFlags,
|
||||
@ -35,6 +35,7 @@ export class MenuCommandContext<
|
||||
readonly client: UsingClient,
|
||||
readonly interaction: T,
|
||||
readonly shardId: number,
|
||||
readonly command: ContextMenuCommand,
|
||||
) {}
|
||||
|
||||
metadata: CommandMetadata<UnionToTuple<M>> = {} as never;
|
||||
|
Loading…
x
Reference in New Issue
Block a user