seyfert 1.0.1 → 1.1.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/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/types.d.ts +23 -23
- 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 +11 -10
- package/lib/cache/resources/default/guild-based.d.ts +8 -7
- package/lib/cache/resources/default/guild-based.js +8 -7
- package/lib/cache/resources/default/guild-related.d.ts +10 -9
- package/lib/cache/resources/default/guild-related.js +3 -2
- 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 +33 -179
- package/lib/client/base.js +56 -21
- package/lib/client/client.d.ts +10 -3
- package/lib/client/client.js +23 -8
- package/lib/client/oninteractioncreate.js +9 -9
- package/lib/client/onmessagecreate.js +192 -153
- package/lib/client/workerclient.d.ts +9 -3
- package/lib/client/workerclient.js +50 -23
- package/lib/collection.js +2 -2
- package/lib/commands/applications/chat.d.ts +16 -8
- package/lib/commands/applications/chat.js +20 -13
- package/lib/commands/applications/chatcontext.d.ts +6 -4
- package/lib/commands/applications/chatcontext.js +6 -1
- package/lib/commands/applications/menu.d.ts +5 -1
- package/lib/commands/applications/menu.js +11 -5
- package/lib/commands/applications/menucontext.d.ts +5 -3
- package/lib/commands/applications/menucontext.js +7 -2
- package/lib/commands/applications/options.d.ts +1 -2
- package/lib/commands/applications/shared.d.ts +5 -4
- package/lib/commands/decorators.d.ts +18 -6
- package/lib/commands/decorators.js +18 -8
- package/lib/commands/handler.d.ts +11 -5
- package/lib/commands/handler.js +46 -37
- 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.d.ts +1 -0
- package/lib/common/it/utils.js +4 -1
- 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 -6
- package/lib/common/shorters/users.js +29 -33
- 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/common/types/util.d.ts +3 -0
- package/lib/components/handler.d.ts +28 -9
- package/lib/components/handler.js +28 -11
- package/lib/events/handler.d.ts +10 -2
- package/lib/events/handler.js +6 -8
- package/lib/index.d.ts +4 -2
- package/lib/index.js +1 -1
- package/lib/langs/handler.d.ts +8 -0
- package/lib/langs/handler.js +8 -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 +7 -6
- package/lib/structures/GuildMember.js +5 -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 +9 -10
- package/lib/structures/Interaction.js +2 -2
- package/lib/structures/Message.d.ts +8 -7
- package/lib/structures/Message.js +7 -4
- package/lib/structures/Sticker.d.ts +2 -2
- package/lib/structures/User.d.ts +1 -0
- package/lib/structures/User.js +5 -0
- package/lib/structures/Webhook.d.ts +2 -2
- package/lib/structures/Webhook.js +3 -3
- package/lib/structures/channels.d.ts +21 -22
- 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
|
@@ -95,8 +95,9 @@ class Guilds extends base_1.BaseResource {
|
|
|
95
95
|
bulkData.push(['channels', channel, channel.id, id]);
|
|
96
96
|
}
|
|
97
97
|
for (const channel of data.channels ?? []) {
|
|
98
|
-
if (channel.permission_overwrites?.length)
|
|
98
|
+
if (channel.permission_overwrites?.length) {
|
|
99
99
|
bulkData.push(['overwrites', channel.permission_overwrites, channel.id, id]);
|
|
100
|
+
}
|
|
100
101
|
}
|
|
101
102
|
for (const emoji of data.emojis ?? []) {
|
|
102
103
|
bulkData.push(['emojis', emoji, emoji.id, id]);
|
|
@@ -3,7 +3,7 @@ import { PermissionsBitField } from '../../structures/extra/Permissions';
|
|
|
3
3
|
import { GuildRelatedResource } from './default/guild-related';
|
|
4
4
|
export declare class Overwrites extends GuildRelatedResource {
|
|
5
5
|
namespace: string;
|
|
6
|
-
parse(data: any, _id: string,
|
|
6
|
+
parse(data: any[], _id: string, guild_id: string): any[];
|
|
7
7
|
get(id: string): ReturnCache<{
|
|
8
8
|
type: number;
|
|
9
9
|
id: string;
|
|
@@ -6,7 +6,10 @@ const Permissions_1 = require("../../structures/extra/Permissions");
|
|
|
6
6
|
const guild_related_1 = require("./default/guild-related");
|
|
7
7
|
class Overwrites extends guild_related_1.GuildRelatedResource {
|
|
8
8
|
namespace = 'overwrite';
|
|
9
|
-
parse(data, _id,
|
|
9
|
+
parse(data, _id, guild_id) {
|
|
10
|
+
data.forEach(x => {
|
|
11
|
+
x.guild_id = guild_id;
|
|
12
|
+
});
|
|
10
13
|
return data;
|
|
11
14
|
}
|
|
12
15
|
get(id) {
|
|
@@ -16,6 +19,7 @@ class Overwrites extends guild_related_1.GuildRelatedResource {
|
|
|
16
19
|
deny: new Permissions_1.PermissionsBitField(BigInt(rawOverwrite.deny)),
|
|
17
20
|
id: rawOverwrite.id,
|
|
18
21
|
type: rawOverwrite.type,
|
|
22
|
+
guildId: rawOverwrite.guild_id,
|
|
19
23
|
}))
|
|
20
24
|
: undefined);
|
|
21
25
|
}
|
|
@@ -25,6 +29,7 @@ class Overwrites extends guild_related_1.GuildRelatedResource {
|
|
|
25
29
|
deny: new Permissions_1.PermissionsBitField(BigInt(rawOverwrite.deny)),
|
|
26
30
|
id: rawOverwrite.id,
|
|
27
31
|
type: rawOverwrite.type,
|
|
32
|
+
guildId: rawOverwrite.guild_id,
|
|
28
33
|
}))));
|
|
29
34
|
}
|
|
30
35
|
bulk(ids) {
|
|
@@ -33,6 +38,7 @@ class Overwrites extends guild_related_1.GuildRelatedResource {
|
|
|
33
38
|
deny: new Permissions_1.PermissionsBitField(BigInt(rawOverwrite.deny)),
|
|
34
39
|
id: rawOverwrite.id,
|
|
35
40
|
type: rawOverwrite.type,
|
|
41
|
+
guildId: rawOverwrite.guild_id,
|
|
36
42
|
}))));
|
|
37
43
|
}
|
|
38
44
|
}
|
package/lib/client/base.d.ts
CHANGED
|
@@ -1,184 +1,33 @@
|
|
|
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';
|
|
5
|
-
import type { MiddlewareContext } from '../commands/applications/shared';
|
|
6
|
-
import {
|
|
7
|
-
import { Logger, type LocaleString, type MakeRequired } from '../common';
|
|
8
|
-
import type { DeepPartial, IntentStrings, OmitInsert } from '../common/types/util';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
4
|
+
import type { Command, ContextMenuCommand, RegisteredMiddlewares } from '../commands';
|
|
5
|
+
import type { InferWithPrefix, MiddlewareContext } from '../commands/applications/shared';
|
|
6
|
+
import { type CommandHandlerLike } from '../commands/handler';
|
|
7
|
+
import { ChannelShorter, EmojiShorter, GuildShorter, Logger, MemberShorter, MessageShorter, ReactionShorter, RoleShorter, TemplateShorter, UsersShorter, WebhookShorter, type LocaleString, type MakeRequired } from '../common';
|
|
8
|
+
import type { DeepPartial, IntentStrings, OmitInsert, When } from '../common/types/util';
|
|
9
|
+
import type { ComponentCommand, ModalCommand } from '../components';
|
|
10
|
+
import { type ComponentHandlerLike } from '../components/handler';
|
|
11
|
+
import { type LangsHandlerLike } from '../langs/handler';
|
|
12
|
+
import type { ChatInputCommandInteraction, Message, MessageCommandInteraction, UserCommandInteraction } from '../structures';
|
|
12
13
|
export declare class BaseClient {
|
|
13
14
|
rest: ApiHandler;
|
|
14
15
|
cache: Cache;
|
|
15
|
-
users:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
reason: string;
|
|
26
|
-
}>) => Promise<import("../structures").AllChannels>;
|
|
27
|
-
edit: (id: string, body: import("discord-api-types/rest/v10/channel").RESTPatchAPIChannelJSONBody, optional?: Partial<{
|
|
28
|
-
guildId: string;
|
|
29
|
-
reason: string;
|
|
30
|
-
}>) => Promise<import("../structures").AllChannels>;
|
|
31
|
-
typing: (id: string) => Promise<never>;
|
|
32
|
-
pins: {
|
|
33
|
-
fetch: (channelId: string) => Promise<import("../structures").Message[]>;
|
|
34
|
-
set: (messageId: string, channelId: string, reason?: string | undefined) => Promise<never>;
|
|
35
|
-
delete: (messageId: string, channelId: string, reason?: string | undefined) => Promise<never>;
|
|
36
|
-
};
|
|
37
|
-
overwrites: {
|
|
38
|
-
memberPermissions: (channelId: string, member: import("../structures").GuildMember, checkAdmin?: boolean) => Promise<import("../structures/extra/Permissions").PermissionsBitField>;
|
|
39
|
-
overwritesFor: (channelId: string, member: import("../structures").GuildMember) => Promise<{
|
|
40
|
-
everyone: {
|
|
41
|
-
type: number;
|
|
42
|
-
id: string;
|
|
43
|
-
deny: import("../structures/extra/Permissions").PermissionsBitField;
|
|
44
|
-
allow: import("../structures/extra/Permissions").PermissionsBitField;
|
|
45
|
-
} | undefined;
|
|
46
|
-
roles: {
|
|
47
|
-
type: number;
|
|
48
|
-
id: string;
|
|
49
|
-
deny: import("../structures/extra/Permissions").PermissionsBitField;
|
|
50
|
-
allow: import("../structures/extra/Permissions").PermissionsBitField;
|
|
51
|
-
}[];
|
|
52
|
-
member: {
|
|
53
|
-
type: number;
|
|
54
|
-
id: string;
|
|
55
|
-
deny: import("../structures/extra/Permissions").PermissionsBitField;
|
|
56
|
-
allow: import("../structures/extra/Permissions").PermissionsBitField;
|
|
57
|
-
} | undefined;
|
|
58
|
-
}>;
|
|
59
|
-
rolePermissions: (channelId: string, role: import("../structures").GuildRole, checkAdmin?: boolean) => Promise<import("../structures/extra/Permissions").PermissionsBitField>;
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
guilds: {
|
|
63
|
-
create: (body: import("discord-api-types/rest/v10/guild").RESTPostAPIGuildsJSONBody) => Promise<import("../structures").Guild<"api">>;
|
|
64
|
-
fetch: (id: string, force?: boolean) => Promise<import("../structures").Guild<"cached"> | import("../structures").Guild<"api">>;
|
|
65
|
-
widgetURL: (id: string, style?: import("discord-api-types/payloads/v10/guild").GuildWidgetStyle | undefined) => Promise<import("discord-api-types/payloads/v10/guild").APIGuildWidgetSettings>;
|
|
66
|
-
list: (query?: import("discord-api-types/rest/v10/user").RESTGetAPICurrentUserGuildsQuery | undefined) => Promise<import("../structures").AnonymousGuild[]>;
|
|
67
|
-
fetchSelf: (id: string) => Promise<import("../structures").GuildMember>;
|
|
68
|
-
leave: (id: string) => Promise<void | undefined>;
|
|
69
|
-
channels: {
|
|
70
|
-
list: (guildId: string, force?: boolean) => Promise<import("../structures").AllChannels[]>;
|
|
71
|
-
fetch: (guildId: string, channelId: string, force?: boolean | undefined) => Promise<import("../structures").AllChannels>;
|
|
72
|
-
create: (guildId: string, body: import("discord-api-types/rest/v10/guild").RESTPostAPIGuildChannelJSONBody) => Promise<import("../structures").AllChannels>;
|
|
73
|
-
delete: (guildId: string, channelId: string, reason?: string | undefined) => Promise<import("../structures").AllChannels>;
|
|
74
|
-
edit: (guildchannelId: string, channelId: string, body: import("discord-api-types/rest/v10/channel").RESTPatchAPIChannelJSONBody, reason?: string | undefined) => Promise<import("../structures").AllChannels>;
|
|
75
|
-
editPositions: (guildId: string, body: import("discord-api-types/rest/v10/guild").RESTPatchAPIGuildChannelPositionsJSONBody) => Promise<never>;
|
|
76
|
-
};
|
|
77
|
-
moderation: {
|
|
78
|
-
list: (guildId: string) => Promise<import("discord-api-types/rest/v10/autoModeration").RESTGetAPIAutoModerationRulesResult>;
|
|
79
|
-
create: (guildId: string, body: import("discord-api-types/rest/v10/autoModeration").RESTPostAPIAutoModerationRuleJSONBody) => Promise<import("discord-api-types/payloads/v10/autoModeration").APIAutoModerationRule>;
|
|
80
|
-
delete: (guildId: string, ruleId: string, reason?: string | undefined) => Promise<never>;
|
|
81
|
-
fetch: (guildId: string, ruleId: string) => Promise<import("discord-api-types/payloads/v10/autoModeration").APIAutoModerationRule>;
|
|
82
|
-
edit: (guildId: string, ruleId: string, body: {
|
|
83
|
-
name?: string | undefined;
|
|
84
|
-
eventType?: import("discord-api-types/payloads/v10/autoModeration").AutoModerationRuleEventType | undefined;
|
|
85
|
-
triggerMetadata?: import("discord-api-types/payloads/v10/autoModeration").APIAutoModerationRuleTriggerMetadata | undefined;
|
|
86
|
-
actions?: import("discord-api-types/payloads/v10/autoModeration").APIAutoModerationAction[] | undefined;
|
|
87
|
-
enabled?: boolean | undefined;
|
|
88
|
-
exemptRoles?: string[] | undefined;
|
|
89
|
-
exemptChannels?: string[] | undefined;
|
|
90
|
-
}, reason?: string | undefined) => Promise<import("discord-api-types/payloads/v10/autoModeration").APIAutoModerationRule>;
|
|
91
|
-
};
|
|
92
|
-
stickers: {
|
|
93
|
-
list: (guildId: string) => Promise<import("../structures").Sticker[]>;
|
|
94
|
-
create: (guildId: string, { file, ...json }: import("../structures").CreateStickerBodyRequest, reason?: string | undefined) => Promise<import("../structures").Sticker>;
|
|
95
|
-
edit: (guildId: string, stickerId: string, body: import("discord-api-types/rest/v10/sticker").RESTPatchAPIGuildStickerJSONBody, reason?: string | undefined) => Promise<import("../structures").Sticker>;
|
|
96
|
-
fetch: (guildId: string, stickerId: string, force?: boolean) => Promise<import("../structures").Sticker>;
|
|
97
|
-
delete: (guildId: string, stickerId: string, reason?: string | undefined) => Promise<void>;
|
|
98
|
-
};
|
|
99
|
-
emojis: {
|
|
100
|
-
list: (guildId: string, force?: boolean) => Promise<import("../structures").GuildEmoji[]>;
|
|
101
|
-
create: (guildId: string, body: Omit<import("discord-api-types/rest/v10/emoji").RESTPostAPIGuildEmojiJSONBody, "image"> & {
|
|
102
|
-
image: import("../common").ImageResolvable;
|
|
103
|
-
}) => Promise<void>;
|
|
104
|
-
fetch: (guildId: string, emojiId: string, force?: boolean) => Promise<import("../structures").GuildEmoji>;
|
|
105
|
-
delete: (guildId: string, emojiId: string, reason?: string | undefined) => Promise<void>;
|
|
106
|
-
edit: (guildId: string, emojiId: string, body: import("discord-api-types/rest/v10/emoji").RESTPatchAPIGuildEmojiJSONBody, reason?: string | undefined) => Promise<import("../structures").GuildEmoji>;
|
|
107
|
-
};
|
|
108
|
-
};
|
|
109
|
-
messages: {
|
|
110
|
-
write: (channelId: string, { files, ...body }: Omit<import("discord-api-types/rest/v10/channel").RESTPostAPIChannelMessageJSONBody, "components" | "embeds"> & import("../common").ResolverProps) => Promise<import("../structures").Message>;
|
|
111
|
-
edit: (messageId: string, channelId: string, { files, ...body }: Omit<import("discord-api-types/rest/v10/channel").RESTPatchAPIChannelMessageJSONBody, "components" | "embeds"> & import("../common").ResolverProps) => Promise<import("../structures").Message>;
|
|
112
|
-
crosspost: (messageId: string, channelId: string, reason?: string | undefined) => Promise<import("../structures").Message>;
|
|
113
|
-
delete: (messageId: string, channelId: string, reason?: string | undefined) => Promise<void>;
|
|
114
|
-
fetch: (messageId: string, channelId: string) => Promise<import("../structures").Message>;
|
|
115
|
-
purge: (messages: string[], channelId: string, reason?: string | undefined) => Promise<never>;
|
|
116
|
-
reactions: {
|
|
117
|
-
add: (messageId: string, channelId: string, emoji: import("../common").EmojiResolvable) => Promise<never>;
|
|
118
|
-
delete: (messageId: string, channelId: string, emoji: import("../common").EmojiResolvable, userId?: string) => Promise<never>;
|
|
119
|
-
fetch: (messageId: string, channelId: string, emoji: import("../common").EmojiResolvable, query?: import("discord-api-types/rest/v10/channel").RESTGetAPIChannelMessageReactionUsersQuery | undefined) => Promise<import("../structures").User[]>;
|
|
120
|
-
purge: (messageId: string, channelId: string, emoji?: import("../common").EmojiResolvable | undefined) => Promise<never>;
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
|
-
members: {
|
|
124
|
-
resolve: (guildId: string, resolve: import("../common").GuildMemberResolvable) => Promise<import("../structures").GuildMember | undefined>;
|
|
125
|
-
search: (guildId: string, query?: import("discord-api-types/rest/v10/guild").RESTGetAPIGuildMembersSearchQuery | undefined) => Promise<import("../structures").GuildMember[]>;
|
|
126
|
-
unban: (guildId: string, memberId: string, body?: import("discord-api-types/rest/v10/guild").RESTPutAPIGuildBanJSONBody | undefined, reason?: string | undefined) => Promise<void>;
|
|
127
|
-
ban: (guildId: string, memberId: string, body?: import("discord-api-types/rest/v10/guild").RESTPutAPIGuildBanJSONBody | undefined, reason?: string | undefined) => Promise<void>;
|
|
128
|
-
kick: (guildId: string, memberId: string, reason?: string | undefined) => Promise<void>;
|
|
129
|
-
edit: (guildId: string, memberId: string, body: import("discord-api-types/rest/v10/guild").RESTPatchAPIGuildMemberJSONBody, reason?: string | undefined) => Promise<import("../structures").GuildMember>;
|
|
130
|
-
add: (guildId: string, memberId: string, body: import("discord-api-types/rest/v10/guild").RESTPutAPIGuildMemberJSONBody) => Promise<import("../structures").GuildMember | undefined>;
|
|
131
|
-
fetch: (guildId: string, memberId: string, force?: boolean) => Promise<import("../structures").GuildMember>;
|
|
132
|
-
list: (guildId: string, query?: import("discord-api-types/rest/v10/guild").RESTGetAPIGuildMembersQuery | undefined, force?: boolean) => Promise<import("../structures").GuildMember[]>;
|
|
133
|
-
roles: {
|
|
134
|
-
add: (guildId: string, memberId: string, id: string) => Promise<void>;
|
|
135
|
-
remove: (guildId: string, memberId: string, id: string) => Promise<void>;
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
webhooks: {
|
|
139
|
-
delete: (webhookId: string, { token, reason }: Partial<{
|
|
140
|
-
token: string;
|
|
141
|
-
reason: string;
|
|
142
|
-
}>) => Promise<never>;
|
|
143
|
-
edit: (webhookId: string, body: import("discord-api-types/rest/v10/webhook").RESTPatchAPIWebhookJSONBody | import("discord-api-types/rest/v10/webhook").RESTPatchAPIWebhookWithTokenJSONBody, { token, reason }: Partial<{
|
|
144
|
-
token: string;
|
|
145
|
-
reason: string;
|
|
146
|
-
}>) => Promise<import("discord-api-types/rest/v10/webhook").RESTGetAPIWebhookWithTokenResult>;
|
|
147
|
-
fetch: (webhookId: string, token?: string | undefined) => Promise<import("../structures").Webhook>;
|
|
148
|
-
messages: {
|
|
149
|
-
write: (webhookId: string, token: string, { body: data, ...payload }: {
|
|
150
|
-
body: Omit<import("discord-api-types/rest/v10/webhook").RESTPostAPIWebhookWithTokenJSONBody, "components" | "embeds"> & import("../common").ResolverProps;
|
|
151
|
-
query?: import("discord-api-types/rest/v10/webhook").RESTPostAPIWebhookWithTokenQuery | undefined;
|
|
152
|
-
}) => Promise<import("../structures").WebhookMessage | null>;
|
|
153
|
-
edit: (webhookId: string, token: string, { messageId, body: data, ...json }: {
|
|
154
|
-
body: Omit<import("discord-api-types/rest/v10/webhook").RESTPatchAPIWebhookWithTokenMessageJSONBody, "components" | "embeds"> & import("../common").ResolverProps;
|
|
155
|
-
messageId: string;
|
|
156
|
-
query?: import("discord-api-types/rest/v10/webhook").RESTGetAPIWebhookWithTokenMessageQuery | undefined;
|
|
157
|
-
}) => Promise<import("../structures").WebhookMessage>;
|
|
158
|
-
delete: (webhookId: string, token: string, messageId: string, reason?: string | undefined) => Promise<never>;
|
|
159
|
-
fetch: (webhookId: string, token: string, messageId: string, threadId?: string | undefined) => Promise<import("../structures").WebhookMessage | undefined>;
|
|
160
|
-
};
|
|
161
|
-
};
|
|
162
|
-
templates: {
|
|
163
|
-
fetch: (code: string) => Promise<import("discord-api-types/payloads/v10/template").APITemplate>;
|
|
164
|
-
list: (guildId: string) => Promise<import("discord-api-types/rest/v10/template").RESTGetAPIGuildTemplatesResult>;
|
|
165
|
-
create: (guildId: string, body: import("discord-api-types/rest/v10/template").RESTPostAPIGuildTemplatesJSONBody) => Promise<import("discord-api-types/payloads/v10/template").APITemplate>;
|
|
166
|
-
sync: (guildId: string, code: string) => Promise<import("discord-api-types/payloads/v10/template").APITemplate>;
|
|
167
|
-
edit: (guildId: string, code: string, body: import("discord-api-types/utils/internals").AddUndefinedToPossiblyUndefinedPropertiesOfInterface<Partial<import("discord-api-types/rest/v10/template").RESTPostAPIGuildTemplatesJSONBody>>) => Promise<import("discord-api-types/payloads/v10/template").APITemplate>;
|
|
168
|
-
delete: (guildId: string, code: string) => Promise<import("discord-api-types/payloads/v10/template").APITemplate>;
|
|
169
|
-
};
|
|
170
|
-
roles: {
|
|
171
|
-
create: (guildId: string, body: import("discord-api-types/rest/v10/guild").RESTPostAPIGuildRoleJSONBody, reason?: string | undefined) => Promise<any>;
|
|
172
|
-
list: (guildId: string, force?: boolean) => Promise<import("../structures").GuildRole[]>;
|
|
173
|
-
edit: (guildId: string, roleId: string, body: import("discord-api-types/rest/v10/guild").RESTPatchAPIGuildRoleJSONBody, reason?: string | undefined) => Promise<any>;
|
|
174
|
-
delete: (guildId: string, roleId: string, reason?: string | undefined) => Promise<void | undefined>;
|
|
175
|
-
editPositions: (guildId: string, body: import("discord-api-types/rest/v10/guild").RESTPatchAPIGuildRolePositionsJSONBody) => Promise<import("../structures").GuildRole[]>;
|
|
176
|
-
};
|
|
16
|
+
users: UsersShorter;
|
|
17
|
+
channels: ChannelShorter;
|
|
18
|
+
guilds: GuildShorter;
|
|
19
|
+
messages: MessageShorter;
|
|
20
|
+
members: MemberShorter;
|
|
21
|
+
webhooks: WebhookShorter;
|
|
22
|
+
templates: TemplateShorter;
|
|
23
|
+
roles: RoleShorter;
|
|
24
|
+
reactions: ReactionShorter;
|
|
25
|
+
emojis: EmojiShorter;
|
|
177
26
|
debugger?: Logger;
|
|
178
27
|
logger: Logger;
|
|
179
|
-
langs
|
|
180
|
-
commands
|
|
181
|
-
components
|
|
28
|
+
langs?: LangsHandlerLike;
|
|
29
|
+
commands?: CommandHandlerLike;
|
|
30
|
+
components?: ComponentHandlerLike;
|
|
182
31
|
private _applicationId?;
|
|
183
32
|
private _botId?;
|
|
184
33
|
middlewares?: Record<string, MiddlewareContext>;
|
|
@@ -191,7 +40,7 @@ export declare class BaseClient {
|
|
|
191
40
|
set applicationId(id: string);
|
|
192
41
|
get applicationId(): string;
|
|
193
42
|
get proxy(): import("../api").APIRoutes;
|
|
194
|
-
setServices({ rest, cache, langs, middlewares }: ServicesOptions): void;
|
|
43
|
+
setServices({ rest, cache, langs, middlewares, handlers }: ServicesOptions): void;
|
|
195
44
|
protected execute(..._options: unknown[]): Promise<void>;
|
|
196
45
|
start(options?: Pick<DeepPartial<StartOptions>, 'langsDir' | 'commandsDir' | 'connection' | 'token' | 'componentsDir'>): Promise<void>;
|
|
197
46
|
protected onPacket(..._packet: unknown[]): Promise<void>;
|
|
@@ -215,7 +64,7 @@ export declare class BaseClient {
|
|
|
215
64
|
}>;
|
|
216
65
|
}
|
|
217
66
|
export interface BaseClientOptions {
|
|
218
|
-
context?: (interaction: ChatInputCommandInteraction<boolean> | UserCommandInteraction<boolean> | MessageCommandInteraction<boolean>) => {};
|
|
67
|
+
context?: (interaction: ChatInputCommandInteraction<boolean> | UserCommandInteraction<boolean> | MessageCommandInteraction<boolean> | When<InferWithPrefix, Message, never>) => {};
|
|
219
68
|
globalMiddlewares?: readonly (keyof RegisteredMiddlewares)[];
|
|
220
69
|
}
|
|
221
70
|
export interface StartOptions {
|
|
@@ -259,12 +108,12 @@ export type RuntimeConfigHTTP = Omit<MakeRequired<RC, 'publicKey' | 'application
|
|
|
259
108
|
};
|
|
260
109
|
export type InternalRuntimeConfig = Omit<MakeRequired<RC, 'intents'>, 'publicKey' | 'port'>;
|
|
261
110
|
export type RuntimeConfig = OmitInsert<InternalRuntimeConfig, 'intents', {
|
|
262
|
-
intents?: IntentStrings | number;
|
|
111
|
+
intents?: IntentStrings | number[] | number;
|
|
263
112
|
}>;
|
|
264
|
-
export
|
|
113
|
+
export interface ServicesOptions {
|
|
265
114
|
rest?: ApiHandler;
|
|
266
115
|
cache?: {
|
|
267
|
-
adapter
|
|
116
|
+
adapter?: Adapter;
|
|
268
117
|
disabledCache?: Cache['disabledCache'];
|
|
269
118
|
};
|
|
270
119
|
langs?: {
|
|
@@ -272,5 +121,10 @@ export type ServicesOptions = {
|
|
|
272
121
|
aliases?: Record<string, LocaleString[]>;
|
|
273
122
|
};
|
|
274
123
|
middlewares?: Record<string, MiddlewareContext>;
|
|
275
|
-
|
|
124
|
+
handlers?: {
|
|
125
|
+
components?: ComponentHandlerLike | ((component: ComponentCommand | ModalCommand) => any);
|
|
126
|
+
commands?: CommandHandlerLike | ((command: Command | ContextMenuCommand) => any);
|
|
127
|
+
langs?: LangsHandlerLike | ((locale: string, record: Record<string, unknown>) => any);
|
|
128
|
+
};
|
|
129
|
+
}
|
|
276
130
|
export {};
|
package/lib/client/base.js
CHANGED
|
@@ -6,24 +6,21 @@ const api_1 = require("../api");
|
|
|
6
6
|
const cache_1 = require("../cache");
|
|
7
7
|
const handler_1 = require("../commands/handler");
|
|
8
8
|
const common_1 = require("../common");
|
|
9
|
-
const members_1 = require("../common/shorters/members");
|
|
10
|
-
const messages_1 = require("../common/shorters/messages");
|
|
11
|
-
const roles_1 = require("../common/shorters/roles");
|
|
12
|
-
const templates_1 = require("../common/shorters/templates");
|
|
13
|
-
const webhook_1 = require("../common/shorters/webhook");
|
|
14
9
|
const handler_2 = require("../components/handler");
|
|
15
10
|
const handler_3 = require("../langs/handler");
|
|
16
11
|
class BaseClient {
|
|
17
12
|
rest;
|
|
18
13
|
cache;
|
|
19
|
-
users = new common_1.UsersShorter(this)
|
|
20
|
-
channels = new common_1.ChannelShorter(this)
|
|
21
|
-
guilds = new common_1.GuildShorter(this)
|
|
22
|
-
messages = new
|
|
23
|
-
members = new
|
|
24
|
-
webhooks = new
|
|
25
|
-
templates = new
|
|
26
|
-
roles = new
|
|
14
|
+
users = new common_1.UsersShorter(this);
|
|
15
|
+
channels = new common_1.ChannelShorter(this);
|
|
16
|
+
guilds = new common_1.GuildShorter(this);
|
|
17
|
+
messages = new common_1.MessageShorter(this);
|
|
18
|
+
members = new common_1.MemberShorter(this);
|
|
19
|
+
webhooks = new common_1.WebhookShorter(this);
|
|
20
|
+
templates = new common_1.TemplateShorter(this);
|
|
21
|
+
roles = new common_1.RoleShorter(this);
|
|
22
|
+
reactions = new common_1.ReactionShorter(this);
|
|
23
|
+
emojis = new common_1.EmojiShorter(this);
|
|
27
24
|
debugger;
|
|
28
25
|
logger = new common_1.Logger({
|
|
29
26
|
name: '[Seyfert]',
|
|
@@ -61,12 +58,53 @@ class BaseClient {
|
|
|
61
58
|
get proxy() {
|
|
62
59
|
return new api_1.Router(this.rest).createProxy();
|
|
63
60
|
}
|
|
64
|
-
setServices({ rest, cache, langs, middlewares }) {
|
|
61
|
+
setServices({ rest, cache, langs, middlewares, handlers }) {
|
|
65
62
|
if (rest) {
|
|
66
63
|
this.rest = rest;
|
|
67
64
|
}
|
|
68
65
|
if (cache) {
|
|
69
|
-
this.cache = new cache_1.Cache(this.cache?.intents ?? 0, cache.adapter, cache.disabledCache ?? this.cache?.disabledCache, this);
|
|
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
|
+
}
|
|
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
|
+
}
|
|
70
108
|
}
|
|
71
109
|
if (langs) {
|
|
72
110
|
if (langs.default)
|
|
@@ -74,9 +112,6 @@ class BaseClient {
|
|
|
74
112
|
if (langs.aliases)
|
|
75
113
|
this.langs.aliases = Object.entries(langs.aliases);
|
|
76
114
|
}
|
|
77
|
-
if (middlewares) {
|
|
78
|
-
this.middlewares = middlewares;
|
|
79
|
-
}
|
|
80
115
|
}
|
|
81
116
|
async execute(..._options) {
|
|
82
117
|
if ((await this.getRC()).debug) {
|
|
@@ -142,21 +177,21 @@ class BaseClient {
|
|
|
142
177
|
}
|
|
143
178
|
async loadCommands(dir) {
|
|
144
179
|
dir ??= await this.getRC().then(x => x.commands);
|
|
145
|
-
if (dir) {
|
|
180
|
+
if (dir && this.commands) {
|
|
146
181
|
await this.commands.load(dir, this);
|
|
147
182
|
this.logger.info('CommandHandler loaded');
|
|
148
183
|
}
|
|
149
184
|
}
|
|
150
185
|
async loadComponents(dir) {
|
|
151
186
|
dir ??= await this.getRC().then(x => x.components);
|
|
152
|
-
if (dir) {
|
|
187
|
+
if (dir && this.components) {
|
|
153
188
|
await this.components.load(dir);
|
|
154
189
|
this.logger.info('ComponentHandler loaded');
|
|
155
190
|
}
|
|
156
191
|
}
|
|
157
192
|
async loadLangs(dir) {
|
|
158
193
|
dir ??= await this.getRC().then(x => x.langs);
|
|
159
|
-
if (dir) {
|
|
194
|
+
if (dir && this.langs) {
|
|
160
195
|
await this.langs.load(dir);
|
|
161
196
|
this.logger.info('LangsHandler loaded');
|
|
162
197
|
}
|
package/lib/client/client.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { Command, CommandContext, Message, SubCommand } from '..';
|
|
1
|
+
import type { ClientEvent, Command, CommandContext, EventHandlerLike, Message, SubCommand } from '..';
|
|
2
2
|
import { type DeepPartial, type GatewayDispatchPayload, type GatewayPresenceUpdateData, type If } from '../common';
|
|
3
|
-
import { EventHandler } from '../events';
|
|
4
3
|
import { ClientUser } from '../structures';
|
|
5
4
|
import { ShardManager, type ShardManagerOptions } from '../websocket';
|
|
6
5
|
import { MemberUpdateHandler } from '../websocket/discord/events/memberUpdate';
|
|
@@ -10,7 +9,7 @@ import { BaseClient } from './base';
|
|
|
10
9
|
export declare class Client<Ready extends boolean = boolean> extends BaseClient {
|
|
11
10
|
private __handleGuilds?;
|
|
12
11
|
gateway: ShardManager;
|
|
13
|
-
events
|
|
12
|
+
events?: EventHandlerLike;
|
|
14
13
|
me: If<Ready, ClientUser>;
|
|
15
14
|
options: ClientOptions | undefined;
|
|
16
15
|
memberUpdateHandler: MemberUpdateHandler;
|
|
@@ -18,6 +17,9 @@ export declare class Client<Ready extends boolean = boolean> extends BaseClient
|
|
|
18
17
|
constructor(options?: ClientOptions);
|
|
19
18
|
setServices({ gateway, ...rest }: ServicesOptions & {
|
|
20
19
|
gateway?: ShardManager;
|
|
20
|
+
handlers?: ServicesOptions['handlers'] & {
|
|
21
|
+
events?: EventHandlerLike | ((event: ClientEvent) => any);
|
|
22
|
+
};
|
|
21
23
|
}): void;
|
|
22
24
|
loadEvents(dir?: string): Promise<void>;
|
|
23
25
|
protected execute(options?: {
|
|
@@ -32,6 +34,11 @@ export interface ClientOptions extends BaseClientOptions {
|
|
|
32
34
|
shards?: {
|
|
33
35
|
start: number;
|
|
34
36
|
end: number;
|
|
37
|
+
total?: number;
|
|
38
|
+
};
|
|
39
|
+
gateway?: {
|
|
40
|
+
properties?: Partial<ShardManagerOptions['properties']>;
|
|
41
|
+
compress?: ShardManagerOptions['compress'];
|
|
35
42
|
};
|
|
36
43
|
commands?: {
|
|
37
44
|
prefix: (message: Message) => Promise<string[]> | string[];
|
package/lib/client/client.js
CHANGED
|
@@ -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
|
}
|
|
@@ -77,7 +89,10 @@ class Client extends base_1.BaseClient {
|
|
|
77
89
|
presence: this.options?.presence,
|
|
78
90
|
debug: debugRC,
|
|
79
91
|
shardStart: this.options?.shards?.start,
|
|
80
|
-
shardEnd: this.options?.shards?.end,
|
|
92
|
+
shardEnd: this.options?.shards?.end ?? this.options?.shards?.total,
|
|
93
|
+
totalShards: this.options?.shards?.total ?? this.options?.shards?.end,
|
|
94
|
+
properties: { ...this.options?.gateway?.properties, ...websocket_1.properties },
|
|
95
|
+
compress: this.options?.gateway?.compress,
|
|
81
96
|
});
|
|
82
97
|
}
|
|
83
98
|
this.cache.intents = this.gateway.options.intents;
|
|
@@ -89,21 +104,21 @@ class Client extends base_1.BaseClient {
|
|
|
89
104
|
}
|
|
90
105
|
}
|
|
91
106
|
async onPacket(shardId, packet) {
|
|
92
|
-
await this.events
|
|
107
|
+
await this.events?.runEvent('RAW', this, packet, shardId);
|
|
93
108
|
switch (packet.t) {
|
|
94
109
|
//// Cases where we must obtain the old data before updating
|
|
95
110
|
case 'GUILD_MEMBER_UPDATE':
|
|
96
111
|
if (!this.memberUpdateHandler.check(packet.d)) {
|
|
97
112
|
return;
|
|
98
113
|
}
|
|
99
|
-
await this.events
|
|
114
|
+
await this.events?.execute(packet.t, packet, this, shardId);
|
|
100
115
|
await this.cache.onPacket(packet);
|
|
101
116
|
break;
|
|
102
117
|
case 'PRESENCE_UPDATE':
|
|
103
118
|
if (!this.presenceUpdateHandler.check(packet.d)) {
|
|
104
119
|
return;
|
|
105
120
|
}
|
|
106
|
-
await this.events
|
|
121
|
+
await this.events?.execute(packet.t, packet, this, shardId);
|
|
107
122
|
await this.cache.onPacket(packet);
|
|
108
123
|
break;
|
|
109
124
|
//rest of the events
|
|
@@ -126,7 +141,7 @@ class Client extends base_1.BaseClient {
|
|
|
126
141
|
if (!this.__handleGuilds?.size ||
|
|
127
142
|
!((this.gateway.options.intents & common_1.GatewayIntentBits.Guilds) === common_1.GatewayIntentBits.Guilds)) {
|
|
128
143
|
if ([...this.gateway.values()].every(shard => shard.data.session_id)) {
|
|
129
|
-
await this.events
|
|
144
|
+
await this.events?.runEvent('BOT_READY', this, this.me, -1);
|
|
130
145
|
}
|
|
131
146
|
delete this.__handleGuilds;
|
|
132
147
|
}
|
|
@@ -136,7 +151,7 @@ class Client extends base_1.BaseClient {
|
|
|
136
151
|
if (this.__handleGuilds?.has(packet.d.id)) {
|
|
137
152
|
this.__handleGuilds.delete(packet.d.id);
|
|
138
153
|
if (!this.__handleGuilds.size && [...this.gateway.values()].every(shard => shard.data.session_id)) {
|
|
139
|
-
await this.events
|
|
154
|
+
await this.events?.runEvent('BOT_READY', this, this.me, -1);
|
|
140
155
|
}
|
|
141
156
|
if (!this.__handleGuilds.size)
|
|
142
157
|
delete this.__handleGuilds;
|
|
@@ -145,7 +160,7 @@ class Client extends base_1.BaseClient {
|
|
|
145
160
|
break;
|
|
146
161
|
}
|
|
147
162
|
}
|
|
148
|
-
await this.events
|
|
163
|
+
await this.events?.execute(packet.t, packet, this, shardId);
|
|
149
164
|
break;
|
|
150
165
|
}
|
|
151
166
|
}
|
|
@@ -9,7 +9,7 @@ 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
|
|
12
|
+
const parentCommand = self.commands?.values.find(x => {
|
|
13
13
|
if (x.guild_id && !x.guild_id.includes(body.data.guild_id ?? '')) {
|
|
14
14
|
return false;
|
|
15
15
|
}
|
|
@@ -47,7 +47,7 @@ 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
|
|
50
|
+
const command = self.commands?.values.find(x => {
|
|
51
51
|
if (x.guild_id && !x.guild_id.includes(body.data.guild_id ?? '')) {
|
|
52
52
|
return false;
|
|
53
53
|
}
|
|
@@ -57,7 +57,7 @@ async function onInteractionCreate(self, body, shardId, __reply) {
|
|
|
57
57
|
// idc, is a YOU problem
|
|
58
58
|
if (!command?.run)
|
|
59
59
|
return self.logger.warn(`${command.name ?? 'Unknown'} command does not have 'run' callback`);
|
|
60
|
-
const context = new commands_1.MenuCommandContext(self, interaction, shardId);
|
|
60
|
+
const context = new commands_1.MenuCommandContext(self, interaction, shardId, command);
|
|
61
61
|
const extendContext = self.options?.context?.(interaction) ?? {};
|
|
62
62
|
Object.assign(context, extendContext);
|
|
63
63
|
try {
|
|
@@ -103,7 +103,7 @@ async function onInteractionCreate(self, body, shardId, __reply) {
|
|
|
103
103
|
case v10_1.ApplicationCommandType.ChatInput:
|
|
104
104
|
{
|
|
105
105
|
const packetData = body.data;
|
|
106
|
-
const parentCommand = self.commands
|
|
106
|
+
const parentCommand = self.commands?.values.find(x => {
|
|
107
107
|
if (x.guild_id && !x.guild_id.includes(packetData.guild_id ?? '')) {
|
|
108
108
|
return false;
|
|
109
109
|
}
|
|
@@ -114,7 +114,7 @@ async function onInteractionCreate(self, body, shardId, __reply) {
|
|
|
114
114
|
const command = optionsResolver.getCommand();
|
|
115
115
|
if (!command?.run)
|
|
116
116
|
return self.logger.warn(`${optionsResolver.fullCommandName} command does not have 'run' callback`);
|
|
117
|
-
const context = new commands_1.CommandContext(self, interaction, optionsResolver, shardId);
|
|
117
|
+
const context = new commands_1.CommandContext(self, interaction, optionsResolver, shardId, command);
|
|
118
118
|
const extendContext = self.options?.context?.(interaction) ?? {};
|
|
119
119
|
Object.assign(context, extendContext);
|
|
120
120
|
try {
|
|
@@ -167,22 +167,22 @@ async function onInteractionCreate(self, body, shardId, __reply) {
|
|
|
167
167
|
case v10_1.InteractionType.ModalSubmit:
|
|
168
168
|
{
|
|
169
169
|
const interaction = structures_1.BaseInteraction.from(self, body, __reply);
|
|
170
|
-
if (self.components
|
|
170
|
+
if (self.components?.hasModal(interaction)) {
|
|
171
171
|
await self.components.onModalSubmit(interaction);
|
|
172
172
|
}
|
|
173
173
|
else {
|
|
174
|
-
await self.components
|
|
174
|
+
await self.components?.executeModal(interaction);
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
break;
|
|
178
178
|
case v10_1.InteractionType.MessageComponent:
|
|
179
179
|
{
|
|
180
180
|
const interaction = structures_1.BaseInteraction.from(self, body, __reply);
|
|
181
|
-
if (self.components
|
|
181
|
+
if (self.components?.hasComponent(body.message.id, interaction.customId)) {
|
|
182
182
|
await self.components.onComponent(body.message.id, interaction);
|
|
183
183
|
}
|
|
184
184
|
else {
|
|
185
|
-
await self.components
|
|
185
|
+
await self.components?.executeComponent(interaction);
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
break;
|