mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-03 05:26:07 +00:00
fix custom context in prefix commands (#159)
This commit is contained in:
parent
74159ac1da
commit
c1351f32de
@ -27,7 +27,7 @@ import {
|
|||||||
import type { DeepPartial, IntentStrings, OmitInsert } from '../common/types/util';
|
import type { DeepPartial, IntentStrings, OmitInsert } from '../common/types/util';
|
||||||
import { ComponentHandler } from '../components/handler';
|
import { ComponentHandler } from '../components/handler';
|
||||||
import { LangsHandler } from '../langs/handler';
|
import { LangsHandler } from '../langs/handler';
|
||||||
import type { ChatInputCommandInteraction, MessageCommandInteraction, UserCommandInteraction } from '../structures';
|
import type { ChatInputCommandInteraction, Message, MessageCommandInteraction, UserCommandInteraction } from '../structures';
|
||||||
|
|
||||||
export class BaseClient {
|
export class BaseClient {
|
||||||
rest!: ApiHandler;
|
rest!: ApiHandler;
|
||||||
@ -245,7 +245,8 @@ export interface BaseClientOptions {
|
|||||||
interaction:
|
interaction:
|
||||||
| ChatInputCommandInteraction<boolean>
|
| ChatInputCommandInteraction<boolean>
|
||||||
| UserCommandInteraction<boolean>
|
| UserCommandInteraction<boolean>
|
||||||
| MessageCommandInteraction<boolean>,
|
| MessageCommandInteraction<boolean>
|
||||||
|
| Message
|
||||||
) => {};
|
) => {};
|
||||||
globalMiddlewares?: readonly (keyof RegisteredMiddlewares)[];
|
globalMiddlewares?: readonly (keyof RegisteredMiddlewares)[];
|
||||||
}
|
}
|
||||||
|
@ -97,6 +97,8 @@ export async function onMessageCreate(
|
|||||||
const { options, errors } = await parseOptions(self, command, rawMessage, args, resolved);
|
const { options, errors } = await parseOptions(self, command, rawMessage, args, resolved);
|
||||||
const optionsResolver = new OptionResolver(self, options, parent as Command, message.guildId, resolved);
|
const optionsResolver = new OptionResolver(self, options, parent as Command, message.guildId, resolved);
|
||||||
const context = new CommandContext(self, message, optionsResolver, shardId, command);
|
const context = new CommandContext(self, message, optionsResolver, shardId, command);
|
||||||
|
const extendContext = self.options?.context?.(message) ?? {};
|
||||||
|
Object.assign(context, extendContext);
|
||||||
try {
|
try {
|
||||||
if (command.botPermissions && message.guildId) {
|
if (command.botPermissions && message.guildId) {
|
||||||
const meMember = await self.cache.members?.get(self.botId, message.guildId);
|
const meMember = await self.cache.members?.get(self.botId, message.guildId);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import type { InternalRuntimeConfig, InternalRuntimeConfigHTTP, RuntimeConfig, RuntimeConfigHTTP } from './client/base';
|
import type { InternalRuntimeConfig, InternalRuntimeConfigHTTP, RuntimeConfig, RuntimeConfigHTTP } from './client/base';
|
||||||
import { GatewayIntentBits } from './common';
|
import { GatewayIntentBits } from './common';
|
||||||
import type { ClientNameEvents, EventContext } from './events';
|
import type { ClientNameEvents, EventContext } from './events';
|
||||||
import type { ChatInputCommandInteraction, MessageCommandInteraction, UserCommandInteraction } from './structures';
|
import type { ChatInputCommandInteraction, Message, MessageCommandInteraction, UserCommandInteraction } from './structures';
|
||||||
|
|
||||||
export { Logger, PermissionFlagsBits, PermissionStrings, Watcher } from './common';
|
export { Logger, PermissionFlagsBits, PermissionStrings, Watcher } from './common';
|
||||||
//
|
//
|
||||||
@ -95,7 +95,7 @@ export const config = {
|
|||||||
* });
|
* });
|
||||||
*/
|
*/
|
||||||
export function extendContext<T extends {}>(
|
export function extendContext<T extends {}>(
|
||||||
cb: (interaction: ChatInputCommandInteraction | UserCommandInteraction | MessageCommandInteraction) => T,
|
cb: (interaction: ChatInputCommandInteraction | UserCommandInteraction | MessageCommandInteraction | Message) => T,
|
||||||
) {
|
) {
|
||||||
return cb;
|
return cb;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user