mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-02 21:16:09 +00:00
fix: defaults of integrationTypes & contexts
This commit is contained in:
parent
7e30f4ba78
commit
625e400c20
@ -91,7 +91,7 @@ export async function onMessageCreate(
|
|||||||
const prefixes = (await self.options.commands.prefix(message)).sort((a, b) => b.length - a.length);
|
const prefixes = (await self.options.commands.prefix(message)).sort((a, b) => b.length - a.length);
|
||||||
const prefix = prefixes.find(x => message.content.startsWith(x));
|
const prefix = prefixes.find(x => message.content.startsWith(x));
|
||||||
|
|
||||||
if (!(prefix && message.content.startsWith(prefix))) return;
|
if (!(prefix !== undefined && message.content.startsWith(prefix))) return;
|
||||||
|
|
||||||
const content = message.content.slice(prefix.length).trimStart();
|
const content = message.content.slice(prefix.length).trimStart();
|
||||||
const { fullCommandName, command, parent } = getCommandFromContent(
|
const { fullCommandName, command, parent } = getCommandFromContent(
|
||||||
@ -105,7 +105,8 @@ export async function onMessageCreate(
|
|||||||
if (!command) return;
|
if (!command) return;
|
||||||
if (!command.run) return self.logger.warn(`${fullCommandName} command does not have 'run' callback`);
|
if (!command.run) return self.logger.warn(`${fullCommandName} command does not have 'run' callback`);
|
||||||
|
|
||||||
if (!(command.contexts?.includes(InteractionContextType.BotDM) || message.guildId)) return;
|
if (!command.contexts.includes(InteractionContextType.BotDM) && !message.guildId) return;
|
||||||
|
if (!command.contexts.includes(InteractionContextType.Guild) && message.guildId) return;
|
||||||
if (command.guildId && !command.guildId?.includes(message.guildId!)) return;
|
if (command.guildId && !command.guildId?.includes(message.guildId!)) return;
|
||||||
|
|
||||||
const resolved: MakeRequired<ContextOptionsResolved> = {
|
const resolved: MakeRequired<ContextOptionsResolved> = {
|
||||||
|
@ -126,8 +126,8 @@ export class BaseCommand {
|
|||||||
nsfw?: boolean;
|
nsfw?: boolean;
|
||||||
description!: string;
|
description!: string;
|
||||||
defaultMemberPermissions?: bigint;
|
defaultMemberPermissions?: bigint;
|
||||||
integrationTypes?: ApplicationIntegrationType[];
|
integrationTypes: ApplicationIntegrationType[] = [];
|
||||||
contexts?: InteractionContextType[];
|
contexts: InteractionContextType[] = [];
|
||||||
botPermissions?: bigint;
|
botPermissions?: bigint;
|
||||||
name_localizations?: Partial<Record<LocaleString, string>>;
|
name_localizations?: Partial<Record<LocaleString, string>>;
|
||||||
description_localizations?: Partial<Record<LocaleString, string>>;
|
description_localizations?: Partial<Record<LocaleString, string>>;
|
||||||
|
@ -19,8 +19,8 @@ export abstract class ContextMenuCommand {
|
|||||||
name!: string;
|
name!: string;
|
||||||
type!: ApplicationCommandType.User | ApplicationCommandType.Message;
|
type!: ApplicationCommandType.User | ApplicationCommandType.Message;
|
||||||
nsfw?: boolean;
|
nsfw?: boolean;
|
||||||
integrationTypes?: ApplicationIntegrationType[];
|
integrationTypes: ApplicationIntegrationType[] = [];
|
||||||
contexts?: InteractionContextType[];
|
contexts: InteractionContextType[] = [];
|
||||||
description!: string;
|
description!: string;
|
||||||
defaultMemberPermissions?: bigint;
|
defaultMemberPermissions?: bigint;
|
||||||
botPermissions?: bigint;
|
botPermissions?: bigint;
|
||||||
|
@ -157,8 +157,12 @@ export function Declare(declare: DeclareOptions) {
|
|||||||
class extends target {
|
class extends target {
|
||||||
name = declare.name;
|
name = declare.name;
|
||||||
nsfw = declare.nsfw;
|
nsfw = declare.nsfw;
|
||||||
contexts = declare.contexts?.map(i => InteractionContextType[i]);
|
contexts =
|
||||||
integrationTypes = declare.integrationTypes?.map(i => ApplicationIntegrationType[i]);
|
declare.contexts?.map(i => InteractionContextType[i]) ??
|
||||||
|
Object.values(InteractionContextType).filter(x => typeof x === 'number');
|
||||||
|
integrationTypes = declare.integrationTypes?.map(i => ApplicationIntegrationType[i]) ?? [
|
||||||
|
ApplicationIntegrationType.GuildInstall,
|
||||||
|
];
|
||||||
defaultMemberPermissions = Array.isArray(declare.defaultMemberPermissions)
|
defaultMemberPermissions = Array.isArray(declare.defaultMemberPermissions)
|
||||||
? declare.defaultMemberPermissions?.reduce((acc, prev) => acc | PermissionFlagsBits[prev], BigInt(0))
|
? declare.defaultMemberPermissions?.reduce((acc, prev) => acc | PermissionFlagsBits[prev], BigInt(0))
|
||||||
: declare.defaultMemberPermissions;
|
: declare.defaultMemberPermissions;
|
||||||
|
@ -143,14 +143,14 @@ export class CommandHandler extends BaseHandler {
|
|||||||
//TODO: locales
|
//TODO: locales
|
||||||
|
|
||||||
if ('contexts' in command && 'contexts' in cached) {
|
if ('contexts' in command && 'contexts' in cached) {
|
||||||
if (command.contexts?.length !== cached.contexts?.length) return true;
|
if (command.contexts.length !== cached.contexts.length) return true;
|
||||||
if (command.contexts && cached.contexts) {
|
if (command.contexts && cached.contexts) {
|
||||||
if (command.contexts.some(ctx => !cached.contexts!.includes(ctx))) return true;
|
if (command.contexts.some(ctx => !cached.contexts!.includes(ctx))) return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('integration_types' in command && 'integration_types' in cached) {
|
if ('integration_types' in command && 'integration_types' in cached) {
|
||||||
if (command.integration_types?.length !== cached.integration_types?.length) return true;
|
if (command.integration_types.length !== cached.integration_types.length) return true;
|
||||||
if (command.integration_types && cached.integration_types) {
|
if (command.integration_types && cached.integration_types) {
|
||||||
if (command.integration_types.some(ctx => !cached.integration_types!.includes(ctx))) return true;
|
if (command.integration_types.some(ctx => !cached.integration_types!.includes(ctx))) return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user