seyfert 1.1.0 → 1.2.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/Routes/applications.d.ts +2 -2
- package/lib/api/Routes/channels.d.ts +2 -2
- package/lib/api/Routes/gateway.d.ts +2 -2
- package/lib/api/Routes/guilds.d.ts +2 -1
- package/lib/api/Routes/interactions.d.ts +2 -2
- package/lib/api/Routes/invites.d.ts +2 -2
- package/lib/api/Routes/stage-instances.d.ts +2 -2
- package/lib/api/Routes/stickers.d.ts +2 -2
- package/lib/api/Routes/users.d.ts +2 -2
- package/lib/api/Routes/voice.d.ts +2 -2
- package/lib/api/Routes/webhooks.d.ts +2 -2
- package/lib/builders/ActionRow.d.ts +2 -1
- package/lib/builders/ActionRow.js +3 -3
- package/lib/builders/Base.d.ts +1 -1
- package/lib/builders/Button.d.ts +2 -1
- package/lib/builders/Button.js +2 -2
- package/lib/builders/Embed.d.ts +2 -1
- package/lib/builders/Modal.d.ts +9 -2
- package/lib/builders/Modal.js +12 -3
- package/lib/builders/SelectMenu.d.ts +18 -1
- package/lib/builders/SelectMenu.js +36 -12
- package/lib/builders/index.d.ts +1 -1
- package/lib/builders/index.js +9 -9
- package/lib/builders/types.d.ts +1 -1
- package/lib/cache/adapters/types.d.ts +23 -23
- package/lib/cache/index.d.ts +5 -5
- package/lib/cache/index.js +3 -3
- package/lib/cache/resources/default/base.d.ts +10 -10
- package/lib/cache/resources/default/guild-based.d.ts +7 -7
- package/lib/cache/resources/default/guild-based.js +2 -1
- package/lib/cache/resources/default/guild-related.d.ts +9 -9
- package/lib/cache/resources/default/guild-related.js +2 -1
- package/lib/cache/resources/presence.d.ts +1 -1
- package/lib/cache/resources/stage-instances.d.ts +1 -1
- package/lib/cache/resources/voice-states.d.ts +1 -1
- package/lib/client/base.d.ts +19 -12
- package/lib/client/base.js +45 -7
- package/lib/client/client.d.ts +7 -4
- package/lib/client/client.js +21 -9
- package/lib/client/httpclient.d.ts +2 -1
- package/lib/client/httpclient.js +3 -3
- package/lib/client/oninteractioncreate.js +18 -19
- package/lib/client/onmessagecreate.js +6 -4
- package/lib/client/workerclient.d.ts +11 -5
- package/lib/client/workerclient.js +18 -11
- package/lib/commands/applications/chat.d.ts +4 -4
- package/lib/commands/applications/chat.js +17 -9
- package/lib/commands/applications/chatcontext.d.ts +7 -10
- package/lib/commands/applications/chatcontext.js +6 -17
- package/lib/commands/applications/menu.d.ts +2 -1
- package/lib/commands/applications/menu.js +7 -5
- package/lib/commands/applications/menucontext.d.ts +5 -9
- package/lib/commands/applications/menucontext.js +8 -21
- package/lib/commands/applications/shared.d.ts +5 -4
- package/lib/commands/basecontex.d.ts +15 -0
- package/lib/commands/basecontex.js +34 -0
- package/lib/commands/decorators.d.ts +3 -2
- package/lib/commands/decorators.js +5 -5
- package/lib/commands/handler.d.ts +6 -0
- package/lib/commands/handler.js +10 -4
- package/lib/commands/optionresolver.d.ts +3 -3
- package/lib/commands/optionresolver.js +14 -14
- package/lib/common/index.d.ts +0 -1
- package/lib/common/index.js +0 -1
- package/lib/common/it/constants.d.ts +3 -1
- package/lib/common/it/constants.js +2 -0
- package/lib/common/it/utils.d.ts +1 -0
- package/lib/common/it/utils.js +2 -1
- package/lib/common/shorters/channels.d.ts +1 -1
- package/lib/common/shorters/channels.js +4 -4
- package/lib/common/shorters/guilds.d.ts +1 -1
- package/lib/common/shorters/guilds.js +6 -1
- package/lib/common/shorters/members.d.ts +6 -1
- package/lib/common/shorters/members.js +25 -2
- package/lib/common/shorters/messages.d.ts +1 -1
- package/lib/common/shorters/messages.js +1 -1
- package/lib/common/shorters/users.d.ts +0 -6
- package/lib/common/shorters/users.js +0 -34
- package/lib/common/shorters/webhook.d.ts +2 -2
- package/lib/common/types/resolvables.d.ts +2 -1
- package/lib/common/types/util.d.ts +4 -1
- package/lib/common/types/write.d.ts +1 -1
- package/lib/components/ActionRow.d.ts +4 -3
- package/lib/components/ActionRow.js +6 -3
- package/lib/components/BaseComponent.d.ts +18 -0
- package/lib/components/BaseComponent.js +21 -0
- package/lib/components/BaseSelectMenuComponent.d.ts +10 -0
- package/lib/components/BaseSelectMenuComponent.js +22 -0
- package/lib/components/ButtonComponent.d.ts +14 -14
- package/lib/components/ButtonComponent.js +36 -25
- package/lib/components/ChannelSelectMenuComponent.d.ts +4 -4
- package/lib/components/ChannelSelectMenuComponent.js +6 -5
- package/lib/components/MentionableSelectMenuComponent.d.ts +3 -2
- package/lib/components/MentionableSelectMenuComponent.js +4 -1
- package/lib/components/RoleSelectMenuComponent.d.ts +3 -2
- package/lib/components/RoleSelectMenuComponent.js +4 -1
- package/lib/components/StringSelectMenuComponent.d.ts +3 -4
- package/lib/components/StringSelectMenuComponent.js +3 -5
- package/lib/components/TextInputComponent.d.ts +10 -5
- package/lib/components/TextInputComponent.js +24 -7
- package/lib/components/UserSelectMenuComponent.d.ts +3 -2
- package/lib/components/UserSelectMenuComponent.js +4 -1
- package/lib/components/command.d.ts +6 -5
- package/lib/components/command.js +4 -0
- package/lib/components/componentcontext.d.ts +42 -0
- package/lib/components/componentcontext.js +79 -0
- package/lib/components/handler.d.ts +22 -6
- package/lib/components/handler.js +19 -12
- package/lib/components/index.d.ts +2 -2
- package/lib/components/index.js +9 -9
- package/lib/events/handler.d.ts +12 -3
- package/lib/events/handler.js +6 -8
- package/lib/events/hooks/application_command.d.ts +2 -2
- package/lib/events/hooks/auto_moderation.d.ts +4 -4
- package/lib/events/hooks/channel.d.ts +1 -1
- package/lib/events/hooks/dispatch.d.ts +1 -1
- package/lib/events/hooks/entitlement.d.ts +4 -4
- package/lib/events/hooks/guild.d.ts +42 -42
- package/lib/events/hooks/integration.d.ts +19 -19
- package/lib/events/hooks/interactions.d.ts +2 -2
- package/lib/events/hooks/invite.d.ts +5 -5
- package/lib/events/hooks/message.d.ts +6 -5
- package/lib/events/hooks/presence.d.ts +7 -7
- package/lib/events/hooks/stage.d.ts +4 -4
- package/lib/events/hooks/thread.d.ts +49 -49
- package/lib/events/hooks/typing.d.ts +2 -2
- package/lib/events/hooks/user.d.ts +1 -1
- package/lib/events/hooks/voice.d.ts +2 -2
- package/lib/events/hooks/webhook.d.ts +1 -1
- package/lib/index.d.ts +3 -6
- package/lib/index.js +6 -7
- package/lib/langs/handler.d.ts +10 -1
- package/lib/langs/handler.js +1 -0
- package/lib/structures/AutoModerationRule.d.ts +3 -2
- package/lib/structures/ClientUser.d.ts +1 -1
- package/lib/structures/Guild.d.ts +27 -27
- package/lib/structures/GuildEmoji.d.ts +2 -1
- package/lib/structures/GuildMember.d.ts +16 -6
- package/lib/structures/GuildMember.js +35 -6
- package/lib/structures/GuildPreview.d.ts +1 -1
- package/lib/structures/GuildRole.d.ts +2 -1
- package/lib/structures/GuildTemplate.d.ts +3 -2
- package/lib/structures/Interaction.d.ts +5 -5
- package/lib/structures/Interaction.js +34 -34
- package/lib/structures/Message.d.ts +6 -5
- package/lib/structures/Sticker.d.ts +2 -1
- package/lib/structures/User.d.ts +7 -3
- package/lib/structures/User.js +5 -0
- package/lib/structures/Webhook.d.ts +63 -4
- package/lib/structures/Webhook.js +53 -0
- package/lib/structures/channels.d.ts +4 -4
- package/lib/structures/extra/BaseGuild.d.ts +2 -1
- package/lib/structures/extra/BaseGuild.js +3 -3
- package/lib/structures/extra/BitField.d.ts +2 -2
- package/lib/structures/extra/BitField.js +2 -2
- package/lib/structures/extra/Permissions.d.ts +1 -1
- package/lib/structures/extra/functions.d.ts +2 -1
- package/lib/structures/extra/functions.js +2 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +17 -0
- package/lib/websocket/SharedTypes.d.ts +2 -1
- package/lib/websocket/SharedTypes.js +1 -0
- package/lib/websocket/discord/shard.d.ts +2 -1
- package/lib/websocket/discord/shard.js +30 -41
- package/lib/websocket/discord/sharder.d.ts +3 -2
- package/lib/websocket/discord/sharder.js +7 -6
- package/lib/websocket/discord/shared.d.ts +2 -1
- package/lib/websocket/discord/worker.d.ts +1 -1
- package/lib/websocket/discord/workermanager.d.ts +3 -2
- package/lib/websocket/discord/workermanager.js +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { GatewayIntentBits } from 'discord-api-types/v10';
|
|
1
2
|
import type { BaseClient } from '../../../client/base';
|
|
2
3
|
import type { UsingClient } from '../../../commands';
|
|
3
|
-
import { type GatewayIntentBits } from '../../../common';
|
|
4
4
|
import type { Cache, ReturnCache } from '../../index';
|
|
5
5
|
export declare class BaseResource<T = any> {
|
|
6
6
|
protected cache: Cache;
|
|
@@ -9,19 +9,19 @@ export declare class BaseResource<T = any> {
|
|
|
9
9
|
constructor(cache: Cache, client?: UsingClient);
|
|
10
10
|
get rest(): import("../../..").ApiHandler;
|
|
11
11
|
get adapter(): import("../../index").Adapter;
|
|
12
|
-
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string): import("
|
|
12
|
+
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string): import("../../../common").Awaitable<void>;
|
|
13
13
|
setIfNI(intent: keyof typeof GatewayIntentBits, id: string, data: any): any;
|
|
14
14
|
get(id: string): ReturnCache<T | undefined>;
|
|
15
15
|
bulk(ids: string[]): ReturnCache<T[]>;
|
|
16
|
-
set(id: string, data: any): import("
|
|
17
|
-
patch<T extends Record<any, any> = Record<any, any>>(id: string, data: T): import("
|
|
18
|
-
remove(id: string): import("
|
|
16
|
+
set(id: string, data: any): import("../../../common").Awaitable<void>;
|
|
17
|
+
patch<T extends Record<any, any> = Record<any, any>>(id: string, data: T): import("../../../common").Awaitable<void>;
|
|
18
|
+
remove(id: string): import("../../../common").Awaitable<void>;
|
|
19
19
|
keys(): ReturnCache<string[]>;
|
|
20
20
|
values(): ReturnCache<T[]>;
|
|
21
|
-
count(): import("
|
|
22
|
-
contains(id: string): import("
|
|
23
|
-
getToRelationship(): import("
|
|
24
|
-
addToRelationship(id: string | string[]): import("
|
|
25
|
-
removeToRelationship(id: string | string[]): import("
|
|
21
|
+
count(): import("../../../common").Awaitable<number>;
|
|
22
|
+
contains(id: string): import("../../../common").Awaitable<boolean>;
|
|
23
|
+
getToRelationship(): import("../../../common").Awaitable<string[]>;
|
|
24
|
+
addToRelationship(id: string | string[]): import("../../../common").Awaitable<void>;
|
|
25
|
+
removeToRelationship(id: string | string[]): import("../../../common").Awaitable<void>;
|
|
26
26
|
hashId(id: string): string;
|
|
27
27
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { GatewayIntentBits } from 'discord-api-types/v10';
|
|
1
2
|
import type { BaseClient } from '../../../client/base';
|
|
2
3
|
import type { UsingClient } from '../../../commands';
|
|
3
|
-
import { type GatewayIntentBits } from '../../../common';
|
|
4
4
|
import type { Cache, ReturnCache } from '../../index';
|
|
5
5
|
export declare class GuildBasedResource<T = any> {
|
|
6
6
|
protected cache: Cache;
|
|
@@ -9,7 +9,7 @@ export declare class GuildBasedResource<T = any> {
|
|
|
9
9
|
constructor(cache: Cache, client?: UsingClient);
|
|
10
10
|
parse(data: any, id: string, guild_id: string): any;
|
|
11
11
|
get adapter(): import("../../index").Adapter;
|
|
12
|
-
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): import("
|
|
12
|
+
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): import("../../../common").Awaitable<void>;
|
|
13
13
|
setIfNI(intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: any): any;
|
|
14
14
|
get(id: string, guild: string): ReturnCache<(T & {
|
|
15
15
|
guild_id: string;
|
|
@@ -21,17 +21,17 @@ export declare class GuildBasedResource<T = any> {
|
|
|
21
21
|
set(__keys: [string, any][], guild: string): ReturnCache<void>;
|
|
22
22
|
patch(__keys: string, guild: string, data: any): ReturnCache<void>;
|
|
23
23
|
patch(__keys: [string, any][], guild: string): ReturnCache<void>;
|
|
24
|
-
remove(id: string | string[], guild: string): import("
|
|
24
|
+
remove(id: string | string[], guild: string): import("../../../common").Awaitable<void>;
|
|
25
25
|
keys(guild: string): ReturnCache<string[]>;
|
|
26
26
|
values(guild: string): ReturnCache<(T & {
|
|
27
27
|
guild_id: string;
|
|
28
28
|
})[]>;
|
|
29
29
|
count(guild: string): ReturnCache<number>;
|
|
30
30
|
contains(id: string, guild: string): ReturnCache<boolean>;
|
|
31
|
-
getToRelationship(guild: string): import("
|
|
32
|
-
addToRelationship(id: string | string[], guild: string): import("
|
|
33
|
-
removeToRelationship(id: string | string[], guild: string): import("
|
|
34
|
-
removeRelationship(id: string | string[]): import("
|
|
31
|
+
getToRelationship(guild: string): import("../../../common").Awaitable<string[]>;
|
|
32
|
+
addToRelationship(id: string | string[], guild: string): import("../../../common").Awaitable<void>;
|
|
33
|
+
removeToRelationship(id: string | string[], guild: string): import("../../../common").Awaitable<void>;
|
|
34
|
+
removeRelationship(id: string | string[]): import("../../../common").Awaitable<void>;
|
|
35
35
|
hashId(id: string): string;
|
|
36
36
|
hashGuildId(guild: string, id: string): string;
|
|
37
37
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { GatewayIntentBits } from 'discord-api-types/v10';
|
|
1
2
|
import type { BaseClient } from '../../../client/base';
|
|
2
3
|
import type { UsingClient } from '../../../commands';
|
|
3
|
-
import { type GatewayIntentBits } from '../../../common';
|
|
4
4
|
import type { Cache, ReturnCache } from '../../index';
|
|
5
5
|
export declare class GuildRelatedResource<T = any> {
|
|
6
6
|
protected cache: Cache;
|
|
@@ -9,7 +9,7 @@ export declare class GuildRelatedResource<T = any> {
|
|
|
9
9
|
constructor(cache: Cache, client?: UsingClient);
|
|
10
10
|
parse(data: any, id: string, guild_id: string): any;
|
|
11
11
|
get adapter(): import("../../index").Adapter;
|
|
12
|
-
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): import("
|
|
12
|
+
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): import("../../../common").Awaitable<void>;
|
|
13
13
|
setIfNI(intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: any): any;
|
|
14
14
|
get(id: string): ReturnCache<(T & {
|
|
15
15
|
guild_id: string;
|
|
@@ -21,16 +21,16 @@ export declare class GuildRelatedResource<T = any> {
|
|
|
21
21
|
set(__keys: [string, any][], guild: string): ReturnCache<void>;
|
|
22
22
|
patch(__keys: string, guild?: string, data?: any): ReturnCache<void>;
|
|
23
23
|
patch(__keys: [string, any][], guild?: string): ReturnCache<void>;
|
|
24
|
-
remove(id: string | string[], guild: string): import("
|
|
24
|
+
remove(id: string | string[], guild: string): import("../../../common").Awaitable<void>;
|
|
25
25
|
keys(guild: string): ReturnCache<string[]>;
|
|
26
26
|
values(guild: string): ReturnCache<(T & {
|
|
27
27
|
guild_id: string;
|
|
28
28
|
})[]>;
|
|
29
|
-
count(to: string): import("
|
|
30
|
-
contains(id: string, guild: string): import("
|
|
31
|
-
getToRelationship(guild: string): import("
|
|
32
|
-
addToRelationship(id: string | string[], guild: string): import("
|
|
33
|
-
removeToRelationship(id: string | string[], guild: string): import("
|
|
34
|
-
removeRelationship(id: string | string[]): import("
|
|
29
|
+
count(to: string): import("../../../common").Awaitable<number>;
|
|
30
|
+
contains(id: string, guild: string): import("../../../common").Awaitable<boolean>;
|
|
31
|
+
getToRelationship(guild: string): import("../../../common").Awaitable<string[]>;
|
|
32
|
+
addToRelationship(id: string | string[], guild: string): import("../../../common").Awaitable<void>;
|
|
33
|
+
removeToRelationship(id: string | string[], guild: string): import("../../../common").Awaitable<void>;
|
|
34
|
+
removeRelationship(id: string | string[]): import("../../../common").Awaitable<void>;
|
|
35
35
|
hashId(id: string): string;
|
|
36
36
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GatewayPresenceUpdate } from '
|
|
1
|
+
import type { GatewayPresenceUpdate } from 'discord-api-types/v10';
|
|
2
2
|
import { GuildRelatedResource } from './default/guild-related';
|
|
3
3
|
export declare class Presences extends GuildRelatedResource<PresenceResource> {
|
|
4
4
|
namespace: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { APIStageInstance } from '
|
|
1
|
+
import type { APIStageInstance } from 'discord-api-types/v10';
|
|
2
2
|
import { GuildRelatedResource } from './default/guild-related';
|
|
3
3
|
export declare class StageInstances extends GuildRelatedResource<APIStageInstance> {
|
|
4
4
|
namespace: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GatewayVoiceState } from '
|
|
1
|
+
import type { GatewayVoiceState } from 'discord-api-types/v10';
|
|
2
2
|
import { GuildBasedResource } from './default/guild-based';
|
|
3
3
|
export declare class VoiceStates extends GuildBasedResource<VoiceStateResource> {
|
|
4
4
|
namespace: string;
|
package/lib/client/base.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { ApiHandler } from '../api';
|
|
2
2
|
import type { Adapter } from '../cache';
|
|
3
3
|
import { Cache } from '../cache';
|
|
4
|
-
import type { RegisteredMiddlewares } from '../commands';
|
|
4
|
+
import type { Command, ContextMenuCommand, RegisteredMiddlewares } from '../commands';
|
|
5
5
|
import type { InferWithPrefix, MiddlewareContext } from '../commands/applications/shared';
|
|
6
|
-
import {
|
|
7
|
-
import { ChannelShorter, EmojiShorter, GuildShorter, Logger, MemberShorter, MessageShorter, ReactionShorter, RoleShorter, TemplateShorter, UsersShorter, WebhookShorter, type
|
|
6
|
+
import { type CommandHandlerLike } from '../commands/handler';
|
|
7
|
+
import { ChannelShorter, EmojiShorter, GuildShorter, Logger, MemberShorter, MessageShorter, ReactionShorter, RoleShorter, TemplateShorter, UsersShorter, WebhookShorter, type MakeRequired } from '../common';
|
|
8
|
+
import type { LocaleString } from 'discord-api-types/rest/v10';
|
|
8
9
|
import type { DeepPartial, IntentStrings, OmitInsert, When } from '../common/types/util';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
10
|
+
import type { ComponentCommand, ModalCommand } from '../components';
|
|
11
|
+
import { type ComponentHandlerLike } from '../components/handler';
|
|
12
|
+
import { type LangsHandlerLike } from '../langs/handler';
|
|
13
|
+
import type { ChatInputCommandInteraction, ComponentInteraction, Message, MessageCommandInteraction, UserCommandInteraction } from '../structures';
|
|
12
14
|
export declare class BaseClient {
|
|
13
15
|
rest: ApiHandler;
|
|
14
16
|
cache: Cache;
|
|
@@ -24,9 +26,9 @@ export declare class BaseClient {
|
|
|
24
26
|
emojis: EmojiShorter;
|
|
25
27
|
debugger?: Logger;
|
|
26
28
|
logger: Logger;
|
|
27
|
-
langs
|
|
28
|
-
commands
|
|
29
|
-
components
|
|
29
|
+
langs?: LangsHandlerLike;
|
|
30
|
+
commands?: CommandHandlerLike;
|
|
31
|
+
components?: ComponentHandlerLike;
|
|
30
32
|
private _applicationId?;
|
|
31
33
|
private _botId?;
|
|
32
34
|
middlewares?: Record<string, MiddlewareContext>;
|
|
@@ -39,7 +41,7 @@ export declare class BaseClient {
|
|
|
39
41
|
set applicationId(id: string);
|
|
40
42
|
get applicationId(): string;
|
|
41
43
|
get proxy(): import("../api").APIRoutes;
|
|
42
|
-
setServices({ rest, cache, langs, middlewares }: ServicesOptions): void;
|
|
44
|
+
setServices({ rest, cache, langs, middlewares, handlers }: ServicesOptions): void;
|
|
43
45
|
protected execute(..._options: unknown[]): Promise<void>;
|
|
44
46
|
start(options?: Pick<DeepPartial<StartOptions>, 'langsDir' | 'commandsDir' | 'connection' | 'token' | 'componentsDir'>): Promise<void>;
|
|
45
47
|
protected onPacket(..._packet: unknown[]): Promise<void>;
|
|
@@ -63,7 +65,7 @@ export declare class BaseClient {
|
|
|
63
65
|
}>;
|
|
64
66
|
}
|
|
65
67
|
export interface BaseClientOptions {
|
|
66
|
-
context?: (interaction: ChatInputCommandInteraction<boolean> | UserCommandInteraction<boolean> | MessageCommandInteraction<boolean> | When<InferWithPrefix, Message, never>) => {};
|
|
68
|
+
context?: (interaction: ChatInputCommandInteraction<boolean> | UserCommandInteraction<boolean> | MessageCommandInteraction<boolean> | ComponentInteraction | When<InferWithPrefix, Message, never>) => {};
|
|
67
69
|
globalMiddlewares?: readonly (keyof RegisteredMiddlewares)[];
|
|
68
70
|
}
|
|
69
71
|
export interface StartOptions {
|
|
@@ -107,7 +109,7 @@ export type RuntimeConfigHTTP = Omit<MakeRequired<RC, 'publicKey' | 'application
|
|
|
107
109
|
};
|
|
108
110
|
export type InternalRuntimeConfig = Omit<MakeRequired<RC, 'intents'>, 'publicKey' | 'port'>;
|
|
109
111
|
export type RuntimeConfig = OmitInsert<InternalRuntimeConfig, 'intents', {
|
|
110
|
-
intents?: IntentStrings | number;
|
|
112
|
+
intents?: IntentStrings | number[] | number;
|
|
111
113
|
}>;
|
|
112
114
|
export interface ServicesOptions {
|
|
113
115
|
rest?: ApiHandler;
|
|
@@ -120,5 +122,10 @@ export interface ServicesOptions {
|
|
|
120
122
|
aliases?: Record<string, LocaleString[]>;
|
|
121
123
|
};
|
|
122
124
|
middlewares?: Record<string, MiddlewareContext>;
|
|
125
|
+
handlers?: {
|
|
126
|
+
components?: ComponentHandlerLike | ((component: ComponentCommand | ModalCommand) => any);
|
|
127
|
+
commands?: CommandHandlerLike | ((command: Command | ContextMenuCommand) => any);
|
|
128
|
+
langs?: LangsHandlerLike | ((locale: string, record: Record<string, unknown>) => any);
|
|
129
|
+
};
|
|
123
130
|
}
|
|
124
131
|
export {};
|
package/lib/client/base.js
CHANGED
|
@@ -58,22 +58,60 @@ class BaseClient {
|
|
|
58
58
|
get proxy() {
|
|
59
59
|
return new api_1.Router(this.rest).createProxy();
|
|
60
60
|
}
|
|
61
|
-
setServices({ rest, cache, langs, middlewares }) {
|
|
61
|
+
setServices({ rest, cache, langs, middlewares, handlers }) {
|
|
62
62
|
if (rest) {
|
|
63
63
|
this.rest = rest;
|
|
64
64
|
}
|
|
65
65
|
if (cache) {
|
|
66
66
|
this.cache = new cache_1.Cache(this.cache?.intents ?? 0, cache?.adapter ?? this.cache?.adapter ?? new cache_1.MemoryAdapter(), cache.disabledCache ?? this.cache?.disabledCache ?? [], this);
|
|
67
67
|
}
|
|
68
|
+
if (middlewares) {
|
|
69
|
+
this.middlewares = middlewares;
|
|
70
|
+
}
|
|
71
|
+
if (handlers) {
|
|
72
|
+
if ('components' in handlers) {
|
|
73
|
+
if (!handlers.components) {
|
|
74
|
+
this.components = undefined;
|
|
75
|
+
}
|
|
76
|
+
else if (typeof handlers.components === 'function') {
|
|
77
|
+
this.components = new handler_2.ComponentHandler(this.logger, this);
|
|
78
|
+
this.components.__callback = handlers.components;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
this.components = handlers.components;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if ('commands' in handlers) {
|
|
85
|
+
if (!handlers.commands) {
|
|
86
|
+
this.commands = undefined;
|
|
87
|
+
}
|
|
88
|
+
else if (typeof handlers.commands === 'function') {
|
|
89
|
+
this.commands = new handler_1.CommandHandler(this.logger, this);
|
|
90
|
+
this.commands.__callback = handlers.commands;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
this.commands = handlers.commands;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if ('langs' in handlers) {
|
|
97
|
+
if (!handlers.langs) {
|
|
98
|
+
this.langs = undefined;
|
|
99
|
+
}
|
|
100
|
+
else if (typeof handlers.langs === 'function') {
|
|
101
|
+
this.langs = new handler_3.LangsHandler(this.logger);
|
|
102
|
+
this.langs.__callback = handlers.langs;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
this.langs = handlers.langs;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
68
109
|
if (langs) {
|
|
69
110
|
if (langs.default)
|
|
70
111
|
this.langs.defaultLang = langs.default;
|
|
71
112
|
if (langs.aliases)
|
|
72
113
|
this.langs.aliases = Object.entries(langs.aliases);
|
|
73
114
|
}
|
|
74
|
-
if (middlewares) {
|
|
75
|
-
this.middlewares = middlewares;
|
|
76
|
-
}
|
|
77
115
|
}
|
|
78
116
|
async execute(..._options) {
|
|
79
117
|
if ((await this.getRC()).debug) {
|
|
@@ -139,21 +177,21 @@ class BaseClient {
|
|
|
139
177
|
}
|
|
140
178
|
async loadCommands(dir) {
|
|
141
179
|
dir ??= await this.getRC().then(x => x.commands);
|
|
142
|
-
if (dir) {
|
|
180
|
+
if (dir && this.commands) {
|
|
143
181
|
await this.commands.load(dir, this);
|
|
144
182
|
this.logger.info('CommandHandler loaded');
|
|
145
183
|
}
|
|
146
184
|
}
|
|
147
185
|
async loadComponents(dir) {
|
|
148
186
|
dir ??= await this.getRC().then(x => x.components);
|
|
149
|
-
if (dir) {
|
|
187
|
+
if (dir && this.components) {
|
|
150
188
|
await this.components.load(dir);
|
|
151
189
|
this.logger.info('ComponentHandler loaded');
|
|
152
190
|
}
|
|
153
191
|
}
|
|
154
192
|
async loadLangs(dir) {
|
|
155
193
|
dir ??= await this.getRC().then(x => x.langs);
|
|
156
|
-
if (dir) {
|
|
194
|
+
if (dir && this.langs) {
|
|
157
195
|
await this.langs.load(dir);
|
|
158
196
|
this.logger.info('LangsHandler loaded');
|
|
159
197
|
}
|
package/lib/client/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { type GatewayDispatchPayload, type GatewayPresenceUpdateData } from 'discord-api-types/v10';
|
|
2
|
+
import type { ClientEvent, Command, CommandContext, EventHandlerLike, Message, SubCommand } from '..';
|
|
3
|
+
import type { DeepPartial, If } from '../common';
|
|
4
4
|
import { ClientUser } from '../structures';
|
|
5
5
|
import { ShardManager, type ShardManagerOptions } from '../websocket';
|
|
6
6
|
import { MemberUpdateHandler } from '../websocket/discord/events/memberUpdate';
|
|
@@ -10,7 +10,7 @@ import { BaseClient } from './base';
|
|
|
10
10
|
export declare class Client<Ready extends boolean = boolean> extends BaseClient {
|
|
11
11
|
private __handleGuilds?;
|
|
12
12
|
gateway: ShardManager;
|
|
13
|
-
events
|
|
13
|
+
events?: EventHandlerLike;
|
|
14
14
|
me: If<Ready, ClientUser>;
|
|
15
15
|
options: ClientOptions | undefined;
|
|
16
16
|
memberUpdateHandler: MemberUpdateHandler;
|
|
@@ -18,6 +18,9 @@ export declare class Client<Ready extends boolean = boolean> extends BaseClient
|
|
|
18
18
|
constructor(options?: ClientOptions);
|
|
19
19
|
setServices({ gateway, ...rest }: ServicesOptions & {
|
|
20
20
|
gateway?: ShardManager;
|
|
21
|
+
handlers?: ServicesOptions['handlers'] & {
|
|
22
|
+
events?: EventHandlerLike | ((event: ClientEvent) => any);
|
|
23
|
+
};
|
|
21
24
|
}): void;
|
|
22
25
|
loadEvents(dir?: string): Promise<void>;
|
|
23
26
|
protected execute(options?: {
|
package/lib/client/client.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Client = void 0;
|
|
4
|
+
const v10_1 = require("discord-api-types/v10");
|
|
4
5
|
const node_worker_threads_1 = require("node:worker_threads");
|
|
5
|
-
const common_1 = require("../common");
|
|
6
6
|
const events_1 = require("../events");
|
|
7
7
|
const structures_1 = require("../structures");
|
|
8
8
|
const websocket_1 = require("../websocket");
|
|
@@ -32,10 +32,22 @@ class Client extends base_1.BaseClient {
|
|
|
32
32
|
};
|
|
33
33
|
this.gateway = gateway;
|
|
34
34
|
}
|
|
35
|
+
if (rest.handlers && 'events' in rest.handlers) {
|
|
36
|
+
if (!rest.handlers.events) {
|
|
37
|
+
this.events = undefined;
|
|
38
|
+
}
|
|
39
|
+
else if (typeof rest.handlers.events === 'function') {
|
|
40
|
+
this.events = new events_1.EventHandler(this.logger);
|
|
41
|
+
this.events.__callback = rest.handlers.events;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.events = rest.handlers.events;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
35
47
|
}
|
|
36
48
|
async loadEvents(dir) {
|
|
37
49
|
dir ??= await this.getRC().then(x => x.events);
|
|
38
|
-
if (dir) {
|
|
50
|
+
if (dir && this.events) {
|
|
39
51
|
await this.events.load(dir);
|
|
40
52
|
this.logger.info('EventHandler loaded');
|
|
41
53
|
}
|
|
@@ -92,21 +104,21 @@ class Client extends base_1.BaseClient {
|
|
|
92
104
|
}
|
|
93
105
|
}
|
|
94
106
|
async onPacket(shardId, packet) {
|
|
95
|
-
await this.events
|
|
107
|
+
await this.events?.runEvent('RAW', this, packet, shardId);
|
|
96
108
|
switch (packet.t) {
|
|
97
109
|
//// Cases where we must obtain the old data before updating
|
|
98
110
|
case 'GUILD_MEMBER_UPDATE':
|
|
99
111
|
if (!this.memberUpdateHandler.check(packet.d)) {
|
|
100
112
|
return;
|
|
101
113
|
}
|
|
102
|
-
await this.events
|
|
114
|
+
await this.events?.execute(packet.t, packet, this, shardId);
|
|
103
115
|
await this.cache.onPacket(packet);
|
|
104
116
|
break;
|
|
105
117
|
case 'PRESENCE_UPDATE':
|
|
106
118
|
if (!this.presenceUpdateHandler.check(packet.d)) {
|
|
107
119
|
return;
|
|
108
120
|
}
|
|
109
|
-
await this.events
|
|
121
|
+
await this.events?.execute(packet.t, packet, this, shardId);
|
|
110
122
|
await this.cache.onPacket(packet);
|
|
111
123
|
break;
|
|
112
124
|
//rest of the events
|
|
@@ -127,9 +139,9 @@ class Client extends base_1.BaseClient {
|
|
|
127
139
|
this.applicationId = packet.d.application.id;
|
|
128
140
|
this.me = new structures_1.ClientUser(this, packet.d.user, packet.d.application);
|
|
129
141
|
if (!this.__handleGuilds?.size ||
|
|
130
|
-
!((this.gateway.options.intents &
|
|
142
|
+
!((this.gateway.options.intents & v10_1.GatewayIntentBits.Guilds) === v10_1.GatewayIntentBits.Guilds)) {
|
|
131
143
|
if ([...this.gateway.values()].every(shard => shard.data.session_id)) {
|
|
132
|
-
await this.events
|
|
144
|
+
await this.events?.runEvent('BOT_READY', this, this.me, -1);
|
|
133
145
|
}
|
|
134
146
|
delete this.__handleGuilds;
|
|
135
147
|
}
|
|
@@ -139,7 +151,7 @@ class Client extends base_1.BaseClient {
|
|
|
139
151
|
if (this.__handleGuilds?.has(packet.d.id)) {
|
|
140
152
|
this.__handleGuilds.delete(packet.d.id);
|
|
141
153
|
if (!this.__handleGuilds.size && [...this.gateway.values()].every(shard => shard.data.session_id)) {
|
|
142
|
-
await this.events
|
|
154
|
+
await this.events?.runEvent('BOT_READY', this, this.me, -1);
|
|
143
155
|
}
|
|
144
156
|
if (!this.__handleGuilds.size)
|
|
145
157
|
delete this.__handleGuilds;
|
|
@@ -148,7 +160,7 @@ class Client extends base_1.BaseClient {
|
|
|
148
160
|
break;
|
|
149
161
|
}
|
|
150
162
|
}
|
|
151
|
-
await this.events
|
|
163
|
+
await this.events?.execute(packet.t, packet, this, shardId);
|
|
152
164
|
break;
|
|
153
165
|
}
|
|
154
166
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
import { type APIInteraction } from 'discord-api-types/v10';
|
|
2
3
|
import type { HttpRequest, HttpResponse } from 'uWebSockets.js';
|
|
3
|
-
import type {
|
|
4
|
+
import type { DeepPartial } from '../common';
|
|
4
5
|
import type { BaseClientOptions, StartOptions } from './base';
|
|
5
6
|
import { BaseClient } from './base';
|
|
6
7
|
export declare class HttpClient extends BaseClient {
|
package/lib/client/httpclient.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HttpClient = void 0;
|
|
4
|
+
const v10_1 = require("discord-api-types/v10");
|
|
4
5
|
const magic_bytes_js_1 = require("magic-bytes.js");
|
|
5
6
|
const api_1 = require("../api");
|
|
6
7
|
const utils_1 = require("../api/utils/utils");
|
|
7
|
-
const common_1 = require("../common");
|
|
8
8
|
const base_1 = require("./base");
|
|
9
9
|
const oninteractioncreate_1 = require("./oninteractioncreate");
|
|
10
10
|
let UWS;
|
|
@@ -104,11 +104,11 @@ class HttpClient extends base_1.BaseClient {
|
|
|
104
104
|
}
|
|
105
105
|
else {
|
|
106
106
|
switch (rawBody.type) {
|
|
107
|
-
case
|
|
107
|
+
case v10_1.InteractionType.Ping:
|
|
108
108
|
this.debugger?.debug('Ping interaction received, responding.');
|
|
109
109
|
res
|
|
110
110
|
.writeHeader('Content-Type', 'application/json')
|
|
111
|
-
.end(JSON.stringify({ type:
|
|
111
|
+
.end(JSON.stringify({ type: v10_1.InteractionResponseType.Pong }));
|
|
112
112
|
break;
|
|
113
113
|
default:
|
|
114
114
|
await (0, oninteractioncreate_1.onInteractionCreate)(this, rawBody, -1, async ({ body, files }) => {
|
|
@@ -9,13 +9,13 @@ async function onInteractionCreate(self, body, shardId, __reply) {
|
|
|
9
9
|
switch (body.type) {
|
|
10
10
|
case v10_1.InteractionType.ApplicationCommandAutocomplete:
|
|
11
11
|
{
|
|
12
|
-
const parentCommand = self.commands
|
|
13
|
-
if (
|
|
14
|
-
return
|
|
12
|
+
const parentCommand = self.commands?.values.find(x => {
|
|
13
|
+
if (body.data.guild_id) {
|
|
14
|
+
return x.guild_id?.includes(body.data.guild_id) && x.name === body.data.name;
|
|
15
15
|
}
|
|
16
16
|
return x.name === body.data.name;
|
|
17
17
|
});
|
|
18
|
-
const optionsResolver = new commands_1.OptionResolver(self, body.data.options ?? [], parentCommand, body.
|
|
18
|
+
const optionsResolver = new commands_1.OptionResolver(self, body.data.options ?? [], parentCommand, body.guild_id, body.data.resolved);
|
|
19
19
|
const interaction = new structures_1.AutocompleteInteraction(self, body, __reply);
|
|
20
20
|
const command = optionsResolver.getAutocomplete();
|
|
21
21
|
// idc, is a YOU problem
|
|
@@ -47,9 +47,9 @@ async function onInteractionCreate(self, body, shardId, __reply) {
|
|
|
47
47
|
case v10_1.ApplicationCommandType.Message:
|
|
48
48
|
case v10_1.ApplicationCommandType.User:
|
|
49
49
|
{
|
|
50
|
-
const command = self.commands
|
|
51
|
-
if (
|
|
52
|
-
return
|
|
50
|
+
const command = self.commands?.values.find(x => {
|
|
51
|
+
if (body.data.guild_id) {
|
|
52
|
+
return x.guild_id?.includes(body.data.guild_id) && x.name === body.data.name;
|
|
53
53
|
}
|
|
54
54
|
return x.name === body.data.name;
|
|
55
55
|
});
|
|
@@ -62,7 +62,7 @@ async function onInteractionCreate(self, body, shardId, __reply) {
|
|
|
62
62
|
Object.assign(context, extendContext);
|
|
63
63
|
try {
|
|
64
64
|
if (command.botPermissions && interaction.appPermissions) {
|
|
65
|
-
const permissions = interaction.appPermissions.missings(...interaction.appPermissions.values(command.botPermissions));
|
|
65
|
+
const permissions = interaction.appPermissions.missings(...interaction.appPermissions.values([command.botPermissions]));
|
|
66
66
|
if (permissions.length) {
|
|
67
67
|
return command.onPermissionsFail?.(context, interaction.appPermissions.keys(permissions));
|
|
68
68
|
}
|
|
@@ -102,14 +102,13 @@ async function onInteractionCreate(self, body, shardId, __reply) {
|
|
|
102
102
|
break;
|
|
103
103
|
case v10_1.ApplicationCommandType.ChatInput:
|
|
104
104
|
{
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return false;
|
|
105
|
+
const parentCommand = self.commands?.values.find(x => {
|
|
106
|
+
if (body.data.guild_id) {
|
|
107
|
+
return x.guild_id?.includes(body.data.guild_id) && x.name === body.data.name;
|
|
109
108
|
}
|
|
110
|
-
return x.name ===
|
|
109
|
+
return x.name === body.data.name;
|
|
111
110
|
});
|
|
112
|
-
const optionsResolver = new commands_1.OptionResolver(self,
|
|
111
|
+
const optionsResolver = new commands_1.OptionResolver(self, body.data.options ?? [], parentCommand, body.guild_id, body.data.resolved);
|
|
113
112
|
const interaction = structures_1.BaseInteraction.from(self, body, __reply);
|
|
114
113
|
const command = optionsResolver.getCommand();
|
|
115
114
|
if (!command?.run)
|
|
@@ -119,7 +118,7 @@ async function onInteractionCreate(self, body, shardId, __reply) {
|
|
|
119
118
|
Object.assign(context, extendContext);
|
|
120
119
|
try {
|
|
121
120
|
if (command.botPermissions && interaction.appPermissions) {
|
|
122
|
-
const permissions = interaction.appPermissions.missings(...interaction.appPermissions.values(command.botPermissions));
|
|
121
|
+
const permissions = interaction.appPermissions.missings(...interaction.appPermissions.values([command.botPermissions]));
|
|
123
122
|
if (permissions.length) {
|
|
124
123
|
return command.onPermissionsFail?.(context, interaction.appPermissions.keys(permissions));
|
|
125
124
|
}
|
|
@@ -167,22 +166,22 @@ async function onInteractionCreate(self, body, shardId, __reply) {
|
|
|
167
166
|
case v10_1.InteractionType.ModalSubmit:
|
|
168
167
|
{
|
|
169
168
|
const interaction = structures_1.BaseInteraction.from(self, body, __reply);
|
|
170
|
-
if (self.components
|
|
169
|
+
if (self.components?.hasModal(interaction)) {
|
|
171
170
|
await self.components.onModalSubmit(interaction);
|
|
172
171
|
}
|
|
173
172
|
else {
|
|
174
|
-
await self.components
|
|
173
|
+
await self.components?.executeModal(interaction);
|
|
175
174
|
}
|
|
176
175
|
}
|
|
177
176
|
break;
|
|
178
177
|
case v10_1.InteractionType.MessageComponent:
|
|
179
178
|
{
|
|
180
179
|
const interaction = structures_1.BaseInteraction.from(self, body, __reply);
|
|
181
|
-
if (self.components
|
|
180
|
+
if (self.components?.hasComponent(body.message.id, interaction.customId)) {
|
|
182
181
|
await self.components.onComponent(body.message.id, interaction);
|
|
183
182
|
}
|
|
184
183
|
else {
|
|
185
|
-
await self.components
|
|
184
|
+
await self.components?.executeComponent(interaction);
|
|
186
185
|
}
|
|
187
186
|
}
|
|
188
187
|
break;
|
|
@@ -45,13 +45,15 @@ async function onMessageCreate(self, rawMessage, shardId) {
|
|
|
45
45
|
if (!prefix || !message.content.startsWith(prefix))
|
|
46
46
|
return;
|
|
47
47
|
const content = message.content.slice(prefix.length).trimStart();
|
|
48
|
-
const { fullCommandName, command, parent } = getCommandFromContent(content
|
|
48
|
+
const { fullCommandName, command, parent } = getCommandFromContent(content
|
|
49
|
+
.split(' ')
|
|
50
|
+
.filter(x => x)
|
|
51
|
+
.slice(0, 3), self);
|
|
49
52
|
if (!command)
|
|
50
53
|
return;
|
|
51
54
|
if (!command.run)
|
|
52
55
|
return self.logger.warn(`${fullCommandName} command does not have 'run' callback`);
|
|
53
|
-
if (
|
|
54
|
-
!message.guildId)
|
|
56
|
+
if (!command.contexts?.includes(__1.InteractionContextTypes.BOT_DM) && !message.guildId)
|
|
55
57
|
return;
|
|
56
58
|
if (command.guild_id && !command.guild_id?.includes(message.guildId))
|
|
57
59
|
return;
|
|
@@ -75,7 +77,7 @@ async function onMessageCreate(self, rawMessage, shardId) {
|
|
|
75
77
|
if (!meMember)
|
|
76
78
|
return; //enable member cache and "Guilds" intent, lol
|
|
77
79
|
const appPermissions = await meMember.fetchPermissions();
|
|
78
|
-
const permissions = appPermissions.missings(...appPermissions.values(command.botPermissions));
|
|
80
|
+
const permissions = appPermissions.missings(...appPermissions.values([command.botPermissions]));
|
|
79
81
|
if (permissions.length) {
|
|
80
82
|
return command.onPermissionsFail?.(context, appPermissions.keys(permissions));
|
|
81
83
|
}
|