seyfert 1.1.1 → 1.2.1
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/index.d.ts +5 -5
- package/lib/cache/index.js +3 -3
- package/lib/cache/resources/default/base.d.ts +1 -1
- package/lib/cache/resources/default/guild-based.d.ts +1 -1
- package/lib/cache/resources/default/guild-related.d.ts +1 -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 +4 -3
- package/lib/client/client.d.ts +2 -1
- package/lib/client/client.js +2 -2
- package/lib/client/httpclient.d.ts +2 -1
- package/lib/client/httpclient.js +34 -32
- package/lib/client/oninteractioncreate.js +11 -12
- package/lib/client/onmessagecreate.js +2 -3
- package/lib/client/workerclient.d.ts +3 -2
- package/lib/client/workerclient.js +4 -3
- package/lib/commands/applications/chat.d.ts +3 -3
- package/lib/commands/applications/chat.js +4 -3
- package/lib/commands/applications/chatcontext.d.ts +6 -9
- package/lib/commands/applications/chatcontext.js +6 -17
- package/lib/commands/applications/menu.d.ts +2 -1
- package/lib/commands/applications/menucontext.d.ts +6 -10
- package/lib/commands/applications/menucontext.js +9 -22
- package/lib/commands/basecontex.d.ts +15 -0
- package/lib/commands/basecontex.js +34 -0
- package/lib/commands/decorators.d.ts +2 -1
- package/lib/commands/decorators.js +4 -4
- package/lib/commands/handler.js +4 -3
- 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/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/webhook.d.ts +2 -2
- package/lib/common/types/resolvables.d.ts +2 -1
- package/lib/common/types/util.d.ts +1 -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 +113 -0
- package/lib/components/componentcontext.js +135 -0
- package/lib/components/handler.d.ts +3 -3
- package/lib/components/handler.js +9 -4
- package/lib/components/index.d.ts +3 -2
- package/lib/components/index.js +10 -9
- package/lib/events/handler.d.ts +2 -1
- 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 +2 -1
- 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 +15 -6
- package/lib/structures/GuildMember.js +32 -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 +3 -3
- package/lib/structures/Interaction.js +33 -33
- package/lib/structures/Message.d.ts +5 -4
- package/lib/structures/Sticker.d.ts +2 -1
- package/lib/structures/User.d.ts +6 -3
- package/lib/structures/User.js +2 -1
- package/lib/structures/Webhook.d.ts +63 -4
- package/lib/structures/Webhook.js +53 -0
- package/lib/structures/channels.d.ts +2 -2
- 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,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MentionableSelectMenuComponent = void 0;
|
|
4
|
-
const BaseSelectMenuComponent_1 = require("
|
|
4
|
+
const BaseSelectMenuComponent_1 = require("./BaseSelectMenuComponent");
|
|
5
5
|
class MentionableSelectMenuComponent extends BaseSelectMenuComponent_1.BaseSelectMenuComponent {
|
|
6
|
+
get defaultValues() {
|
|
7
|
+
return this.data.default_values;
|
|
8
|
+
}
|
|
6
9
|
}
|
|
7
10
|
exports.MentionableSelectMenuComponent = MentionableSelectMenuComponent;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ComponentType } from '
|
|
2
|
-
import { BaseSelectMenuComponent } from '
|
|
1
|
+
import type { ComponentType } from 'discord-api-types/v10';
|
|
2
|
+
import { BaseSelectMenuComponent } from './BaseSelectMenuComponent';
|
|
3
3
|
export declare class RoleSelectMenuComponent extends BaseSelectMenuComponent<ComponentType.RoleSelect> {
|
|
4
|
+
get defaultValues(): import("discord-api-types/v10").APISelectMenuDefaultValue<import("discord-api-types/v10").SelectMenuDefaultValueType.Role>[] | undefined;
|
|
4
5
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RoleSelectMenuComponent = void 0;
|
|
4
|
-
const BaseSelectMenuComponent_1 = require("
|
|
4
|
+
const BaseSelectMenuComponent_1 = require("./BaseSelectMenuComponent");
|
|
5
5
|
class RoleSelectMenuComponent extends BaseSelectMenuComponent_1.BaseSelectMenuComponent {
|
|
6
|
+
get defaultValues() {
|
|
7
|
+
return this.data.default_values;
|
|
8
|
+
}
|
|
6
9
|
}
|
|
7
10
|
exports.RoleSelectMenuComponent = RoleSelectMenuComponent;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { BaseSelectMenuComponent } from '
|
|
1
|
+
import type { ComponentType } from 'discord-api-types/v10';
|
|
2
|
+
import { BaseSelectMenuComponent } from './BaseSelectMenuComponent';
|
|
3
3
|
export declare class StringSelectMenuComponent extends BaseSelectMenuComponent<ComponentType.StringSelect> {
|
|
4
|
-
|
|
5
|
-
options: APISelectMenuOption[];
|
|
4
|
+
get options(): import("discord-api-types/v10").APISelectMenuOption[];
|
|
6
5
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StringSelectMenuComponent = void 0;
|
|
4
|
-
const BaseSelectMenuComponent_1 = require("
|
|
4
|
+
const BaseSelectMenuComponent_1 = require("./BaseSelectMenuComponent");
|
|
5
5
|
class StringSelectMenuComponent extends BaseSelectMenuComponent_1.BaseSelectMenuComponent {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
this.options = data.options;
|
|
6
|
+
get options() {
|
|
7
|
+
return this.data.options;
|
|
9
8
|
}
|
|
10
|
-
options;
|
|
11
9
|
}
|
|
12
10
|
exports.StringSelectMenuComponent = StringSelectMenuComponent;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { BaseComponent } from '
|
|
1
|
+
import type { ComponentType } from 'discord-api-types/v10';
|
|
2
|
+
import { BaseComponent } from './BaseComponent';
|
|
3
3
|
export declare class TextInputComponent extends BaseComponent<ComponentType.TextInput> {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
get customId(): string;
|
|
5
|
+
get value(): string | undefined;
|
|
6
|
+
get style(): import("discord-api-types/v10").TextInputStyle;
|
|
7
|
+
get label(): string;
|
|
8
|
+
get max(): number | undefined;
|
|
9
|
+
get min(): number | undefined;
|
|
10
|
+
get required(): boolean | undefined;
|
|
11
|
+
get placeholder(): string | undefined;
|
|
7
12
|
}
|
|
@@ -1,14 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TextInputComponent = void 0;
|
|
4
|
-
const BaseComponent_1 = require("
|
|
4
|
+
const BaseComponent_1 = require("./BaseComponent");
|
|
5
5
|
class TextInputComponent extends BaseComponent_1.BaseComponent {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
get customId() {
|
|
7
|
+
return this.data.custom_id;
|
|
8
|
+
}
|
|
9
|
+
get value() {
|
|
10
|
+
return this.data.value;
|
|
11
|
+
}
|
|
12
|
+
get style() {
|
|
13
|
+
return this.data.style;
|
|
14
|
+
}
|
|
15
|
+
get label() {
|
|
16
|
+
return this.data.label;
|
|
17
|
+
}
|
|
18
|
+
get max() {
|
|
19
|
+
return this.data.max_length;
|
|
20
|
+
}
|
|
21
|
+
get min() {
|
|
22
|
+
return this.data.min_length;
|
|
23
|
+
}
|
|
24
|
+
get required() {
|
|
25
|
+
return this.data.required;
|
|
26
|
+
}
|
|
27
|
+
get placeholder() {
|
|
28
|
+
return this.data.placeholder;
|
|
10
29
|
}
|
|
11
|
-
customId;
|
|
12
|
-
value;
|
|
13
30
|
}
|
|
14
31
|
exports.TextInputComponent = TextInputComponent;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ComponentType } from '
|
|
2
|
-
import { BaseSelectMenuComponent } from '
|
|
1
|
+
import type { ComponentType } from 'discord-api-types/v10';
|
|
2
|
+
import { BaseSelectMenuComponent } from './BaseSelectMenuComponent';
|
|
3
3
|
export declare class UserSelectMenuComponent extends BaseSelectMenuComponent<ComponentType.UserSelect> {
|
|
4
|
+
get defaultValues(): import("discord-api-types/v10").APISelectMenuDefaultValue<import("discord-api-types/v10").SelectMenuDefaultValueType.User>[] | undefined;
|
|
4
5
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UserSelectMenuComponent = void 0;
|
|
4
|
-
const BaseSelectMenuComponent_1 = require("
|
|
4
|
+
const BaseSelectMenuComponent_1 = require("./BaseSelectMenuComponent");
|
|
5
5
|
class UserSelectMenuComponent extends BaseSelectMenuComponent_1.BaseSelectMenuComponent {
|
|
6
|
+
get defaultValues() {
|
|
7
|
+
return this.data.default_values;
|
|
8
|
+
}
|
|
6
9
|
}
|
|
7
10
|
exports.UserSelectMenuComponent = UserSelectMenuComponent;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { ModalSubmitInteraction } from '../structures';
|
|
2
|
+
import type { ComponentCommandInteractionMap, ComponentContext } from './componentcontext';
|
|
3
3
|
export declare const InteractionCommandType: {
|
|
4
4
|
readonly COMPONENT: 0;
|
|
5
5
|
readonly MODAL: 1;
|
|
@@ -9,9 +9,10 @@ export interface ComponentCommand {
|
|
|
9
9
|
}
|
|
10
10
|
export declare abstract class ComponentCommand {
|
|
11
11
|
type: 0;
|
|
12
|
-
abstract componentType:
|
|
13
|
-
abstract filter(interaction:
|
|
14
|
-
abstract run(interaction:
|
|
12
|
+
abstract componentType: keyof ComponentCommandInteractionMap;
|
|
13
|
+
abstract filter(interaction: ComponentContext<typeof this.componentType>): Promise<boolean> | boolean;
|
|
14
|
+
abstract run(interaction: ComponentContext<typeof this.componentType>): any;
|
|
15
|
+
get cType(): number;
|
|
15
16
|
}
|
|
16
17
|
export interface ModalCommand {
|
|
17
18
|
__filePath?: string;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ModalCommand = exports.ComponentCommand = exports.InteractionCommandType = void 0;
|
|
4
|
+
const v10_1 = require("discord-api-types/v10");
|
|
4
5
|
exports.InteractionCommandType = {
|
|
5
6
|
COMPONENT: 0,
|
|
6
7
|
MODAL: 1,
|
|
7
8
|
};
|
|
8
9
|
class ComponentCommand {
|
|
9
10
|
type = exports.InteractionCommandType.COMPONENT;
|
|
11
|
+
get cType() {
|
|
12
|
+
return v10_1.ComponentType[this.componentType];
|
|
13
|
+
}
|
|
10
14
|
}
|
|
11
15
|
exports.ComponentCommand = ComponentCommand;
|
|
12
16
|
class ModalCommand {
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { AllChannels, ButtonInteraction, ChannelSelectMenuInteraction, ComponentInteraction, Guild, GuildMember, MentionableSelectMenuInteraction, Message, ReturnCache, RoleSelectMenuInteraction, StringSelectMenuInteraction, UserSelectMenuInteraction, WebhookMessage } from '..';
|
|
2
|
+
import type { ExtendContext, UsingClient } from '../commands';
|
|
3
|
+
import { BaseContext } from '../commands/basecontex';
|
|
4
|
+
import type { ComponentInteractionMessageUpdate, InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest, When } from '../common';
|
|
5
|
+
export interface ComponentContext<Type extends keyof ComponentCommandInteractionMap> extends BaseContext, ExtendContext {
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Represents a context for interacting with components in a Discord bot.
|
|
9
|
+
* @template Type - The type of component interaction.
|
|
10
|
+
*/
|
|
11
|
+
export declare class ComponentContext<Type extends keyof ComponentCommandInteractionMap> extends BaseContext {
|
|
12
|
+
readonly client: UsingClient;
|
|
13
|
+
interaction: ComponentCommandInteractionMap[Type] | ComponentInteraction;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new instance of the ComponentContext class.
|
|
16
|
+
* @param client - The UsingClient instance.
|
|
17
|
+
* @param interaction - The component interaction object.
|
|
18
|
+
*/
|
|
19
|
+
constructor(client: UsingClient, interaction: ComponentCommandInteractionMap[Type] | ComponentInteraction);
|
|
20
|
+
/**
|
|
21
|
+
* Gets the proxy object.
|
|
22
|
+
*/
|
|
23
|
+
get proxy(): import("..").APIRoutes;
|
|
24
|
+
/**
|
|
25
|
+
* Gets the language object for the interaction's locale.
|
|
26
|
+
*/
|
|
27
|
+
get t(): import("..").__InternalParseLocale<import("..").DefaultLocale> & {
|
|
28
|
+
get(locale?: string | undefined): import("..").DefaultLocale;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Gets the custom ID of the interaction.
|
|
32
|
+
*/
|
|
33
|
+
get customId(): string;
|
|
34
|
+
/**
|
|
35
|
+
* Writes a response to the interaction.
|
|
36
|
+
* @param body - The body of the response.
|
|
37
|
+
* @param fetchReply - Whether to fetch the reply or not.
|
|
38
|
+
*/
|
|
39
|
+
write<FR extends boolean = false>(body: InteractionCreateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessage, void>>;
|
|
40
|
+
/**
|
|
41
|
+
* Defers the reply to the interaction.
|
|
42
|
+
* @param ephemeral - Whether the reply should be ephemeral or not.
|
|
43
|
+
*/
|
|
44
|
+
deferReply(ephemeral?: boolean): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Edits the response of the interaction.
|
|
47
|
+
* @param body - The updated body of the response.
|
|
48
|
+
*/
|
|
49
|
+
editResponse(body: InteractionMessageUpdateBodyRequest): Promise<Message>;
|
|
50
|
+
/**
|
|
51
|
+
* Updates the interaction with new data.
|
|
52
|
+
* @param body - The updated body of the interaction.
|
|
53
|
+
*/
|
|
54
|
+
update(body: ComponentInteractionMessageUpdate): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Edits the response or replies to the interaction.
|
|
57
|
+
* @param body - The body of the response or updated body of the interaction.
|
|
58
|
+
* @param fetchReply - Whether to fetch the reply or not.
|
|
59
|
+
*/
|
|
60
|
+
editOrReply<FR extends boolean = false>(body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessage | Message, void | WebhookMessage | Message>>;
|
|
61
|
+
/**
|
|
62
|
+
* Deletes the response of the interaction.
|
|
63
|
+
* @returns A promise that resolves when the response is deleted.
|
|
64
|
+
*/
|
|
65
|
+
deleteResponse(): Promise<void | undefined>;
|
|
66
|
+
/**
|
|
67
|
+
* Gets the channel of the interaction.
|
|
68
|
+
* @param mode - The mode to fetch the channel.
|
|
69
|
+
* @returns A promise that resolves to the channel.
|
|
70
|
+
*/
|
|
71
|
+
channel(mode?: 'rest' | 'flow'): Promise<AllChannels>;
|
|
72
|
+
channel(mode?: 'cache'): ReturnCache<AllChannels>;
|
|
73
|
+
/**
|
|
74
|
+
* Gets the bot member in the guild of the interaction.
|
|
75
|
+
* @param mode - The mode to fetch the member.
|
|
76
|
+
* @returns A promise that resolves to the bot member.
|
|
77
|
+
*/
|
|
78
|
+
me(mode?: 'rest' | 'flow'): Promise<GuildMember>;
|
|
79
|
+
me(mode?: 'cache'): ReturnCache<GuildMember | undefined>;
|
|
80
|
+
/**
|
|
81
|
+
* Gets the guild of the interaction.
|
|
82
|
+
* @param mode - The mode to fetch the guild.
|
|
83
|
+
* @returns A promise that resolves to the guild.
|
|
84
|
+
*/
|
|
85
|
+
guild(mode?: 'rest' | 'flow'): Promise<Guild<'cached' | 'api'> | undefined>;
|
|
86
|
+
guild(mode?: 'cache'): ReturnCache<Guild<'cached'> | undefined>;
|
|
87
|
+
/**
|
|
88
|
+
* Gets the ID of the guild of the interaction.
|
|
89
|
+
*/
|
|
90
|
+
get guildId(): string | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Gets the ID of the channel of the interaction.
|
|
93
|
+
*/
|
|
94
|
+
get channelId(): string;
|
|
95
|
+
/**
|
|
96
|
+
* Gets the author of the interaction.
|
|
97
|
+
*/
|
|
98
|
+
get author(): import("..").User;
|
|
99
|
+
/**
|
|
100
|
+
* Gets the member of the interaction.
|
|
101
|
+
*/
|
|
102
|
+
get member(): import("..").InteractionGuildMember | undefined;
|
|
103
|
+
}
|
|
104
|
+
export interface ComponentCommandInteractionMap {
|
|
105
|
+
ActionRow: never;
|
|
106
|
+
Button: ButtonInteraction;
|
|
107
|
+
StringSelect: StringSelectMenuInteraction;
|
|
108
|
+
TextInput: never;
|
|
109
|
+
UserSelect: UserSelectMenuInteraction;
|
|
110
|
+
RoleSelect: RoleSelectMenuInteraction;
|
|
111
|
+
MentionableSelect: MentionableSelectMenuInteraction;
|
|
112
|
+
ChannelSelect: ChannelSelectMenuInteraction;
|
|
113
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComponentContext = void 0;
|
|
4
|
+
const v10_1 = require("discord-api-types/v10");
|
|
5
|
+
const basecontex_1 = require("../commands/basecontex");
|
|
6
|
+
/**
|
|
7
|
+
* Represents a context for interacting with components in a Discord bot.
|
|
8
|
+
* @template Type - The type of component interaction.
|
|
9
|
+
*/
|
|
10
|
+
class ComponentContext extends basecontex_1.BaseContext {
|
|
11
|
+
client;
|
|
12
|
+
interaction;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new instance of the ComponentContext class.
|
|
15
|
+
* @param client - The UsingClient instance.
|
|
16
|
+
* @param interaction - The component interaction object.
|
|
17
|
+
*/
|
|
18
|
+
constructor(client, interaction) {
|
|
19
|
+
super(client);
|
|
20
|
+
this.client = client;
|
|
21
|
+
this.interaction = interaction;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Gets the proxy object.
|
|
25
|
+
*/
|
|
26
|
+
get proxy() {
|
|
27
|
+
return this.client.proxy;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Gets the language object for the interaction's locale.
|
|
31
|
+
*/
|
|
32
|
+
get t() {
|
|
33
|
+
return this.client.langs.get(this.interaction?.locale ?? this.client.langs?.defaultLang ?? 'en-US');
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Gets the custom ID of the interaction.
|
|
37
|
+
*/
|
|
38
|
+
get customId() {
|
|
39
|
+
return this.interaction.customId;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Writes a response to the interaction.
|
|
43
|
+
* @param body - The body of the response.
|
|
44
|
+
* @param fetchReply - Whether to fetch the reply or not.
|
|
45
|
+
*/
|
|
46
|
+
write(body, fetchReply) {
|
|
47
|
+
return this.interaction.write(body, fetchReply);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Defers the reply to the interaction.
|
|
51
|
+
* @param ephemeral - Whether the reply should be ephemeral or not.
|
|
52
|
+
*/
|
|
53
|
+
deferReply(ephemeral = false) {
|
|
54
|
+
return this.interaction.deferReply(ephemeral ? v10_1.MessageFlags.Ephemeral : undefined);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Edits the response of the interaction.
|
|
58
|
+
* @param body - The updated body of the response.
|
|
59
|
+
*/
|
|
60
|
+
editResponse(body) {
|
|
61
|
+
return this.interaction.editResponse(body);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Updates the interaction with new data.
|
|
65
|
+
* @param body - The updated body of the interaction.
|
|
66
|
+
*/
|
|
67
|
+
update(body) {
|
|
68
|
+
return this.interaction.update(body);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Edits the response or replies to the interaction.
|
|
72
|
+
* @param body - The body of the response or updated body of the interaction.
|
|
73
|
+
* @param fetchReply - Whether to fetch the reply or not.
|
|
74
|
+
*/
|
|
75
|
+
editOrReply(body, fetchReply) {
|
|
76
|
+
return this.interaction.editOrReply(body, fetchReply);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Deletes the response of the interaction.
|
|
80
|
+
* @returns A promise that resolves when the response is deleted.
|
|
81
|
+
*/
|
|
82
|
+
deleteResponse() {
|
|
83
|
+
return this.interaction.deleteResponse();
|
|
84
|
+
}
|
|
85
|
+
channel(mode = 'cache') {
|
|
86
|
+
if (this.interaction?.channel && mode === 'cache')
|
|
87
|
+
return this.client.cache.adapter.isAsync ? Promise.resolve(this.interaction.channel) : this.interaction.channel;
|
|
88
|
+
return this.client.channels.fetch(this.channelId, mode === 'rest');
|
|
89
|
+
}
|
|
90
|
+
me(mode = 'cache') {
|
|
91
|
+
if (!this.guildId)
|
|
92
|
+
return mode === 'cache' ? (this.client.cache.adapter.isAsync ? Promise.resolve() : undefined) : Promise.resolve();
|
|
93
|
+
switch (mode) {
|
|
94
|
+
case 'cache':
|
|
95
|
+
return this.client.cache.members?.get(this.client.botId, this.guildId);
|
|
96
|
+
default:
|
|
97
|
+
return this.client.members.fetch(this.guildId, this.client.botId, mode === 'rest');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
guild(mode = 'cache') {
|
|
101
|
+
if (!this.guildId)
|
|
102
|
+
return (mode === 'cache' ? (this.client.cache.adapter.isAsync ? Promise.resolve() : undefined) : Promise.resolve());
|
|
103
|
+
switch (mode) {
|
|
104
|
+
case 'cache':
|
|
105
|
+
return this.client.cache.guilds?.get(this.guildId);
|
|
106
|
+
default:
|
|
107
|
+
return this.client.guilds.fetch(this.guildId, mode === 'rest');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Gets the ID of the guild of the interaction.
|
|
112
|
+
*/
|
|
113
|
+
get guildId() {
|
|
114
|
+
return this.interaction.guildId;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Gets the ID of the channel of the interaction.
|
|
118
|
+
*/
|
|
119
|
+
get channelId() {
|
|
120
|
+
return this.interaction.channelId;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Gets the author of the interaction.
|
|
124
|
+
*/
|
|
125
|
+
get author() {
|
|
126
|
+
return this.interaction.user;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Gets the member of the interaction.
|
|
130
|
+
*/
|
|
131
|
+
get member() {
|
|
132
|
+
return this.interaction.member;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.ComponentContext = ComponentContext;
|
|
@@ -3,7 +3,7 @@ import type { ComponentCallback, ListenerOptions, ModalSubmitCallback } from '..
|
|
|
3
3
|
import { LimitedCollection } from '../collection';
|
|
4
4
|
import type { UsingClient } from '../commands';
|
|
5
5
|
import { BaseHandler, type Logger, type OnFailCallback } from '../common';
|
|
6
|
-
import type { ComponentInteraction, ModalSubmitInteraction } from '../structures';
|
|
6
|
+
import type { ComponentInteraction, ModalSubmitInteraction, StringSelectMenuInteraction } from '../structures';
|
|
7
7
|
import { ComponentCommand, ModalCommand } from './command';
|
|
8
8
|
type COMPONENTS = {
|
|
9
9
|
components: {
|
|
@@ -42,8 +42,8 @@ export declare class ComponentHandler extends BaseHandler {
|
|
|
42
42
|
protected filter: (path: string) => boolean;
|
|
43
43
|
constructor(logger: Logger, client: UsingClient);
|
|
44
44
|
createComponentCollector(messageId: string, options?: ListenerOptions): {
|
|
45
|
-
run
|
|
46
|
-
stop
|
|
45
|
+
run<T extends ComponentInteraction | StringSelectMenuInteraction = ComponentInteraction | StringSelectMenuInteraction>(customId: string | string[] | RegExp, callback: ComponentCallback<T>): any;
|
|
46
|
+
stop(reason?: string): any;
|
|
47
47
|
};
|
|
48
48
|
onComponent(id: string, interaction: ComponentInteraction): Promise<void>;
|
|
49
49
|
hasComponent(id: string, customId: string): boolean;
|
|
@@ -4,6 +4,7 @@ exports.ComponentHandler = void 0;
|
|
|
4
4
|
const collection_1 = require("../collection");
|
|
5
5
|
const common_1 = require("../common");
|
|
6
6
|
const command_1 = require("./command");
|
|
7
|
+
const componentcontext_1 = require("./componentcontext");
|
|
7
8
|
class ComponentHandler extends common_1.BaseHandler {
|
|
8
9
|
client;
|
|
9
10
|
onFail = err => this.logger.warn('<Client>.components.onFail', err);
|
|
@@ -46,6 +47,7 @@ class ComponentHandler extends common_1.BaseHandler {
|
|
|
46
47
|
},
|
|
47
48
|
});
|
|
48
49
|
return {
|
|
50
|
+
//@ts-expect-error generic
|
|
49
51
|
run: this.values.get(messageId).__run,
|
|
50
52
|
stop: (reason) => {
|
|
51
53
|
this.deleteValue(messageId);
|
|
@@ -171,10 +173,13 @@ class ComponentHandler extends common_1.BaseHandler {
|
|
|
171
173
|
async executeComponent(interaction) {
|
|
172
174
|
for (const i of this.commands) {
|
|
173
175
|
try {
|
|
174
|
-
if (i.type === command_1.InteractionCommandType.COMPONENT &&
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
if (i.type === command_1.InteractionCommandType.COMPONENT && i.cType === interaction.componentType) {
|
|
177
|
+
const context = new componentcontext_1.ComponentContext(this.client, interaction);
|
|
178
|
+
const extended = this.client.options?.context?.(interaction) ?? {};
|
|
179
|
+
Object.assign(context, extended);
|
|
180
|
+
if (!(await i.filter(context)))
|
|
181
|
+
continue;
|
|
182
|
+
await i.run(context);
|
|
178
183
|
break;
|
|
179
184
|
}
|
|
180
185
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { BaseComponent } from '
|
|
1
|
+
import { type APIMessageActionRowComponent } from 'discord-api-types/v10';
|
|
2
|
+
import { BaseComponent } from './BaseComponent';
|
|
3
3
|
import { ButtonComponent, LinkButtonComponent } from './ButtonComponent';
|
|
4
4
|
import { ChannelSelectMenuComponent } from './ChannelSelectMenuComponent';
|
|
5
5
|
import { MentionableSelectMenuComponent } from './MentionableSelectMenuComponent';
|
|
@@ -10,6 +10,7 @@ import { UserSelectMenuComponent } from './UserSelectMenuComponent';
|
|
|
10
10
|
export type MessageComponents = ButtonComponent | LinkButtonComponent | RoleSelectMenuComponent | UserSelectMenuComponent | StringSelectMenuComponent | ChannelSelectMenuComponent | MentionableSelectMenuComponent | TextInputComponent;
|
|
11
11
|
export type ActionRowMessageComponents = Exclude<MessageComponents, TextInputComponent>;
|
|
12
12
|
export * from './command';
|
|
13
|
+
export * from './componentcontext';
|
|
13
14
|
/**
|
|
14
15
|
* Return a new component instance based on the component type.
|
|
15
16
|
*
|
package/lib/components/index.js
CHANGED
|
@@ -15,8 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.componentFactory = void 0;
|
|
18
|
-
const
|
|
19
|
-
const BaseComponent_1 = require("
|
|
18
|
+
const v10_1 = require("discord-api-types/v10");
|
|
19
|
+
const BaseComponent_1 = require("./BaseComponent");
|
|
20
20
|
const ButtonComponent_1 = require("./ButtonComponent");
|
|
21
21
|
const ChannelSelectMenuComponent_1 = require("./ChannelSelectMenuComponent");
|
|
22
22
|
const MentionableSelectMenuComponent_1 = require("./MentionableSelectMenuComponent");
|
|
@@ -24,6 +24,7 @@ const RoleSelectMenuComponent_1 = require("./RoleSelectMenuComponent");
|
|
|
24
24
|
const StringSelectMenuComponent_1 = require("./StringSelectMenuComponent");
|
|
25
25
|
const UserSelectMenuComponent_1 = require("./UserSelectMenuComponent");
|
|
26
26
|
__exportStar(require("./command"), exports);
|
|
27
|
+
__exportStar(require("./componentcontext"), exports);
|
|
27
28
|
/**
|
|
28
29
|
* Return a new component instance based on the component type.
|
|
29
30
|
*
|
|
@@ -32,20 +33,20 @@ __exportStar(require("./command"), exports);
|
|
|
32
33
|
*/
|
|
33
34
|
function componentFactory(component) {
|
|
34
35
|
switch (component.type) {
|
|
35
|
-
case
|
|
36
|
-
if (component.style ===
|
|
36
|
+
case v10_1.ComponentType.Button:
|
|
37
|
+
if (component.style === v10_1.ButtonStyle.Link) {
|
|
37
38
|
return new ButtonComponent_1.LinkButtonComponent(component);
|
|
38
39
|
}
|
|
39
40
|
return new ButtonComponent_1.ButtonComponent(component);
|
|
40
|
-
case
|
|
41
|
+
case v10_1.ComponentType.ChannelSelect:
|
|
41
42
|
return new ChannelSelectMenuComponent_1.ChannelSelectMenuComponent(component);
|
|
42
|
-
case
|
|
43
|
+
case v10_1.ComponentType.RoleSelect:
|
|
43
44
|
return new RoleSelectMenuComponent_1.RoleSelectMenuComponent(component);
|
|
44
|
-
case
|
|
45
|
+
case v10_1.ComponentType.StringSelect:
|
|
45
46
|
return new StringSelectMenuComponent_1.StringSelectMenuComponent(component);
|
|
46
|
-
case
|
|
47
|
+
case v10_1.ComponentType.UserSelect:
|
|
47
48
|
return new UserSelectMenuComponent_1.UserSelectMenuComponent(component);
|
|
48
|
-
case
|
|
49
|
+
case v10_1.ComponentType.MentionableSelect:
|
|
49
50
|
return new MentionableSelectMenuComponent_1.MentionableSelectMenuComponent(component);
|
|
50
51
|
default:
|
|
51
52
|
return new BaseComponent_1.BaseComponent(component);
|
package/lib/events/handler.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { GatewayDispatchPayload } from 'discord-api-types/v10';
|
|
1
2
|
import type { Client, WorkerClient } from '../client';
|
|
2
|
-
import { BaseHandler, type
|
|
3
|
+
import { BaseHandler, type MakeRequired, type OnFailCallback, type SnakeCase } from '../common';
|
|
3
4
|
import type { ClientEvents } from '../events/hooks';
|
|
4
5
|
import type { ClientEvent, ClientNameEvents } from './event';
|
|
5
6
|
type EventValue = MakeRequired<ClientEvent, '__filePath'> & {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import type { GatewayApplicationCommandPermissionsUpdateDispatchData } from 'discord-api-types/v10';
|
|
1
2
|
import type { BaseClient } from '../../client/base';
|
|
2
|
-
import type { GatewayApplicationCommandPermissionsUpdateDispatchData } from '../../common';
|
|
3
3
|
export declare const APPLICATION_COMMAND_PERMISSIONS_UPDATE: (_self: BaseClient, data: GatewayApplicationCommandPermissionsUpdateDispatchData) => {
|
|
4
4
|
id: string;
|
|
5
5
|
applicationId: string;
|
|
6
6
|
guildId: string;
|
|
7
7
|
permissions: {
|
|
8
8
|
id: string;
|
|
9
|
-
type: import("discord-api-types/
|
|
9
|
+
type: import("discord-api-types/v10").ApplicationCommandPermissionType;
|
|
10
10
|
permission: boolean;
|
|
11
11
|
}[];
|
|
12
12
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import type { GatewayAutoModerationActionExecutionDispatchData, GatewayAutoModerationRuleCreateDispatchData, GatewayAutoModerationRuleDeleteDispatchData, GatewayAutoModerationRuleUpdateDispatchData } from 'discord-api-types/v10';
|
|
1
2
|
import type { BaseClient } from '../../client/base';
|
|
2
|
-
import { type GatewayAutoModerationActionExecutionDispatchData, type GatewayAutoModerationRuleCreateDispatchData, type GatewayAutoModerationRuleDeleteDispatchData, type GatewayAutoModerationRuleUpdateDispatchData } from '../../common';
|
|
3
3
|
import { AutoModerationRule } from '../../structures';
|
|
4
4
|
export declare const AUTO_MODERATION_ACTION_EXECUTION: (_self: BaseClient, data: GatewayAutoModerationActionExecutionDispatchData) => {
|
|
5
5
|
guildId: string;
|
|
6
6
|
action: {
|
|
7
|
-
type: import("discord-api-types/
|
|
8
|
-
metadata?: import("discord-api-types/
|
|
7
|
+
type: import("discord-api-types/v10").AutoModerationActionType;
|
|
8
|
+
metadata?: import("discord-api-types/v10").APIAutoModerationActionMetadata | undefined;
|
|
9
9
|
};
|
|
10
10
|
ruleId: string;
|
|
11
|
-
ruleTriggerType: import("discord-api-types/
|
|
11
|
+
ruleTriggerType: import("discord-api-types/v10").AutoModerationRuleTriggerType;
|
|
12
12
|
userId: string;
|
|
13
13
|
channelId?: string | undefined;
|
|
14
14
|
messageId?: string | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { GatewayChannelCreateDispatchData, GatewayChannelDeleteDispatchData, GatewayChannelPinsUpdateDispatchData, GatewayChannelUpdateDispatchData } from 'discord-api-types/v10';
|
|
2
2
|
import type { BaseClient } from '../../client/base';
|
|
3
3
|
import type { AllChannels } from '../../structures';
|
|
4
4
|
export declare const CHANNEL_CREATE: (self: BaseClient, data: GatewayChannelCreateDispatchData) => AllChannels;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { GatewayDispatchPayload, GatewayReadyDispatchData, GatewayResumedDispatch } from 'discord-api-types/v10';
|
|
1
2
|
import type { BaseClient } from '../../client/base';
|
|
2
|
-
import type { GatewayDispatchPayload, GatewayReadyDispatchData, GatewayResumedDispatch } from '../../common';
|
|
3
3
|
import { ClientUser } from '../../structures';
|
|
4
4
|
export declare const READY: (self: BaseClient, data: GatewayReadyDispatchData) => ClientUser;
|
|
5
5
|
export declare const RESUMED: (_self: BaseClient, _data: GatewayResumedDispatch['d']) => void;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import type { APIEntitlement } from 'discord-api-types/v10';
|
|
1
2
|
import type { BaseClient } from '../../client/base';
|
|
2
|
-
import { type APIEntitlement } from '../../common';
|
|
3
3
|
export declare const ENTITLEMENT_CREATE: (_: BaseClient, data: APIEntitlement) => {
|
|
4
4
|
id: string;
|
|
5
5
|
skuId: string;
|
|
6
6
|
userId?: string | undefined;
|
|
7
7
|
guildId?: string | undefined;
|
|
8
8
|
applicationId: string;
|
|
9
|
-
type: import("discord-api-types/
|
|
9
|
+
type: import("discord-api-types/v10").EntitlementType;
|
|
10
10
|
deleted: boolean;
|
|
11
11
|
startsAt?: string | undefined;
|
|
12
12
|
endsAt?: string | undefined;
|
|
@@ -17,7 +17,7 @@ export declare const ENTITLEMENT_UPDATE: (_: BaseClient, data: APIEntitlement) =
|
|
|
17
17
|
userId?: string | undefined;
|
|
18
18
|
guildId?: string | undefined;
|
|
19
19
|
applicationId: string;
|
|
20
|
-
type: import("discord-api-types/
|
|
20
|
+
type: import("discord-api-types/v10").EntitlementType;
|
|
21
21
|
deleted: boolean;
|
|
22
22
|
startsAt?: string | undefined;
|
|
23
23
|
endsAt?: string | undefined;
|
|
@@ -28,7 +28,7 @@ export declare const ENTITLEMENT_DELETE: (_: BaseClient, data: APIEntitlement) =
|
|
|
28
28
|
userId?: string | undefined;
|
|
29
29
|
guildId?: string | undefined;
|
|
30
30
|
applicationId: string;
|
|
31
|
-
type: import("discord-api-types/
|
|
31
|
+
type: import("discord-api-types/v10").EntitlementType;
|
|
32
32
|
deleted: boolean;
|
|
33
33
|
startsAt?: string | undefined;
|
|
34
34
|
endsAt?: string | undefined;
|