seyfert 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/CDN.d.ts +1 -1
- package/lib/api/CDN.js +0 -2
- package/lib/api/Router.js +2 -2
- package/lib/api/Routes/applications.d.ts +29 -33
- package/lib/api/Routes/channels.d.ts +11 -17
- package/lib/api/Routes/interactions.d.ts +3 -7
- package/lib/api/Routes/webhooks.d.ts +4 -6
- package/lib/builders/Attachment.d.ts +2 -3
- package/lib/cache/adapters/redis.js +6 -0
- package/lib/cache/adapters/workeradapter.d.ts +4 -4
- package/lib/cache/adapters/workeradapter.js +10 -5
- package/lib/cache/index.d.ts +4 -5
- package/lib/cache/index.js +4 -3
- package/lib/cache/resources/default/base.d.ts +2 -1
- package/lib/cache/resources/default/guild-based.d.ts +2 -1
- package/lib/cache/resources/default/guild-based.js +6 -6
- package/lib/cache/resources/default/guild-related.d.ts +2 -1
- package/lib/cache/resources/default/guild-related.js +1 -1
- package/lib/cache/resources/guilds.js +2 -1
- package/lib/cache/resources/overwrites.d.ts +1 -1
- package/lib/cache/resources/overwrites.js +7 -1
- package/lib/client/base.d.ts +18 -170
- package/lib/client/base.js +11 -14
- package/lib/client/client.d.ts +5 -0
- package/lib/client/client.js +4 -1
- package/lib/client/oninteractioncreate.js +2 -2
- package/lib/client/onmessagecreate.js +188 -152
- package/lib/client/workerclient.d.ts +1 -0
- package/lib/client/workerclient.js +36 -15
- package/lib/collection.js +2 -2
- package/lib/commands/applications/chat.d.ts +15 -7
- package/lib/commands/applications/chat.js +7 -7
- package/lib/commands/applications/chatcontext.d.ts +5 -3
- package/lib/commands/applications/chatcontext.js +6 -1
- package/lib/commands/applications/menu.d.ts +5 -1
- package/lib/commands/applications/menu.js +4 -0
- package/lib/commands/applications/menucontext.d.ts +4 -2
- package/lib/commands/applications/menucontext.js +6 -1
- package/lib/commands/applications/options.d.ts +1 -2
- package/lib/commands/decorators.d.ts +17 -5
- package/lib/commands/decorators.js +17 -7
- package/lib/commands/handler.d.ts +5 -5
- package/lib/commands/handler.js +40 -36
- package/lib/commands/optionresolver.d.ts +11 -4
- package/lib/commands/optionresolver.js +6 -4
- package/lib/common/index.d.ts +7 -0
- package/lib/common/index.js +7 -0
- package/lib/common/it/utils.js +2 -0
- package/lib/common/shorters/channels.d.ts +67 -129
- package/lib/common/shorters/channels.js +119 -135
- package/lib/common/shorters/emojis.d.ts +47 -0
- package/lib/common/shorters/emojis.js +80 -0
- package/lib/common/shorters/guilds.d.ts +22 -249
- package/lib/common/shorters/guilds.js +51 -140
- package/lib/common/shorters/members.d.ts +82 -108
- package/lib/common/shorters/members.js +151 -166
- package/lib/common/shorters/messages.d.ts +11 -23
- package/lib/common/shorters/messages.js +58 -104
- package/lib/common/shorters/reactions.d.ts +10 -0
- package/lib/common/shorters/reactions.js +45 -0
- package/lib/common/shorters/roles.d.ts +39 -7
- package/lib/common/shorters/roles.js +74 -42
- package/lib/common/shorters/templates.d.ts +6 -8
- package/lib/common/shorters/templates.js +17 -21
- package/lib/common/shorters/users.d.ts +4 -0
- package/lib/common/shorters/users.js +30 -0
- package/lib/common/shorters/webhook.d.ts +62 -26
- package/lib/common/shorters/webhook.js +113 -58
- package/lib/common/types/options.d.ts +2 -2
- package/lib/components/handler.d.ts +10 -7
- package/lib/components/handler.js +20 -5
- package/lib/index.d.ts +4 -2
- package/lib/langs/handler.js +7 -2
- package/lib/structures/AutoModerationRule.d.ts +2 -2
- package/lib/structures/ClientUser.d.ts +2 -2
- package/lib/structures/Guild.d.ts +2 -2
- package/lib/structures/GuildEmoji.d.ts +4 -4
- package/lib/structures/GuildEmoji.js +7 -7
- package/lib/structures/GuildMember.d.ts +6 -6
- package/lib/structures/GuildMember.js +2 -2
- package/lib/structures/GuildPreview.d.ts +2 -2
- package/lib/structures/GuildRole.d.ts +2 -2
- package/lib/structures/GuildTemplate.d.ts +2 -2
- package/lib/structures/Interaction.d.ts +7 -8
- package/lib/structures/Interaction.js +1 -1
- package/lib/structures/Message.d.ts +7 -6
- package/lib/structures/Message.js +7 -4
- package/lib/structures/Sticker.d.ts +2 -2
- package/lib/structures/Webhook.d.ts +2 -2
- package/lib/structures/Webhook.js +3 -3
- package/lib/structures/channels.d.ts +19 -20
- package/lib/structures/channels.js +13 -25
- package/lib/structures/extra/Base.d.ts +1 -2
- package/lib/structures/extra/DiscordBase.d.ts +2 -2
- package/lib/websocket/constants/index.js +1 -0
- package/lib/websocket/discord/shard.js +4 -2
- package/lib/websocket/discord/sharder.d.ts +3 -0
- package/lib/websocket/discord/sharder.js +12 -5
- package/lib/websocket/discord/shared.d.ts +1 -0
- package/lib/websocket/discord/worker.d.ts +2 -1
- package/lib/websocket/discord/workermanager.d.ts +8 -3
- package/lib/websocket/discord/workermanager.js +78 -30
- package/package.json +8 -6
|
@@ -14,22 +14,22 @@ class BaseCommand {
|
|
|
14
14
|
nsfw;
|
|
15
15
|
description;
|
|
16
16
|
default_member_permissions;
|
|
17
|
+
integration_types;
|
|
18
|
+
contexts;
|
|
17
19
|
botPermissions;
|
|
18
|
-
dm;
|
|
19
20
|
name_localizations;
|
|
20
21
|
description_localizations;
|
|
21
22
|
options;
|
|
22
23
|
/** @internal */
|
|
23
24
|
async __runOptions(ctx, resolver) {
|
|
24
|
-
|
|
25
|
-
if (!command?.options?.length) {
|
|
25
|
+
if (!this?.options?.length) {
|
|
26
26
|
return [false, {}];
|
|
27
27
|
}
|
|
28
28
|
const data = {};
|
|
29
29
|
let errored = false;
|
|
30
|
-
for (const i of
|
|
30
|
+
for (const i of this.options ?? []) {
|
|
31
31
|
try {
|
|
32
|
-
const option =
|
|
32
|
+
const option = this.options.find(x => x.name === i.name);
|
|
33
33
|
const value = resolver.getHoisted(i.name)?.value !== undefined
|
|
34
34
|
? await new Promise((res, rej) => option.value?.({ context: ctx, value: resolver.getValue(i.name) }, res, rej) ||
|
|
35
35
|
res(resolver.getValue(i.name)))
|
|
@@ -117,9 +117,9 @@ class BaseCommand {
|
|
|
117
117
|
description_localizations: this.description_localizations,
|
|
118
118
|
guild_id: this.guild_id,
|
|
119
119
|
default_member_permissions: this.default_member_permissions,
|
|
120
|
+
contexts: this.contexts,
|
|
121
|
+
integration_types: this.integration_types,
|
|
120
122
|
};
|
|
121
|
-
if ('dm' in this)
|
|
122
|
-
data.dm_permission = this.dm;
|
|
123
123
|
return data;
|
|
124
124
|
}
|
|
125
125
|
async reload() {
|
|
@@ -4,18 +4,19 @@ import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest
|
|
|
4
4
|
import { Message, type ChatInputCommandInteraction, type GuildMember, type InteractionGuildMember } from '../../structures';
|
|
5
5
|
import type { RegisteredMiddlewares } from '../decorators';
|
|
6
6
|
import type { OptionResolver } from '../optionresolver';
|
|
7
|
-
import type { ContextOptions, OptionsRecord } from './chat';
|
|
7
|
+
import type { Command, ContextOptions, OptionsRecord, SubCommand } from './chat';
|
|
8
8
|
import type { CommandMetadata, ExtendContext, GlobalMetadata, UsingClient } from './shared';
|
|
9
9
|
export interface CommandContext<T extends OptionsRecord = {}, M extends keyof RegisteredMiddlewares = never> extends ExtendContext {
|
|
10
10
|
}
|
|
11
11
|
export declare class CommandContext<T extends OptionsRecord = {}, M extends keyof RegisteredMiddlewares = never> {
|
|
12
12
|
readonly client: UsingClient;
|
|
13
|
-
resolver: OptionResolver;
|
|
13
|
+
readonly resolver: OptionResolver;
|
|
14
14
|
readonly shardId: number;
|
|
15
|
+
readonly command: Command | SubCommand;
|
|
15
16
|
message: If<InferWithPrefix, Message | undefined, undefined>;
|
|
16
17
|
interaction: If<InferWithPrefix, ChatInputCommandInteraction | undefined, ChatInputCommandInteraction>;
|
|
17
18
|
messageResponse?: If<InferWithPrefix, Message | undefined>;
|
|
18
|
-
constructor(client: UsingClient, data: ChatInputCommandInteraction | Message, resolver: OptionResolver, shardId: number);
|
|
19
|
+
constructor(client: UsingClient, data: ChatInputCommandInteraction | Message, resolver: OptionResolver, shardId: number, command: Command | SubCommand);
|
|
19
20
|
options: ContextOptions<T>;
|
|
20
21
|
metadata: CommandMetadata<UnionToTuple<M>>;
|
|
21
22
|
globalMetadata: GlobalMetadata;
|
|
@@ -23,6 +24,7 @@ export declare class CommandContext<T extends OptionsRecord = {}, M extends keyo
|
|
|
23
24
|
get t(): import("../..").__InternalParseLocale<import("./shared").DefaultLocale> & {
|
|
24
25
|
get(locale?: string | undefined): import("./shared").DefaultLocale;
|
|
25
26
|
};
|
|
27
|
+
get fullCommandName(): string;
|
|
26
28
|
write<FR extends boolean = false>(body: InteractionCreateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessage | Message, void | WebhookMessage | Message>>;
|
|
27
29
|
deferReply(ephemeral?: boolean): Promise<void | Message>;
|
|
28
30
|
editResponse(body: InteractionMessageUpdateBodyRequest): Promise<Message>;
|
|
@@ -8,13 +8,15 @@ class CommandContext {
|
|
|
8
8
|
client;
|
|
9
9
|
resolver;
|
|
10
10
|
shardId;
|
|
11
|
+
command;
|
|
11
12
|
message;
|
|
12
13
|
interaction;
|
|
13
14
|
messageResponse;
|
|
14
|
-
constructor(client, data, resolver, shardId) {
|
|
15
|
+
constructor(client, data, resolver, shardId, command) {
|
|
15
16
|
this.client = client;
|
|
16
17
|
this.resolver = resolver;
|
|
17
18
|
this.shardId = shardId;
|
|
19
|
+
this.command = command;
|
|
18
20
|
if (data instanceof structures_1.Message) {
|
|
19
21
|
this.message = data;
|
|
20
22
|
}
|
|
@@ -31,6 +33,9 @@ class CommandContext {
|
|
|
31
33
|
get t() {
|
|
32
34
|
return this.client.langs.get(this.interaction?.locale ?? this.client.langs.defaultLang ?? 'en-US');
|
|
33
35
|
}
|
|
36
|
+
get fullCommandName() {
|
|
37
|
+
return this.resolver.fullCommandName;
|
|
38
|
+
}
|
|
34
39
|
async write(body, fetchReply) {
|
|
35
40
|
if (this.interaction)
|
|
36
41
|
return this.interaction.write(body, fetchReply);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ApplicationCommandType, type LocaleString, type PermissionStrings } from '../../common';
|
|
2
|
-
import type { RegisteredMiddlewares } from '../decorators';
|
|
2
|
+
import type { IntegrationTypes, InteractionContextTypes, RegisteredMiddlewares } from '../decorators';
|
|
3
3
|
import type { MenuCommandContext } from './menucontext';
|
|
4
4
|
import type { UsingClient } from './shared';
|
|
5
5
|
export declare abstract class ContextMenuCommand {
|
|
@@ -13,6 +13,8 @@ export declare abstract class ContextMenuCommand {
|
|
|
13
13
|
name: string;
|
|
14
14
|
type: ApplicationCommandType.User | ApplicationCommandType.Message;
|
|
15
15
|
nsfw?: boolean;
|
|
16
|
+
integration_types?: IntegrationTypes[];
|
|
17
|
+
contexts?: InteractionContextTypes[];
|
|
16
18
|
description: string;
|
|
17
19
|
default_member_permissions?: string;
|
|
18
20
|
botPermissions?: bigint;
|
|
@@ -29,6 +31,8 @@ export declare abstract class ContextMenuCommand {
|
|
|
29
31
|
guild_id: string[] | undefined;
|
|
30
32
|
dm_permission: boolean | undefined;
|
|
31
33
|
default_member_permissions: string | undefined;
|
|
34
|
+
contexts: InteractionContextTypes[] | undefined;
|
|
35
|
+
integration_types: IntegrationTypes[] | undefined;
|
|
32
36
|
};
|
|
33
37
|
reload(): Promise<void>;
|
|
34
38
|
abstract run?(context: MenuCommandContext<any>): any;
|
|
@@ -10,6 +10,8 @@ class ContextMenuCommand {
|
|
|
10
10
|
name;
|
|
11
11
|
type;
|
|
12
12
|
nsfw;
|
|
13
|
+
integration_types;
|
|
14
|
+
contexts;
|
|
13
15
|
description;
|
|
14
16
|
default_member_permissions;
|
|
15
17
|
botPermissions;
|
|
@@ -73,6 +75,8 @@ class ContextMenuCommand {
|
|
|
73
75
|
guild_id: this.guild_id,
|
|
74
76
|
dm_permission: this.dm,
|
|
75
77
|
default_member_permissions: this.default_member_permissions,
|
|
78
|
+
contexts: this.contexts,
|
|
79
|
+
integration_types: this.integration_types,
|
|
76
80
|
};
|
|
77
81
|
}
|
|
78
82
|
async reload() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommandContext, type ReturnCache, type WebhookMessage } from '../..';
|
|
1
|
+
import { CommandContext, type ContextMenuCommand, type ReturnCache, type WebhookMessage } from '../..';
|
|
2
2
|
import { type InteractionCreateBodyRequest, type InteractionMessageUpdateBodyRequest, type UnionToTuple, type When } from '../../common';
|
|
3
3
|
import { Message, User, type AllChannels, type Guild, type GuildMember, type MessageCommandInteraction, type UserCommandInteraction } from '../../structures';
|
|
4
4
|
import type { RegisteredMiddlewares } from '../decorators';
|
|
@@ -10,7 +10,8 @@ export declare class MenuCommandContext<T extends MessageCommandInteraction | Us
|
|
|
10
10
|
readonly client: UsingClient;
|
|
11
11
|
readonly interaction: T;
|
|
12
12
|
readonly shardId: number;
|
|
13
|
-
|
|
13
|
+
readonly command: ContextMenuCommand;
|
|
14
|
+
constructor(client: UsingClient, interaction: T, shardId: number, command: ContextMenuCommand);
|
|
14
15
|
metadata: CommandMetadata<UnionToTuple<M>>;
|
|
15
16
|
globalMetadata: GlobalMetadata;
|
|
16
17
|
get proxy(): import("../..").APIRoutes;
|
|
@@ -18,6 +19,7 @@ export declare class MenuCommandContext<T extends MessageCommandInteraction | Us
|
|
|
18
19
|
get t(): import("../..").__InternalParseLocale<import("./shared").DefaultLocale> & {
|
|
19
20
|
get(locale?: string | undefined): import("./shared").DefaultLocale;
|
|
20
21
|
};
|
|
22
|
+
get fullCommandName(): string;
|
|
21
23
|
write<FR extends boolean = false>(body: InteractionCreateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessage, void | WebhookMessage>>;
|
|
22
24
|
get modal(): ((body: import("../../common").ModalCreateBodyRequest) => Promise<void>) | ((body: import("../../common").ModalCreateBodyRequest) => Promise<void>);
|
|
23
25
|
deferReply(ephemeral?: boolean): Promise<void>;
|
|
@@ -8,10 +8,12 @@ class MenuCommandContext {
|
|
|
8
8
|
client;
|
|
9
9
|
interaction;
|
|
10
10
|
shardId;
|
|
11
|
-
|
|
11
|
+
command;
|
|
12
|
+
constructor(client, interaction, shardId, command) {
|
|
12
13
|
this.client = client;
|
|
13
14
|
this.interaction = interaction;
|
|
14
15
|
this.shardId = shardId;
|
|
16
|
+
this.command = command;
|
|
15
17
|
}
|
|
16
18
|
metadata = {};
|
|
17
19
|
globalMetadata = {};
|
|
@@ -34,6 +36,9 @@ class MenuCommandContext {
|
|
|
34
36
|
get t() {
|
|
35
37
|
return this.client.langs.get(this.interaction.locale);
|
|
36
38
|
}
|
|
39
|
+
get fullCommandName() {
|
|
40
|
+
return this.command.name;
|
|
41
|
+
}
|
|
37
42
|
write(body, fetchReply) {
|
|
38
43
|
return this.interaction.write(body, fetchReply);
|
|
39
44
|
}
|
|
@@ -63,5 +63,4 @@ export declare function createNumberOption<T extends SeyfertNumberOption = Seyfe
|
|
|
63
63
|
export declare function createAttachmentOption<T extends SeyfertAttachmentOption = SeyfertAttachmentOption>(data: T): T & {
|
|
64
64
|
readonly type: ApplicationCommandOptionType.Attachment;
|
|
65
65
|
};
|
|
66
|
-
export
|
|
67
|
-
export declare function createMiddleware<T = ParseMiddlewareType<unknown>>(data: ParseMiddlewareType<T>): ParseMiddlewareType<T>;
|
|
66
|
+
export declare function createMiddleware<T = any, C extends CommandContext | MenuCommandContext<MessageCommandInteraction<boolean> | UserCommandInteraction<boolean>> = CommandContext | MenuCommandContext<MessageCommandInteraction<boolean> | UserCommandInteraction<boolean>>>(data: MiddlewareContext<T, C>): MiddlewareContext<T, C>;
|
|
@@ -3,22 +3,33 @@ import type { CommandOption, OptionsRecord, SubCommand } from './applications/ch
|
|
|
3
3
|
import type { DefaultLocale, MiddlewareContext } from './applications/shared';
|
|
4
4
|
export interface RegisteredMiddlewares {
|
|
5
5
|
}
|
|
6
|
+
export declare enum IntegrationTypes {
|
|
7
|
+
GUILD_INSTALL = 0,
|
|
8
|
+
USER_INSTALL = 1
|
|
9
|
+
}
|
|
10
|
+
export declare enum InteractionContextTypes {
|
|
11
|
+
GUILD = 0,
|
|
12
|
+
BOT_DM = 1,
|
|
13
|
+
PRIVATE_CHANNEL = 2
|
|
14
|
+
}
|
|
6
15
|
type DeclareOptions = {
|
|
7
16
|
name: string;
|
|
8
17
|
description: string;
|
|
9
18
|
botPermissions?: PermissionStrings | bigint;
|
|
10
|
-
|
|
19
|
+
defaultMemberPermissions?: PermissionStrings | bigint;
|
|
11
20
|
guildId?: string[];
|
|
12
|
-
dm?: boolean;
|
|
13
21
|
nsfw?: boolean;
|
|
22
|
+
integrationTypes?: (keyof typeof IntegrationTypes)[];
|
|
23
|
+
contexts?: (keyof typeof InteractionContextTypes)[];
|
|
14
24
|
} | (Omit<{
|
|
15
25
|
name: string;
|
|
16
26
|
description: string;
|
|
17
27
|
botPermissions?: PermissionStrings | bigint;
|
|
18
|
-
|
|
28
|
+
defaultMemberPermissions?: PermissionStrings | bigint;
|
|
19
29
|
guildId?: string[];
|
|
20
|
-
dm?: boolean;
|
|
21
30
|
nsfw?: boolean;
|
|
31
|
+
integrationTypes?: (keyof typeof IntegrationTypes)[];
|
|
32
|
+
contexts?: (keyof typeof InteractionContextTypes)[];
|
|
22
33
|
}, 'type' | 'description'> & {
|
|
23
34
|
type: ApplicationCommandType.User | ApplicationCommandType.Message;
|
|
24
35
|
});
|
|
@@ -96,9 +107,10 @@ export declare function Declare(declare: DeclareOptions): <T extends new (...arg
|
|
|
96
107
|
new (...args: any[]): {
|
|
97
108
|
name: string;
|
|
98
109
|
nsfw: boolean | undefined;
|
|
110
|
+
contexts: InteractionContextTypes[] | undefined;
|
|
111
|
+
integration_types: IntegrationTypes[] | undefined;
|
|
99
112
|
default_member_permissions: string | bigint | undefined;
|
|
100
113
|
botPermissions: bigint | undefined;
|
|
101
|
-
dm?: boolean | undefined;
|
|
102
114
|
description: string;
|
|
103
115
|
type: ApplicationCommandType;
|
|
104
116
|
guild_id?: string[] | undefined;
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Declare = exports.Middlewares = exports.AutoLoad = exports.Options = exports.Group = exports.Groups = exports.GroupsT = exports.LocalesT = exports.Locales = void 0;
|
|
3
|
+
exports.Declare = exports.Middlewares = exports.AutoLoad = exports.Options = exports.Group = exports.Groups = exports.GroupsT = exports.LocalesT = exports.Locales = exports.InteractionContextTypes = exports.IntegrationTypes = void 0;
|
|
4
4
|
const common_1 = require("../common");
|
|
5
|
+
var IntegrationTypes;
|
|
6
|
+
(function (IntegrationTypes) {
|
|
7
|
+
IntegrationTypes[IntegrationTypes["GUILD_INSTALL"] = 0] = "GUILD_INSTALL";
|
|
8
|
+
IntegrationTypes[IntegrationTypes["USER_INSTALL"] = 1] = "USER_INSTALL";
|
|
9
|
+
})(IntegrationTypes || (exports.IntegrationTypes = IntegrationTypes = {}));
|
|
10
|
+
var InteractionContextTypes;
|
|
11
|
+
(function (InteractionContextTypes) {
|
|
12
|
+
InteractionContextTypes[InteractionContextTypes["GUILD"] = 0] = "GUILD";
|
|
13
|
+
InteractionContextTypes[InteractionContextTypes["BOT_DM"] = 1] = "BOT_DM";
|
|
14
|
+
InteractionContextTypes[InteractionContextTypes["PRIVATE_CHANNEL"] = 2] = "PRIVATE_CHANNEL";
|
|
15
|
+
})(InteractionContextTypes || (exports.InteractionContextTypes = InteractionContextTypes = {}));
|
|
5
16
|
function Locales({ name: names, description: descriptions, }) {
|
|
6
17
|
return (target) => class extends target {
|
|
7
18
|
name_localizations = names ? Object.fromEntries(names) : undefined;
|
|
@@ -62,13 +73,14 @@ function Declare(declare) {
|
|
|
62
73
|
return (target) => class extends target {
|
|
63
74
|
name = declare.name;
|
|
64
75
|
nsfw = declare.nsfw;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
76
|
+
contexts = declare.contexts?.map(i => InteractionContextTypes[i]);
|
|
77
|
+
integration_types = declare.integrationTypes?.map(i => IntegrationTypes[i]);
|
|
78
|
+
default_member_permissions = Array.isArray(declare.defaultMemberPermissions)
|
|
79
|
+
? declare.defaultMemberPermissions?.reduce((acc, prev) => acc | common_1.PermissionFlagsBits[prev], BigInt(0)).toString()
|
|
80
|
+
: declare.defaultMemberPermissions;
|
|
68
81
|
botPermissions = Array.isArray(declare.botPermissions)
|
|
69
82
|
? declare.botPermissions?.reduce((acc, prev) => acc | common_1.PermissionFlagsBits[prev], BigInt(0))
|
|
70
83
|
: declare.botPermissions;
|
|
71
|
-
dm;
|
|
72
84
|
description = '';
|
|
73
85
|
type = common_1.ApplicationCommandType.ChatInput;
|
|
74
86
|
guild_id;
|
|
@@ -78,8 +90,6 @@ function Declare(declare) {
|
|
|
78
90
|
this.description = declare.description;
|
|
79
91
|
if ('type' in declare)
|
|
80
92
|
this.type = declare.type;
|
|
81
|
-
if ('dm' in declare)
|
|
82
|
-
this.dm = !!declare.dm;
|
|
83
93
|
if ('guildId' in declare)
|
|
84
94
|
this.guild_id = declare.guildId;
|
|
85
95
|
// check if all properties are valid
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { BaseClient } from '../client/base';
|
|
2
1
|
import type { Logger } from '../common';
|
|
3
2
|
import { BaseHandler } from '../common';
|
|
4
3
|
import { Command } from './applications/chat';
|
|
5
4
|
import { ContextMenuCommand } from './applications/menu';
|
|
5
|
+
import type { UsingClient } from './applications/shared';
|
|
6
6
|
export declare class CommandHandler extends BaseHandler {
|
|
7
7
|
protected logger: Logger;
|
|
8
|
-
protected client:
|
|
8
|
+
protected client: UsingClient;
|
|
9
9
|
values: (Command | ContextMenuCommand)[];
|
|
10
10
|
protected filter: (path: string) => boolean;
|
|
11
|
-
constructor(logger: Logger, client:
|
|
11
|
+
constructor(logger: Logger, client: UsingClient);
|
|
12
12
|
reload(resolve: string | Command): Promise<void>;
|
|
13
13
|
reloadAll(stopIfFail?: boolean): Promise<void>;
|
|
14
|
-
load(commandsDir: string, client:
|
|
15
|
-
private
|
|
14
|
+
load(commandsDir: string, client: UsingClient): Promise<(Command | ContextMenuCommand)[]>;
|
|
15
|
+
private __parseCommandLocales;
|
|
16
16
|
}
|
package/lib/commands/handler.js
CHANGED
|
@@ -63,6 +63,7 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
63
63
|
commandInstance.__filePath = command.path;
|
|
64
64
|
commandInstance.options ??= [];
|
|
65
65
|
if (commandInstance.__d) {
|
|
66
|
+
//@AutoLoad
|
|
66
67
|
const options = await this.getFiles((0, node_path_1.dirname)(command.path));
|
|
67
68
|
for (const option of options) {
|
|
68
69
|
if (command.name === (0, node_path_1.basename)(option)) {
|
|
@@ -95,45 +96,60 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
this.values.push(commandInstance);
|
|
98
|
-
this.
|
|
99
|
+
this.__parseCommandLocales(commandInstance, client);
|
|
99
100
|
for (const i of commandInstance.options ?? []) {
|
|
100
101
|
if (i instanceof chat_1.SubCommand) {
|
|
101
|
-
this.
|
|
102
|
+
this.__parseCommandLocales(i, client);
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
return this.values;
|
|
106
107
|
}
|
|
107
|
-
|
|
108
|
+
__parseCommandLocales(command, client) {
|
|
108
109
|
if (command.__t) {
|
|
109
110
|
command.name_localizations = {};
|
|
110
111
|
command.description_localizations = {};
|
|
111
112
|
for (const locale of Object.keys(client.langs.values)) {
|
|
112
|
-
const
|
|
113
|
-
if (Object.values(common_1.Locale).includes(locale))
|
|
114
|
-
|
|
113
|
+
const locales = this.client.langs.aliases.find(x => x[0] === locale)?.[1] ?? [];
|
|
114
|
+
if (Object.values(common_1.Locale).includes(locale))
|
|
115
|
+
locales.push(locale);
|
|
116
|
+
if (command.__t.name) {
|
|
117
|
+
for (const i of locales) {
|
|
115
118
|
const valueName = client.langs.getKey(locale, command.__t.name);
|
|
116
119
|
if (valueName)
|
|
117
|
-
command.name_localizations[
|
|
120
|
+
command.name_localizations[i] = valueName;
|
|
118
121
|
}
|
|
119
|
-
|
|
122
|
+
}
|
|
123
|
+
if (command.__t.description) {
|
|
124
|
+
for (const i of locales) {
|
|
120
125
|
const valueKey = client.langs.getKey(locale, command.__t.description);
|
|
121
126
|
if (valueKey)
|
|
122
|
-
command.description_localizations[
|
|
127
|
+
command.description_localizations[i] = valueKey;
|
|
123
128
|
}
|
|
124
129
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
for (const options of command.options ?? []) {
|
|
133
|
+
if (options instanceof chat_1.SubCommand || !options.locales)
|
|
134
|
+
continue;
|
|
135
|
+
options.name_localizations = {};
|
|
136
|
+
options.description_localizations = {};
|
|
137
|
+
for (const locale of Object.keys(client.langs.values)) {
|
|
138
|
+
const locales = this.client.langs.aliases.find(x => x[0] === locale)?.[1] ?? [];
|
|
139
|
+
if (Object.values(common_1.Locale).includes(locale))
|
|
140
|
+
locales.push(locale);
|
|
141
|
+
if (options.locales.name) {
|
|
142
|
+
for (const i of locales) {
|
|
143
|
+
const valueName = client.langs.getKey(locale, options.locales.name);
|
|
128
144
|
if (valueName)
|
|
129
|
-
|
|
145
|
+
options.name_localizations[i] = valueName;
|
|
130
146
|
}
|
|
131
147
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const valueKey = client.langs.getKey(locale,
|
|
148
|
+
if (options.locales.description) {
|
|
149
|
+
for (const i of locales) {
|
|
150
|
+
const valueKey = client.langs.getKey(locale, options.locales.description);
|
|
135
151
|
if (valueKey)
|
|
136
|
-
|
|
152
|
+
options.description_localizations[i] = valueKey;
|
|
137
153
|
}
|
|
138
154
|
}
|
|
139
155
|
}
|
|
@@ -141,37 +157,25 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
141
157
|
if (command instanceof chat_1.Command && command.__tGroups) {
|
|
142
158
|
command.groups = {};
|
|
143
159
|
for (const locale of Object.keys(client.langs.values)) {
|
|
144
|
-
const
|
|
160
|
+
const locales = this.client.langs.aliases.find(x => x[0] === locale)?.[1] ?? [];
|
|
161
|
+
if (Object.values(common_1.Locale).includes(locale))
|
|
162
|
+
locales.push(locale);
|
|
145
163
|
for (const group in command.__tGroups) {
|
|
146
164
|
command.groups[group] ??= {
|
|
147
165
|
defaultDescription: command.__tGroups[group].defaultDescription,
|
|
148
166
|
description: [],
|
|
149
167
|
name: [],
|
|
150
168
|
};
|
|
151
|
-
if (
|
|
152
|
-
|
|
153
|
-
const valueName = client.langs.getKey(locale, command.__tGroups[group].name);
|
|
154
|
-
if (valueName) {
|
|
155
|
-
command.groups[group].name.push([locale, valueName]);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
if (command.__tGroups[group].description) {
|
|
159
|
-
const valueKey = client.langs.getKey(locale, command.__tGroups[group].description);
|
|
160
|
-
if (valueKey) {
|
|
161
|
-
command.groups[group].description.push([locale, valueKey]);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
for (const i of aliases) {
|
|
166
|
-
if (command.__tGroups[group].name) {
|
|
169
|
+
if (command.__tGroups[group].name) {
|
|
170
|
+
for (const i of locales) {
|
|
167
171
|
const valueName = client.langs.getKey(locale, command.__tGroups[group].name);
|
|
168
172
|
if (valueName) {
|
|
169
173
|
command.groups[group].name.push([i, valueName]);
|
|
170
174
|
}
|
|
171
175
|
}
|
|
172
176
|
}
|
|
173
|
-
|
|
174
|
-
|
|
177
|
+
if (command.__tGroups[group].description) {
|
|
178
|
+
for (const i of locales) {
|
|
175
179
|
const valueKey = client.langs.getKey(locale, command.__tGroups[group].description);
|
|
176
180
|
if (valueKey) {
|
|
177
181
|
command.groups[group].description.push([i, valueKey]);
|
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
import { Attachment, GuildMember } from '..';
|
|
2
|
-
import type { APIApplicationCommandInteractionDataOption,
|
|
2
|
+
import type { APIApplicationCommandInteractionDataOption, APIAttachment, APIGuildMember, APIInteractionDataResolvedChannel, APIInteractionGuildMember, APIRole, APIUser, MakeRequired } from '../common';
|
|
3
3
|
import { ApplicationCommandOptionType } from '../common';
|
|
4
4
|
import type { AllChannels } from '../structures';
|
|
5
5
|
import { GuildRole, InteractionGuildMember, User } from '../structures';
|
|
6
6
|
import type { Command, CommandAutocompleteOption, SubCommand } from './applications/chat';
|
|
7
7
|
import type { UsingClient } from './applications/shared';
|
|
8
|
+
export type ContextOptionsResolved = {
|
|
9
|
+
members?: Record<string, APIGuildMember | APIInteractionGuildMember | GuildMember | InteractionGuildMember>;
|
|
10
|
+
users?: Record<string, APIUser | User>;
|
|
11
|
+
roles?: Record<string, APIRole | GuildRole>;
|
|
12
|
+
channels?: Record<string, APIInteractionDataResolvedChannel | AllChannels>;
|
|
13
|
+
attachments?: Record<string, APIAttachment | Attachment>;
|
|
14
|
+
};
|
|
8
15
|
export declare class OptionResolver {
|
|
9
16
|
private client;
|
|
10
17
|
parent?: Command | undefined;
|
|
11
18
|
guildId?: string | undefined;
|
|
12
|
-
resolved?:
|
|
19
|
+
resolved?: ContextOptionsResolved | undefined;
|
|
13
20
|
readonly options: OptionResolved[];
|
|
14
21
|
hoistedOptions: OptionResolved[];
|
|
15
22
|
private subCommand;
|
|
16
23
|
private group;
|
|
17
|
-
constructor(client: UsingClient, options: APIApplicationCommandInteractionDataOption[], parent?: Command | undefined, guildId?: string | undefined, resolved?:
|
|
24
|
+
constructor(client: UsingClient, options: APIApplicationCommandInteractionDataOption[], parent?: Command | undefined, guildId?: string | undefined, resolved?: ContextOptionsResolved | undefined);
|
|
18
25
|
get fullCommandName(): string;
|
|
19
26
|
getCommand(): Command | SubCommand | undefined;
|
|
20
27
|
getAutocompleteValue(): string | undefined;
|
|
@@ -28,7 +35,7 @@ export declare class OptionResolver {
|
|
|
28
35
|
private getTypedOption;
|
|
29
36
|
getChannel(name: string, required?: true): AllChannels;
|
|
30
37
|
getString(name: string, required?: true): string;
|
|
31
|
-
transformOption(option: APIApplicationCommandInteractionDataOption, resolved?:
|
|
38
|
+
transformOption(option: APIApplicationCommandInteractionDataOption, resolved?: ContextOptionsResolved): OptionResolved;
|
|
32
39
|
}
|
|
33
40
|
export interface OptionResolved {
|
|
34
41
|
name: string;
|
|
@@ -122,14 +122,16 @@ class OptionResolver {
|
|
|
122
122
|
const value = resolve.value;
|
|
123
123
|
const user = resolved.users?.[value];
|
|
124
124
|
if (user) {
|
|
125
|
-
resolve.user = new structures_1.User(this.client, user);
|
|
125
|
+
resolve.user = user instanceof structures_1.User ? user : new structures_1.User(this.client, user);
|
|
126
126
|
}
|
|
127
127
|
const member = resolved.members?.[value];
|
|
128
128
|
if (member) {
|
|
129
129
|
resolve.member =
|
|
130
|
-
member instanceof __1.GuildMember
|
|
130
|
+
member instanceof __1.GuildMember || member instanceof structures_1.InteractionGuildMember
|
|
131
131
|
? member
|
|
132
|
-
:
|
|
132
|
+
: 'permissions' in member
|
|
133
|
+
? new structures_1.InteractionGuildMember(this.client, member, user, this.guildId)
|
|
134
|
+
: new __1.GuildMember(this.client, member, user, this.guildId);
|
|
133
135
|
}
|
|
134
136
|
const channel = resolved.channels?.[value];
|
|
135
137
|
if (channel) {
|
|
@@ -141,7 +143,7 @@ class OptionResolver {
|
|
|
141
143
|
}
|
|
142
144
|
const attachment = resolved.attachments?.[value];
|
|
143
145
|
if (attachment) {
|
|
144
|
-
resolve.attachment = new __1.Attachment(this.client, attachment);
|
|
146
|
+
resolve.attachment = attachment instanceof __1.Attachment ? attachment : new __1.Attachment(this.client, attachment);
|
|
145
147
|
}
|
|
146
148
|
}
|
|
147
149
|
return resolve;
|
package/lib/common/index.d.ts
CHANGED
|
@@ -4,8 +4,15 @@ export * from 'discord-api-types/v10';
|
|
|
4
4
|
export * from './it/colors';
|
|
5
5
|
export * from './it/logger';
|
|
6
6
|
export * from './shorters/channels';
|
|
7
|
+
export * from './shorters/emojis';
|
|
7
8
|
export * from './shorters/guilds';
|
|
9
|
+
export * from './shorters/members';
|
|
10
|
+
export * from './shorters/messages';
|
|
11
|
+
export * from './shorters/reactions';
|
|
12
|
+
export * from './shorters/roles';
|
|
13
|
+
export * from './shorters/templates';
|
|
8
14
|
export * from './shorters/users';
|
|
15
|
+
export * from './shorters/webhook';
|
|
9
16
|
export * from './types/options';
|
|
10
17
|
export * from './types/resolvables';
|
|
11
18
|
export * from './types/util';
|
package/lib/common/index.js
CHANGED
|
@@ -21,8 +21,15 @@ __exportStar(require("discord-api-types/v10"), exports);
|
|
|
21
21
|
__exportStar(require("./it/colors"), exports);
|
|
22
22
|
__exportStar(require("./it/logger"), exports);
|
|
23
23
|
__exportStar(require("./shorters/channels"), exports);
|
|
24
|
+
__exportStar(require("./shorters/emojis"), exports);
|
|
24
25
|
__exportStar(require("./shorters/guilds"), exports);
|
|
26
|
+
__exportStar(require("./shorters/members"), exports);
|
|
27
|
+
__exportStar(require("./shorters/messages"), exports);
|
|
28
|
+
__exportStar(require("./shorters/reactions"), exports);
|
|
29
|
+
__exportStar(require("./shorters/roles"), exports);
|
|
30
|
+
__exportStar(require("./shorters/templates"), exports);
|
|
25
31
|
__exportStar(require("./shorters/users"), exports);
|
|
32
|
+
__exportStar(require("./shorters/webhook"), exports);
|
|
26
33
|
__exportStar(require("./types/options"), exports);
|
|
27
34
|
__exportStar(require("./types/resolvables"), exports);
|
|
28
35
|
__exportStar(require("./types/util"), exports);
|
package/lib/common/it/utils.js
CHANGED
|
@@ -240,6 +240,7 @@ async function magicImport(path) {
|
|
|
240
240
|
return require(path);
|
|
241
241
|
}
|
|
242
242
|
catch {
|
|
243
|
+
// biome-ignore lint/security/noGlobalEval: modules import broke
|
|
243
244
|
return eval('((path) => import(`file:///${path}`))')(path.split('\\').join('\\\\'));
|
|
244
245
|
}
|
|
245
246
|
}
|
|
@@ -248,6 +249,7 @@ function fakePromise(value) {
|
|
|
248
249
|
if (value instanceof Promise)
|
|
249
250
|
return value;
|
|
250
251
|
return {
|
|
252
|
+
// biome-ignore lint/suspicious/noThenProperty: magic
|
|
251
253
|
then: callback => callback(value),
|
|
252
254
|
};
|
|
253
255
|
}
|