seyfert 1.4.0 → 1.5.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/README.md +7 -7
- package/lib/api/Router.js +3 -1
- package/lib/api/Routes/guilds.d.ts +4 -1
- package/lib/cache/index.d.ts +6 -2
- package/lib/cache/index.js +18 -0
- package/lib/cache/resources/bans.d.ts +12 -0
- package/lib/cache/resources/bans.js +35 -0
- package/lib/cache/resources/members.js +4 -4
- package/lib/cache/resources/messages.js +8 -6
- package/lib/client/base.d.ts +7 -3
- package/lib/client/base.js +43 -24
- package/lib/client/client.d.ts +17 -5
- package/lib/client/client.js +39 -43
- package/lib/client/collectors.d.ts +36 -0
- package/lib/client/collectors.js +85 -0
- package/lib/client/httpclient.js +6 -6
- package/lib/client/onmessagecreate.d.ts +12 -2
- package/lib/client/onmessagecreate.js +32 -17
- package/lib/client/workerclient.d.ts +4 -1
- package/lib/client/workerclient.js +59 -67
- package/lib/collection.d.ts +2 -2
- package/lib/collection.js +2 -2
- package/lib/commands/applications/chat.d.ts +10 -9
- package/lib/commands/applications/chat.js +21 -7
- package/lib/commands/applications/menu.d.ts +8 -7
- package/lib/commands/applications/menu.js +3 -2
- package/lib/commands/applications/shared.d.ts +12 -0
- package/lib/commands/decorators.d.ts +11 -17
- package/lib/commands/decorators.js +7 -14
- package/lib/commands/handler.js +39 -29
- package/lib/common/index.d.ts +1 -0
- package/lib/common/index.js +3 -1
- package/lib/common/it/formatter.d.ts +155 -0
- package/lib/common/it/formatter.js +184 -0
- package/lib/common/it/logger.js +5 -5
- package/lib/common/it/utils.js +2 -4
- package/lib/common/shorters/bans.d.ts +43 -0
- package/lib/common/shorters/bans.js +78 -0
- package/lib/common/shorters/emojis.d.ts +1 -1
- package/lib/common/shorters/emojis.js +4 -3
- package/lib/common/shorters/interaction.js +9 -7
- package/lib/common/shorters/messages.js +2 -2
- package/lib/common/shorters/webhook.js +2 -2
- package/lib/components/componentcommand.d.ts +3 -2
- package/lib/components/componentcommand.js +2 -1
- package/lib/components/componentcontext.d.ts +1 -1
- package/lib/components/handler.d.ts +1 -1
- package/lib/components/handler.js +25 -28
- package/lib/components/modalcommand.d.ts +2 -1
- package/lib/components/modalcommand.js +1 -0
- package/lib/components/modalcontext.d.ts +1 -1
- package/lib/events/event.d.ts +4 -3
- package/lib/events/handler.d.ts +8 -5
- package/lib/events/handler.js +58 -13
- package/lib/events/hooks/guild.d.ts +18 -73
- package/lib/events/hooks/integration.d.ts +57 -0
- package/lib/events/hooks/invite.d.ts +3 -0
- package/lib/events/hooks/message.d.ts +11 -6
- package/lib/events/hooks/presence.d.ts +4 -0
- package/lib/events/hooks/thread.d.ts +14 -3
- package/lib/events/hooks/typing.d.ts +1 -0
- package/lib/index.d.ts +3 -3
- package/lib/index.js +3 -2
- package/lib/structures/Guild.d.ts +9 -1
- package/lib/structures/Guild.js +2 -0
- package/lib/structures/GuildBan.d.ts +25 -0
- package/lib/structures/GuildBan.js +36 -0
- package/lib/structures/GuildEmoji.d.ts +1 -1
- package/lib/structures/GuildMember.d.ts +7 -2
- package/lib/structures/GuildMember.js +4 -4
- package/lib/structures/Interaction.d.ts +3 -2
- package/lib/structures/Interaction.js +21 -9
- package/lib/structures/Message.d.ts +69 -8
- package/lib/structures/Message.js +59 -17
- package/lib/structures/Sticker.d.ts +3 -3
- package/lib/structures/User.d.ts +1 -0
- package/lib/structures/User.js +4 -1
- package/lib/structures/channels.d.ts +4 -1
- package/lib/structures/channels.js +36 -6
- package/lib/structures/extra/functions.js +1 -1
- package/lib/websocket/discord/basesocket.d.ts +1 -0
- package/lib/websocket/discord/basesocket.js +17 -0
- package/lib/websocket/discord/shard.d.ts +1 -0
- package/lib/websocket/discord/shard.js +6 -0
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
|
|
15
15
|
# FAQ
|
|
16
16
|
## So, what is `seyfert`?
|
|
17
|
-
Seyfert is the ultimate Discord framework! We make easy to interact with the Discord API, big cache control, scalable code and a pretty dev experience.
|
|
17
|
+
Seyfert is the ultimate Discord framework! We make it easy to interact with the Discord API, big cache control, scalable code and a pretty dev experience.
|
|
18
18
|
|
|
19
|
-
## Why I
|
|
20
|
-
There are many reasons to use Seyfert, but
|
|
19
|
+
## Why should I use it?
|
|
20
|
+
There are many reasons to use Seyfert, but they dont all fit in this tiny readme, so here is a list of the most awesome reasons!
|
|
21
21
|
|
|
22
|
-
- **RAM
|
|
22
|
+
- **Low RAM Usage**
|
|
23
23
|
- **Latest features**
|
|
24
24
|
- **Dev experience**
|
|
25
|
-
- **24/6 support (Sunday is for
|
|
25
|
+
- **24/6 support (Sunday is for church)**
|
|
26
26
|
- **Written from Scratch**
|
|
27
27
|
- **Type-safe**
|
|
28
28
|
- **And many more!!**
|
|
@@ -30,12 +30,12 @@ There are many reasons to use Seyfert, but we cannot put them all in here so the
|
|
|
30
30
|
|
|
31
31
|
## Installation
|
|
32
32
|
> [!NOTE]
|
|
33
|
-
> You **NEED** Node.js 18>= for this to work,
|
|
33
|
+
> You **NEED** Node.js 18>= for this to work, Node.js 20 LTS and Bun latest are recommended
|
|
34
34
|
```sh
|
|
35
35
|
pnpm add seyfert
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
> You may use your preferred package manager, for this example
|
|
38
|
+
> You may use your preferred package manager, for this example PNMP is being used since it’s more efficient.
|
|
39
39
|
|
|
40
40
|
# Useful links
|
|
41
41
|
|
package/lib/api/Router.js
CHANGED
|
@@ -45,7 +45,7 @@ exports.CDNRouter = {
|
|
|
45
45
|
return (value, options) => {
|
|
46
46
|
const lastRoute = `${common_1.CDN_URL}/${route.join('/')}`;
|
|
47
47
|
let routeResult = lastRoute;
|
|
48
|
-
if (typeof value === 'string') {
|
|
48
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
49
49
|
routeResult = `${lastRoute}${value ? `/${value}` : ''}`;
|
|
50
50
|
return parseCDNURL(routeResult, options);
|
|
51
51
|
}
|
|
@@ -63,6 +63,8 @@ exports.CDNRouter = {
|
|
|
63
63
|
function parseCDNURL(route, options = {}) {
|
|
64
64
|
if (options.forceStatic && route.includes('a_'))
|
|
65
65
|
options.extension = 'png';
|
|
66
|
+
if (!options.extension && route.includes('a_'))
|
|
67
|
+
options.extension = 'gif';
|
|
66
68
|
const url = new URL(`${route}.${options.extension || 'png'}`);
|
|
67
69
|
if (options.size)
|
|
68
70
|
url.searchParams.set('size', `${options.size}`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { APIThreadChannel, RESTDeleteAPIAutoModerationRuleResult, RESTDeleteAPIGuildBanResult, RESTDeleteAPIGuildEmojiResult, RESTDeleteAPIGuildIntegrationResult, RESTDeleteAPIGuildMemberResult, RESTDeleteAPIGuildMemberRoleResult, RESTDeleteAPIGuildResult, RESTDeleteAPIGuildRoleResult, RESTDeleteAPIGuildScheduledEventResult, RESTDeleteAPIGuildStickerResult, RESTDeleteAPIGuildTemplateResult, RESTGetAPIAuditLogQuery, RESTGetAPIAuditLogResult, RESTGetAPIAutoModerationRuleResult, RESTGetAPIAutoModerationRulesResult, RESTGetAPIGuildBanResult, RESTGetAPIGuildBansQuery, RESTGetAPIGuildBansResult, RESTGetAPIGuildChannelsResult, RESTGetAPIGuildEmojiResult, RESTGetAPIGuildEmojisResult, RESTGetAPIGuildIntegrationsResult, RESTGetAPIGuildInvitesResult, RESTGetAPIGuildMemberResult, RESTGetAPIGuildMembersQuery, RESTGetAPIGuildMembersResult, RESTGetAPIGuildMembersSearchQuery, RESTGetAPIGuildMembersSearchResult, RESTGetAPIGuildPreviewResult, RESTGetAPIGuildPruneCountQuery, RESTGetAPIGuildPruneCountResult, RESTGetAPIGuildQuery, RESTGetAPIGuildResult, RESTGetAPIGuildRolesResult, RESTGetAPIGuildScheduledEventQuery, RESTGetAPIGuildScheduledEventResult, RESTGetAPIGuildScheduledEventUsersQuery, RESTGetAPIGuildScheduledEventUsersResult, RESTGetAPIGuildScheduledEventsQuery, RESTGetAPIGuildScheduledEventsResult, RESTGetAPIGuildStickerResult, RESTGetAPIGuildStickersResult, RESTGetAPIGuildTemplatesResult, RESTGetAPIGuildThreadsResult, RESTGetAPIGuildVanityUrlResult, RESTGetAPIGuildVoiceRegionsResult, RESTGetAPIGuildWebhooksResult, RESTGetAPIGuildWelcomeScreenResult, RESTGetAPIGuildWidgetImageQuery, RESTGetAPIGuildWidgetImageResult, RESTGetAPIGuildWidgetJSONResult, RESTGetAPIGuildWidgetSettingsResult, RESTGetAPITemplateResult, RESTPatchAPIAutoModerationRuleJSONBody, RESTPatchAPIAutoModerationRuleResult, RESTPatchAPICurrentGuildMemberJSONBody, RESTPatchAPIGuildChannelPositionsJSONBody, RESTPatchAPIGuildChannelPositionsResult, RESTPatchAPIGuildEmojiJSONBody, RESTPatchAPIGuildEmojiResult, RESTPatchAPIGuildJSONBody, RESTPatchAPIGuildMemberJSONBody, RESTPatchAPIGuildMemberResult, RESTPatchAPIGuildResult, RESTPatchAPIGuildRoleJSONBody, RESTPatchAPIGuildRolePositionsJSONBody, RESTPatchAPIGuildRolePositionsResult, RESTPatchAPIGuildRoleResult, RESTPatchAPIGuildScheduledEventJSONBody, RESTPatchAPIGuildScheduledEventResult, RESTPatchAPIGuildStickerJSONBody, RESTPatchAPIGuildStickerResult, RESTPatchAPIGuildTemplateJSONBody, RESTPatchAPIGuildTemplateResult, RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody, RESTPatchAPIGuildVoiceStateCurrentMemberResult, RESTPatchAPIGuildVoiceStateUserJSONBody, RESTPatchAPIGuildVoiceStateUserResult, RESTPatchAPIGuildWelcomeScreenJSONBody, RESTPatchAPIGuildWelcomeScreenResult, RESTPatchAPIGuildWidgetSettingsJSONBody, RESTPatchAPIGuildWidgetSettingsResult, RESTPostAPIAutoModerationRuleJSONBody, RESTPostAPIAutoModerationRuleResult, RESTPostAPIGuildChannelJSONBody, RESTPostAPIGuildChannelResult, RESTPostAPIGuildEmojiJSONBody, RESTPostAPIGuildEmojiResult, RESTPostAPIGuildPruneJSONBody, RESTPostAPIGuildPruneResult, RESTPostAPIGuildRoleJSONBody, RESTPostAPIGuildRoleResult, RESTPostAPIGuildScheduledEventJSONBody, RESTPostAPIGuildScheduledEventResult, RESTPostAPIGuildStickerFormDataBody, RESTPostAPIGuildStickerResult, RESTPostAPIGuildTemplatesJSONBody, RESTPostAPIGuildTemplatesResult, RESTPostAPIGuildsJSONBody, RESTPostAPIGuildsMFAJSONBody, RESTPostAPIGuildsMFAResult, RESTPostAPIGuildsResult, RESTPostAPITemplateCreateGuildJSONBody, RESTPostAPITemplateCreateGuildResult, RESTPutAPIGuildBanJSONBody, RESTPutAPIGuildBanResult, RESTPutAPIGuildMemberJSONBody, RESTPutAPIGuildMemberResult, RESTPutAPIGuildMemberRoleResult, RESTPutAPIGuildTemplateSyncResult } from 'discord-api-types/v10';
|
|
1
|
+
import type { APIThreadChannel, RESTDeleteAPIAutoModerationRuleResult, RESTDeleteAPIGuildBanResult, RESTDeleteAPIGuildEmojiResult, RESTDeleteAPIGuildIntegrationResult, RESTDeleteAPIGuildMemberResult, RESTDeleteAPIGuildMemberRoleResult, RESTDeleteAPIGuildResult, RESTDeleteAPIGuildRoleResult, RESTDeleteAPIGuildScheduledEventResult, RESTDeleteAPIGuildStickerResult, RESTDeleteAPIGuildTemplateResult, RESTGetAPIAuditLogQuery, RESTGetAPIAuditLogResult, RESTGetAPIAutoModerationRuleResult, RESTGetAPIAutoModerationRulesResult, RESTGetAPIGuildBanResult, RESTGetAPIGuildBansQuery, RESTGetAPIGuildBansResult, RESTGetAPIGuildChannelsResult, RESTGetAPIGuildEmojiResult, RESTGetAPIGuildEmojisResult, RESTGetAPIGuildIntegrationsResult, RESTGetAPIGuildInvitesResult, RESTGetAPIGuildMemberResult, RESTGetAPIGuildMembersQuery, RESTGetAPIGuildMembersResult, RESTGetAPIGuildMembersSearchQuery, RESTGetAPIGuildMembersSearchResult, RESTGetAPIGuildPreviewResult, RESTGetAPIGuildPruneCountQuery, RESTGetAPIGuildPruneCountResult, RESTGetAPIGuildQuery, RESTGetAPIGuildResult, RESTGetAPIGuildRolesResult, RESTGetAPIGuildScheduledEventQuery, RESTGetAPIGuildScheduledEventResult, RESTGetAPIGuildScheduledEventUsersQuery, RESTGetAPIGuildScheduledEventUsersResult, RESTGetAPIGuildScheduledEventsQuery, RESTGetAPIGuildScheduledEventsResult, RESTGetAPIGuildStickerResult, RESTGetAPIGuildStickersResult, RESTGetAPIGuildTemplatesResult, RESTGetAPIGuildThreadsResult, RESTGetAPIGuildVanityUrlResult, RESTGetAPIGuildVoiceRegionsResult, RESTGetAPIGuildWebhooksResult, RESTGetAPIGuildWelcomeScreenResult, RESTGetAPIGuildWidgetImageQuery, RESTGetAPIGuildWidgetImageResult, RESTGetAPIGuildWidgetJSONResult, RESTGetAPIGuildWidgetSettingsResult, RESTGetAPITemplateResult, RESTPatchAPIAutoModerationRuleJSONBody, RESTPatchAPIAutoModerationRuleResult, RESTPatchAPICurrentGuildMemberJSONBody, RESTPatchAPIGuildChannelPositionsJSONBody, RESTPatchAPIGuildChannelPositionsResult, RESTPatchAPIGuildEmojiJSONBody, RESTPatchAPIGuildEmojiResult, RESTPatchAPIGuildJSONBody, RESTPatchAPIGuildMemberJSONBody, RESTPatchAPIGuildMemberResult, RESTPatchAPIGuildResult, RESTPatchAPIGuildRoleJSONBody, RESTPatchAPIGuildRolePositionsJSONBody, RESTPatchAPIGuildRolePositionsResult, RESTPatchAPIGuildRoleResult, RESTPatchAPIGuildScheduledEventJSONBody, RESTPatchAPIGuildScheduledEventResult, RESTPatchAPIGuildStickerJSONBody, RESTPatchAPIGuildStickerResult, RESTPatchAPIGuildTemplateJSONBody, RESTPatchAPIGuildTemplateResult, RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody, RESTPatchAPIGuildVoiceStateCurrentMemberResult, RESTPatchAPIGuildVoiceStateUserJSONBody, RESTPatchAPIGuildVoiceStateUserResult, RESTPatchAPIGuildWelcomeScreenJSONBody, RESTPatchAPIGuildWelcomeScreenResult, RESTPatchAPIGuildWidgetSettingsJSONBody, RESTPatchAPIGuildWidgetSettingsResult, RESTPostAPIAutoModerationRuleJSONBody, RESTPostAPIAutoModerationRuleResult, RESTPostAPIGuildBulkBanJSONBody, RESTPostAPIGuildBulkBanResult, RESTPostAPIGuildChannelJSONBody, RESTPostAPIGuildChannelResult, RESTPostAPIGuildEmojiJSONBody, RESTPostAPIGuildEmojiResult, RESTPostAPIGuildPruneJSONBody, RESTPostAPIGuildPruneResult, RESTPostAPIGuildRoleJSONBody, RESTPostAPIGuildRoleResult, RESTPostAPIGuildScheduledEventJSONBody, RESTPostAPIGuildScheduledEventResult, RESTPostAPIGuildStickerFormDataBody, RESTPostAPIGuildStickerResult, RESTPostAPIGuildTemplatesJSONBody, RESTPostAPIGuildTemplatesResult, RESTPostAPIGuildsJSONBody, RESTPostAPIGuildsMFAJSONBody, RESTPostAPIGuildsMFAResult, RESTPostAPIGuildsResult, RESTPostAPITemplateCreateGuildJSONBody, RESTPostAPITemplateCreateGuildResult, RESTPutAPIGuildBanJSONBody, RESTPutAPIGuildBanResult, RESTPutAPIGuildMemberJSONBody, RESTPutAPIGuildMemberResult, RESTPutAPIGuildMemberRoleResult, RESTPutAPIGuildTemplateSyncResult } from 'discord-api-types/v10';
|
|
2
2
|
import type { Identify, OmitInsert } from '../../common';
|
|
3
3
|
import type { ProxyRequestMethod } from '../Router';
|
|
4
4
|
import type { RestArguments } from '../api';
|
|
@@ -82,6 +82,9 @@ export interface GuildRoutes {
|
|
|
82
82
|
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIGuildBanResult>;
|
|
83
83
|
};
|
|
84
84
|
};
|
|
85
|
+
'bulk-bans': {
|
|
86
|
+
post(args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIGuildBulkBanJSONBody>): Promise<RESTPostAPIGuildBulkBanResult>;
|
|
87
|
+
};
|
|
85
88
|
mfa: {
|
|
86
89
|
post(args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIGuildsMFAJSONBody>): Promise<RESTPostAPIGuildsMFAResult>;
|
|
87
90
|
};
|
package/lib/cache/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { StageInstances } from './resources/stage-instances';
|
|
|
11
11
|
import { Stickers } from './resources/stickers';
|
|
12
12
|
import { Threads } from './resources/threads';
|
|
13
13
|
import { VoiceStates } from './resources/voice-states';
|
|
14
|
+
import { Bans } from './resources/bans';
|
|
14
15
|
import { GatewayIntentBits, type GatewayDispatchPayload } from 'discord-api-types/v10';
|
|
15
16
|
import type { InternalOptions, UsingClient } from '../commands';
|
|
16
17
|
import { Overwrites } from './resources/overwrites';
|
|
@@ -20,10 +21,10 @@ export type InferAsyncCache = InternalOptions extends {
|
|
|
20
21
|
} ? P : false;
|
|
21
22
|
export type ReturnCache<T> = If<InferAsyncCache, Promise<T>, T>;
|
|
22
23
|
export type GuildBased = 'members' | 'voiceStates';
|
|
23
|
-
export type GuildRelated = 'emojis' | 'roles' | 'threads' | 'channels' | 'stickers' | 'presences' | 'stageInstances' | 'overwrites' | 'messages';
|
|
24
|
+
export type GuildRelated = 'emojis' | 'roles' | 'threads' | 'channels' | 'stickers' | 'presences' | 'stageInstances' | 'overwrites' | 'messages' | 'bans';
|
|
24
25
|
export type NonGuildBased = 'users' | 'guilds';
|
|
25
26
|
export * from './adapters/index';
|
|
26
|
-
export type CachedEvents = 'READY' | 'GUILD_CREATE' | 'GUILD_UPDATE' | 'GUILD_DELETE' | 'CHANNEL_CREATE' | 'CHANNEL_UPDATE' | 'CHANNEL_DELETE' | 'GUILD_ROLE_CREATE' | 'GUILD_ROLE_UPDATE' | 'GUILD_ROLE_DELETE' | 'GUILD_EMOJIS_UPDATE' | 'GUILD_STICKERS_UPDATE' | 'GUILD_MEMBER_ADD' | 'GUILD_MEMBER_UPDATE' | 'GUILD_MEMBER_REMOVE' | 'MESSAGE_CREATE' | 'PRESENCE_UPDATE' | 'THREAD_DELETE' | 'THREAD_CREATE' | 'THREAD_UPDATE' | 'USER_UPDATE' | 'VOICE_STATE_UPDATE' | 'STAGE_INSTANCE_CREATE' | 'STAGE_INSTANCE_UPDATE' | 'STAGE_INSTANCE_DELETE';
|
|
27
|
+
export type CachedEvents = 'READY' | 'GUILD_CREATE' | 'GUILD_UPDATE' | 'GUILD_DELETE' | 'CHANNEL_CREATE' | 'CHANNEL_UPDATE' | 'CHANNEL_DELETE' | 'GUILD_ROLE_CREATE' | 'GUILD_ROLE_UPDATE' | 'GUILD_ROLE_DELETE' | 'GUILD_BAN_ADD' | 'GUILD_BAN_REMOVE' | 'GUILD_EMOJIS_UPDATE' | 'GUILD_STICKERS_UPDATE' | 'GUILD_MEMBER_ADD' | 'GUILD_MEMBER_UPDATE' | 'GUILD_MEMBER_REMOVE' | 'MESSAGE_CREATE' | 'PRESENCE_UPDATE' | 'THREAD_DELETE' | 'THREAD_CREATE' | 'THREAD_UPDATE' | 'USER_UPDATE' | 'VOICE_STATE_UPDATE' | 'STAGE_INSTANCE_CREATE' | 'STAGE_INSTANCE_UPDATE' | 'STAGE_INSTANCE_DELETE';
|
|
27
28
|
export declare class Cache {
|
|
28
29
|
intents: number;
|
|
29
30
|
adapter: Adapter;
|
|
@@ -41,6 +42,7 @@ export declare class Cache {
|
|
|
41
42
|
presences?: Presences;
|
|
42
43
|
stageInstances?: StageInstances;
|
|
43
44
|
messages?: Messages;
|
|
45
|
+
bans?: Bans;
|
|
44
46
|
constructor(intents: number, adapter: Adapter, disabledCache?: (NonGuildBased | GuildBased | GuildRelated)[], client?: UsingClient);
|
|
45
47
|
flush(): ReturnCache<void>;
|
|
46
48
|
hasIntent(intent: keyof typeof GatewayIntentBits): boolean;
|
|
@@ -52,6 +54,7 @@ export declare class Cache {
|
|
|
52
54
|
get hasVoiceStatesIntent(): boolean;
|
|
53
55
|
get hasPrenseceUpdates(): boolean;
|
|
54
56
|
get hasDirectMessages(): boolean;
|
|
57
|
+
get hasBansIntent(): boolean;
|
|
55
58
|
bulkGet(keys: (readonly [
|
|
56
59
|
NonGuildBased | GuildRelated,
|
|
57
60
|
string
|
|
@@ -74,6 +77,7 @@ export declare class Cache {
|
|
|
74
77
|
guild_id: string;
|
|
75
78
|
})[];
|
|
76
79
|
threads: import("..").ThreadChannel[];
|
|
80
|
+
bans: import("../structures/GuildBan").GuildBan[];
|
|
77
81
|
voiceStates: import("..").VoiceState[];
|
|
78
82
|
stageInstances: (import("discord-api-types/v10").APIStageInstance & {
|
|
79
83
|
guild_id: string;
|
package/lib/cache/index.js
CHANGED
|
@@ -26,6 +26,7 @@ const stage_instances_1 = require("./resources/stage-instances");
|
|
|
26
26
|
const stickers_1 = require("./resources/stickers");
|
|
27
27
|
const threads_1 = require("./resources/threads");
|
|
28
28
|
const voice_states_1 = require("./resources/voice-states");
|
|
29
|
+
const bans_1 = require("./resources/bans");
|
|
29
30
|
const v10_1 = require("discord-api-types/v10");
|
|
30
31
|
const overwrites_1 = require("./resources/overwrites");
|
|
31
32
|
const messages_1 = require("./resources/messages");
|
|
@@ -50,6 +51,7 @@ class Cache {
|
|
|
50
51
|
presences;
|
|
51
52
|
stageInstances;
|
|
52
53
|
messages;
|
|
54
|
+
bans;
|
|
53
55
|
constructor(intents, adapter, disabledCache = [], client) {
|
|
54
56
|
this.intents = intents;
|
|
55
57
|
this.adapter = adapter;
|
|
@@ -96,6 +98,9 @@ class Cache {
|
|
|
96
98
|
if (!this.disabledCache.includes('messages')) {
|
|
97
99
|
this.messages = new messages_1.Messages(this, client);
|
|
98
100
|
}
|
|
101
|
+
if (!this.disabledCache.includes('bans')) {
|
|
102
|
+
this.bans = new bans_1.Bans(this, client);
|
|
103
|
+
}
|
|
99
104
|
}
|
|
100
105
|
/** @internal */
|
|
101
106
|
__setClient(client) {
|
|
@@ -112,6 +117,7 @@ class Cache {
|
|
|
112
117
|
this.threads?.__setClient(client);
|
|
113
118
|
this.stageInstances?.__setClient(client);
|
|
114
119
|
this.messages?.__setClient(client);
|
|
120
|
+
this.bans?.__setClient(client);
|
|
115
121
|
}
|
|
116
122
|
flush() {
|
|
117
123
|
return this.adapter.flush();
|
|
@@ -144,6 +150,9 @@ class Cache {
|
|
|
144
150
|
get hasDirectMessages() {
|
|
145
151
|
return this.hasIntent('DirectMessages');
|
|
146
152
|
}
|
|
153
|
+
get hasBansIntent() {
|
|
154
|
+
return this.hasIntent('GuildBans');
|
|
155
|
+
}
|
|
147
156
|
async bulkGet(keys) {
|
|
148
157
|
const allData = {};
|
|
149
158
|
for (const [type, id, guildId] of keys) {
|
|
@@ -167,6 +176,7 @@ class Cache {
|
|
|
167
176
|
case 'users':
|
|
168
177
|
case 'guilds':
|
|
169
178
|
case 'overwrites':
|
|
179
|
+
case 'bans':
|
|
170
180
|
case 'messages':
|
|
171
181
|
{
|
|
172
182
|
if (!allData[type]) {
|
|
@@ -207,6 +217,7 @@ class Cache {
|
|
|
207
217
|
case 'stageInstances':
|
|
208
218
|
case 'emojis':
|
|
209
219
|
case 'overwrites':
|
|
220
|
+
case 'bans':
|
|
210
221
|
case 'messages':
|
|
211
222
|
{
|
|
212
223
|
if (!this[type]?.filter(data, id, guildId))
|
|
@@ -278,6 +289,7 @@ class Cache {
|
|
|
278
289
|
case 'stageInstances':
|
|
279
290
|
case 'emojis':
|
|
280
291
|
case 'overwrites':
|
|
292
|
+
case 'bans':
|
|
281
293
|
case 'messages':
|
|
282
294
|
{
|
|
283
295
|
if (!this[type]?.filter(data, id, guildId))
|
|
@@ -376,6 +388,12 @@ class Cache {
|
|
|
376
388
|
case 'GUILD_ROLE_DELETE':
|
|
377
389
|
await this.roles?.remove(event.d.role_id, event.d.guild_id);
|
|
378
390
|
break;
|
|
391
|
+
case 'GUILD_BAN_ADD':
|
|
392
|
+
await this.bans?.set(event.d.user.id, event.d.guild_id, event.d);
|
|
393
|
+
break;
|
|
394
|
+
case 'GUILD_BAN_REMOVE':
|
|
395
|
+
await this.bans?.remove(event.d.user.id, event.d.guild_id);
|
|
396
|
+
break;
|
|
379
397
|
case 'GUILD_EMOJIS_UPDATE':
|
|
380
398
|
await this.emojis?.remove(await this.emojis?.keys(event.d.guild_id), event.d.guild_id);
|
|
381
399
|
await this.emojis?.set(event.d.emojis.map(x => [x.id, x]), event.d.guild_id);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { APIBan } from 'discord-api-types/v10';
|
|
2
|
+
import type { ReturnCache } from '../..';
|
|
3
|
+
import { GuildBasedResource } from './default/guild-based';
|
|
4
|
+
import { GuildBan } from '../../structures/GuildBan';
|
|
5
|
+
export declare class Bans extends GuildBasedResource {
|
|
6
|
+
namespace: string;
|
|
7
|
+
filter(data: APIBan, id: string, guild_id: string): boolean;
|
|
8
|
+
parse(data: any, key: string, guild_id: string): any;
|
|
9
|
+
get(id: string, guild: string): ReturnCache<GuildBan | undefined>;
|
|
10
|
+
bulk(ids: string[], guild: string): ReturnCache<GuildBan[]>;
|
|
11
|
+
values(guild: string): ReturnCache<GuildBan[]>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Bans = void 0;
|
|
4
|
+
const common_1 = require("../../common");
|
|
5
|
+
const guild_based_1 = require("./default/guild-based");
|
|
6
|
+
const GuildBan_1 = require("../../structures/GuildBan");
|
|
7
|
+
class Bans extends guild_based_1.GuildBasedResource {
|
|
8
|
+
namespace = 'ban';
|
|
9
|
+
//@ts-expect-error
|
|
10
|
+
filter(data, id, guild_id) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
parse(data, key, guild_id) {
|
|
14
|
+
const { user, ...rest } = super.parse(data, data.user?.id ?? key, guild_id);
|
|
15
|
+
return rest;
|
|
16
|
+
}
|
|
17
|
+
get(id, guild) {
|
|
18
|
+
return (0, common_1.fakePromise)(super.get(id, guild)).then(rawBan => rawBan ? new GuildBan_1.GuildBan(this.client, rawBan, guild) : undefined);
|
|
19
|
+
}
|
|
20
|
+
bulk(ids, guild) {
|
|
21
|
+
return (0, common_1.fakePromise)(super.bulk(ids, guild)).then(bans => bans
|
|
22
|
+
.map(rawBan => {
|
|
23
|
+
return rawBan ? new GuildBan_1.GuildBan(this.client, rawBan, guild) : undefined;
|
|
24
|
+
})
|
|
25
|
+
.filter(Boolean));
|
|
26
|
+
}
|
|
27
|
+
values(guild) {
|
|
28
|
+
return (0, common_1.fakePromise)(super.values(guild)).then(bans => bans
|
|
29
|
+
.map(rawBan => {
|
|
30
|
+
return rawBan ? new GuildBan_1.GuildBan(this.client, rawBan, guild) : undefined;
|
|
31
|
+
})
|
|
32
|
+
.filter(Boolean));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.Bans = Bans;
|
|
@@ -18,17 +18,17 @@ class Members extends guild_based_1.GuildBasedResource {
|
|
|
18
18
|
return (0, common_1.fakePromise)(super.get(id, guild)).then(rawMember => (0, common_1.fakePromise)(this.client.cache.users?.get(id)).then(user => rawMember && user ? new structures_1.GuildMember(this.client, rawMember, user, guild) : undefined));
|
|
19
19
|
}
|
|
20
20
|
bulk(ids, guild) {
|
|
21
|
-
return (0, common_1.fakePromise)(super.bulk(ids, guild)).then(members => (0, common_1.fakePromise)(this.client.cache.users?.bulk(ids)
|
|
21
|
+
return (0, common_1.fakePromise)(super.bulk(ids, guild)).then(members => (0, common_1.fakePromise)(this.client.cache.users?.bulk(ids)).then(users => members
|
|
22
22
|
.map(rawMember => {
|
|
23
|
-
const user = users
|
|
23
|
+
const user = users?.find(x => x.id === rawMember.id);
|
|
24
24
|
return user ? new structures_1.GuildMember(this.client, rawMember, user, guild) : undefined;
|
|
25
25
|
})
|
|
26
26
|
.filter(Boolean)));
|
|
27
27
|
}
|
|
28
28
|
values(guild) {
|
|
29
|
-
return (0, common_1.fakePromise)(super.values(guild)).then(members => (0, common_1.fakePromise)(this.client.cache.users?.values()
|
|
29
|
+
return (0, common_1.fakePromise)(super.values(guild)).then(members => (0, common_1.fakePromise)(this.client.cache.users?.values()).then(users => members
|
|
30
30
|
.map(rawMember => {
|
|
31
|
-
const user = users
|
|
31
|
+
const user = users?.find(x => x.id === rawMember.id);
|
|
32
32
|
return user ? new structures_1.GuildMember(this.client, rawMember, user, rawMember.guild_id) : undefined;
|
|
33
33
|
})
|
|
34
34
|
.filter(Boolean)));
|
|
@@ -18,19 +18,21 @@ class Messages extends guild_related_1.GuildRelatedResource {
|
|
|
18
18
|
}
|
|
19
19
|
get(id) {
|
|
20
20
|
return (0, common_1.fakePromise)(super.get(id)).then(rawMessage => {
|
|
21
|
-
|
|
22
|
-
? this.cache.adapter.get(this.cache.users.hashId(rawMessage.user_id))
|
|
21
|
+
return this.cache.users && rawMessage?.user_id
|
|
22
|
+
? (0, common_1.fakePromise)(this.cache.adapter.get(this.cache.users.hashId(rawMessage.user_id))).then(user => {
|
|
23
|
+
return user ? new structures_1.Message(this.client, { ...rawMessage, author: user }) : undefined;
|
|
24
|
+
})
|
|
23
25
|
: undefined;
|
|
24
|
-
return user ? new structures_1.Message(this.client, { ...rawMessage, author: user }) : undefined;
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
28
|
bulk(ids) {
|
|
28
29
|
return (0, common_1.fakePromise)(super.bulk(ids)).then(messages => messages
|
|
29
30
|
.map(rawMessage => {
|
|
30
|
-
|
|
31
|
-
? this.cache.adapter.get(this.cache.users.hashId(rawMessage.user_id))
|
|
31
|
+
return this.cache.users && rawMessage?.user_id
|
|
32
|
+
? (0, common_1.fakePromise)(this.cache.adapter.get(this.cache.users.hashId(rawMessage.user_id))).then(user => {
|
|
33
|
+
return user ? new structures_1.Message(this.client, { ...rawMessage, author: user }) : undefined;
|
|
34
|
+
})
|
|
32
35
|
: undefined;
|
|
33
|
-
return user ? new structures_1.Message(this.client, { ...rawMessage, author: user }) : undefined;
|
|
34
36
|
})
|
|
35
37
|
.filter(Boolean));
|
|
36
38
|
}
|
package/lib/client/base.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { ApiHandler } from '../api';
|
|
2
2
|
import type { Adapter } from '../cache';
|
|
3
3
|
import { Cache } from '../cache';
|
|
4
|
-
import type { Command, RegisteredMiddlewares } from '../commands';
|
|
4
|
+
import type { Command, ExtraProps, RegisteredMiddlewares } from '../commands';
|
|
5
5
|
import { type InferWithPrefix, type MiddlewareContext } from '../commands/applications/shared';
|
|
6
6
|
import { CommandHandler } from '../commands/handler';
|
|
7
7
|
import { ChannelShorter, EmojiShorter, GuildShorter, InteractionShorter, Logger, MemberShorter, MessageShorter, ReactionShorter, RoleShorter, TemplateShorter, ThreadShorter, UsersShorter, WebhookShorter, type MakeRequired } from '../common';
|
|
8
8
|
import type { LocaleString, RESTPostAPIChannelMessageJSONBody } from 'discord-api-types/rest/v10';
|
|
9
|
-
import type { DeepPartial, IntentStrings, OmitInsert, When } from '../common/types/util';
|
|
9
|
+
import type { Awaitable, DeepPartial, IntentStrings, OmitInsert, When } from '../common/types/util';
|
|
10
10
|
import { ComponentHandler } from '../components/handler';
|
|
11
11
|
import { LangsHandler } from '../langs/handler';
|
|
12
12
|
import type { ChatInputCommandInteraction, ComponentInteraction, Message, MessageCommandInteraction, ModalSubmitInteraction, UserCommandInteraction } from '../structures';
|
|
13
13
|
import type { ComponentCommand, ModalCommand } from '../components';
|
|
14
|
+
import { BanShorter } from '../common/shorters/bans';
|
|
14
15
|
export declare class BaseClient {
|
|
15
16
|
rest: ApiHandler;
|
|
16
17
|
cache: Cache;
|
|
@@ -25,6 +26,7 @@ export declare class BaseClient {
|
|
|
25
26
|
reactions: ReactionShorter;
|
|
26
27
|
emojis: EmojiShorter;
|
|
27
28
|
threads: ThreadShorter;
|
|
29
|
+
bans: BanShorter;
|
|
28
30
|
interactions: InteractionShorter;
|
|
29
31
|
debugger?: Logger;
|
|
30
32
|
logger: Logger;
|
|
@@ -43,7 +45,7 @@ export declare class BaseClient {
|
|
|
43
45
|
set applicationId(id: string);
|
|
44
46
|
get applicationId(): string;
|
|
45
47
|
get proxy(): import("../api").APIRoutes;
|
|
46
|
-
setServices({ rest, cache, langs, middlewares, handlers }: ServicesOptions): void;
|
|
48
|
+
setServices({ rest, cache, langs, middlewares, handlers, }: ServicesOptions): void;
|
|
47
49
|
protected execute(..._options: unknown[]): Promise<void>;
|
|
48
50
|
start(options?: Pick<DeepPartial<StartOptions>, 'langsDir' | 'commandsDir' | 'connection' | 'token' | 'componentsDir'>): Promise<void>;
|
|
49
51
|
protected onPacket(..._packet: unknown[]): Promise<void>;
|
|
@@ -79,6 +81,7 @@ export interface BaseClientOptions {
|
|
|
79
81
|
onMiddlewaresError?: Command['onMiddlewaresError'];
|
|
80
82
|
onOptionsError?: Command['onOptionsError'];
|
|
81
83
|
onAfterRun?: Command['onAfterRun'];
|
|
84
|
+
props?: ExtraProps;
|
|
82
85
|
};
|
|
83
86
|
};
|
|
84
87
|
components?: {
|
|
@@ -100,6 +103,7 @@ export interface BaseClientOptions {
|
|
|
100
103
|
allowedMentions?: Omit<NonNullable<RESTPostAPIChannelMessageJSONBody['allowed_mentions']>, 'parse'> & {
|
|
101
104
|
parse?: ('everyone' | 'roles' | 'users')[];
|
|
102
105
|
};
|
|
106
|
+
getRC?(): Awaitable<InternalRuntimeConfig | InternalRuntimeConfigHTTP>;
|
|
103
107
|
}
|
|
104
108
|
export interface StartOptions {
|
|
105
109
|
eventsDir: string;
|
package/lib/client/base.js
CHANGED
|
@@ -10,6 +10,7 @@ const common_1 = require("../common");
|
|
|
10
10
|
const handler_2 = require("../components/handler");
|
|
11
11
|
const handler_3 = require("../langs/handler");
|
|
12
12
|
const node_fs_1 = require("node:fs");
|
|
13
|
+
const bans_1 = require("../common/shorters/bans");
|
|
13
14
|
class BaseClient {
|
|
14
15
|
rest;
|
|
15
16
|
cache;
|
|
@@ -24,6 +25,7 @@ class BaseClient {
|
|
|
24
25
|
reactions = new common_1.ReactionShorter(this);
|
|
25
26
|
emojis = new common_1.EmojiShorter(this);
|
|
26
27
|
threads = new common_1.ThreadShorter(this);
|
|
28
|
+
bans = new bans_1.BanShorter(this);
|
|
27
29
|
interactions = new common_1.InteractionShorter(this);
|
|
28
30
|
debugger;
|
|
29
31
|
logger = new common_1.Logger({
|
|
@@ -45,7 +47,7 @@ class BaseClient {
|
|
|
45
47
|
}
|
|
46
48
|
options;
|
|
47
49
|
/**@internal */
|
|
48
|
-
static
|
|
50
|
+
static _seyfertConfig;
|
|
49
51
|
constructor(options) {
|
|
50
52
|
this.options = (0, common_1.MergeOptions)({
|
|
51
53
|
commands: {
|
|
@@ -102,7 +104,7 @@ class BaseClient {
|
|
|
102
104
|
this._botId = id;
|
|
103
105
|
}
|
|
104
106
|
get botId() {
|
|
105
|
-
return this._botId ?? BaseClient.getBotIdFromToken(this.rest.options.token);
|
|
107
|
+
return (this._botId ?? BaseClient.getBotIdFromToken(this.rest.options.token));
|
|
106
108
|
}
|
|
107
109
|
set applicationId(id) {
|
|
108
110
|
this._applicationId = id;
|
|
@@ -113,7 +115,7 @@ class BaseClient {
|
|
|
113
115
|
get proxy() {
|
|
114
116
|
return new api_1.Router(this.rest).createProxy();
|
|
115
117
|
}
|
|
116
|
-
setServices({ rest, cache, langs, middlewares, handlers }) {
|
|
118
|
+
setServices({ rest, cache, langs, middlewares, handlers, }) {
|
|
117
119
|
if (rest) {
|
|
118
120
|
this.rest = rest;
|
|
119
121
|
}
|
|
@@ -130,7 +132,9 @@ class BaseClient {
|
|
|
130
132
|
}
|
|
131
133
|
else if (typeof handlers.components === 'function') {
|
|
132
134
|
this.components ??= new handler_2.ComponentHandler(this.logger, this);
|
|
133
|
-
this.components.setHandlers({
|
|
135
|
+
this.components.setHandlers({
|
|
136
|
+
callback: handlers.components,
|
|
137
|
+
});
|
|
134
138
|
}
|
|
135
139
|
else {
|
|
136
140
|
this.components = handlers.components;
|
|
@@ -197,11 +201,11 @@ class BaseClient {
|
|
|
197
201
|
debug: (await this.getRC()).debug,
|
|
198
202
|
});
|
|
199
203
|
}
|
|
200
|
-
if (
|
|
201
|
-
this.cache
|
|
204
|
+
if (this.cache) {
|
|
205
|
+
this.cache.__setClient(this);
|
|
202
206
|
}
|
|
203
207
|
else {
|
|
204
|
-
this.cache.
|
|
208
|
+
this.cache = new cache_1.Cache(0, new cache_1.MemoryAdapter(), [], this);
|
|
205
209
|
}
|
|
206
210
|
}
|
|
207
211
|
async onPacket(..._packet) {
|
|
@@ -210,17 +214,19 @@ class BaseClient {
|
|
|
210
214
|
shouldUploadCommands(cachePath) {
|
|
211
215
|
return this.commands.shouldUpload(cachePath).then(async (should) => {
|
|
212
216
|
if (should)
|
|
213
|
-
await node_fs_1.promises.writeFile(cachePath, JSON.stringify(this.commands.values.map(x => x.toJSON())));
|
|
217
|
+
await node_fs_1.promises.writeFile(cachePath, JSON.stringify(this.commands.values.map((x) => x.toJSON())));
|
|
214
218
|
return should;
|
|
215
219
|
});
|
|
216
220
|
}
|
|
217
221
|
async uploadCommands(applicationId) {
|
|
218
|
-
applicationId ??= await this.getRC().then(x => x.applicationId ?? this.applicationId);
|
|
222
|
+
applicationId ??= await this.getRC().then((x) => x.applicationId ?? this.applicationId);
|
|
219
223
|
BaseClient.assertString(applicationId, 'applicationId is not a string');
|
|
220
224
|
const commands = this.commands.values;
|
|
221
|
-
const filter = (0, common_1.filterSplit)(commands, command => !command.guildId);
|
|
225
|
+
const filter = (0, common_1.filterSplit)(commands, (command) => !command.guildId);
|
|
222
226
|
await this.proxy.applications(applicationId).commands.put({
|
|
223
|
-
body: filter.expect
|
|
227
|
+
body: filter.expect
|
|
228
|
+
.filter((cmd) => !('ignore' in cmd) || cmd.ignore !== shared_1.IgnoreCommand.Slash)
|
|
229
|
+
.map((x) => x.toJSON()),
|
|
224
230
|
});
|
|
225
231
|
const guilds = new Set();
|
|
226
232
|
for (const command of filter.never) {
|
|
@@ -234,27 +240,29 @@ class BaseClient {
|
|
|
234
240
|
.guilds(guild)
|
|
235
241
|
.commands.put({
|
|
236
242
|
body: filter.never
|
|
237
|
-
.filter(cmd => cmd.guildId?.includes(guild) &&
|
|
238
|
-
|
|
243
|
+
.filter((cmd) => cmd.guildId?.includes(guild) &&
|
|
244
|
+
(!('ignore' in cmd) ||
|
|
245
|
+
cmd.ignore !== shared_1.IgnoreCommand.Slash))
|
|
246
|
+
.map((x) => x.toJSON()),
|
|
239
247
|
});
|
|
240
248
|
}
|
|
241
249
|
}
|
|
242
250
|
async loadCommands(dir) {
|
|
243
|
-
dir ??= await this.getRC().then(x => x.commands);
|
|
251
|
+
dir ??= await this.getRC().then((x) => x.commands);
|
|
244
252
|
if (dir && this.commands) {
|
|
245
253
|
await this.commands.load(dir, this);
|
|
246
254
|
this.logger.info('CommandHandler loaded');
|
|
247
255
|
}
|
|
248
256
|
}
|
|
249
257
|
async loadComponents(dir) {
|
|
250
|
-
dir ??= await this.getRC().then(x => x.components);
|
|
258
|
+
dir ??= await this.getRC().then((x) => x.components);
|
|
251
259
|
if (dir && this.components) {
|
|
252
260
|
await this.components.load(dir);
|
|
253
261
|
this.logger.info('ComponentHandler loaded');
|
|
254
262
|
}
|
|
255
263
|
}
|
|
256
264
|
async loadLangs(dir) {
|
|
257
|
-
dir ??= await this.getRC().then(x => x.langs);
|
|
265
|
+
dir ??= await this.getRC().then((x) => x.langs);
|
|
258
266
|
if (dir && this.langs) {
|
|
259
267
|
await this.langs.load(dir);
|
|
260
268
|
this.logger.info('LangsHandler loaded');
|
|
@@ -264,21 +272,32 @@ class BaseClient {
|
|
|
264
272
|
return this.langs.get(locale);
|
|
265
273
|
}
|
|
266
274
|
async getRC() {
|
|
267
|
-
const seyfertConfig = (BaseClient.
|
|
268
|
-
(await
|
|
275
|
+
const seyfertConfig = (BaseClient._seyfertConfig ||
|
|
276
|
+
(await this.options.getRC?.()) ||
|
|
277
|
+
(await (0, common_1.magicImport)((0, node_path_1.join)(process.cwd(), 'seyfert.config.js')).then((x) => x.default ?? x)));
|
|
269
278
|
const { locations, debug, ...env } = seyfertConfig;
|
|
270
279
|
const obj = {
|
|
271
280
|
debug: !!debug,
|
|
272
281
|
...env,
|
|
273
|
-
templates: locations.templates
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
282
|
+
templates: locations.templates
|
|
283
|
+
? (0, node_path_1.join)(process.cwd(), locations.base, locations.templates)
|
|
284
|
+
: undefined,
|
|
285
|
+
langs: locations.langs
|
|
286
|
+
? (0, node_path_1.join)(process.cwd(), locations.output, locations.langs)
|
|
287
|
+
: undefined,
|
|
288
|
+
events: 'events' in locations && locations.events
|
|
289
|
+
? (0, node_path_1.join)(process.cwd(), locations.output, locations.events)
|
|
290
|
+
: undefined,
|
|
291
|
+
components: locations.components
|
|
292
|
+
? (0, node_path_1.join)(process.cwd(), locations.output, locations.components)
|
|
293
|
+
: undefined,
|
|
294
|
+
commands: locations.commands
|
|
295
|
+
? (0, node_path_1.join)(process.cwd(), locations.output, locations.commands)
|
|
296
|
+
: undefined,
|
|
278
297
|
base: (0, node_path_1.join)(process.cwd(), locations.base),
|
|
279
298
|
output: (0, node_path_1.join)(process.cwd(), locations.output),
|
|
280
299
|
};
|
|
281
|
-
BaseClient.
|
|
300
|
+
BaseClient._seyfertConfig = seyfertConfig;
|
|
282
301
|
return obj;
|
|
283
302
|
}
|
|
284
303
|
}
|
package/lib/client/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type GatewayDispatchPayload, type GatewayPresenceUpdateData } from 'discord-api-types/v10';
|
|
2
|
-
import type { Command, CommandContext, Message, SubCommand } from '..';
|
|
3
|
-
import { type DeepPartial, type If } from '../common';
|
|
1
|
+
import { type APIApplicationCommandInteractionDataOption, type GatewayMessageCreateDispatchData, type GatewayDispatchPayload, type GatewayPresenceUpdateData } from 'discord-api-types/v10';
|
|
2
|
+
import type { Command, CommandContext, ContextOptionsResolved, Message, MessageCommandOptionErrors, SubCommand, UsingClient } from '..';
|
|
3
|
+
import { type Awaitable, type MakeRequired, type DeepPartial, type If } from '../common';
|
|
4
4
|
import { EventHandler } from '../events';
|
|
5
5
|
import { ClientUser } from '../structures';
|
|
6
6
|
import { ShardManager, type ShardManagerOptions } from '../websocket';
|
|
@@ -8,14 +8,18 @@ import { MemberUpdateHandler } from '../websocket/discord/events/memberUpdate';
|
|
|
8
8
|
import { PresenceUpdateHandler } from '../websocket/discord/events/presenceUpdate';
|
|
9
9
|
import type { BaseClientOptions, ServicesOptions, StartOptions } from './base';
|
|
10
10
|
import { BaseClient } from './base';
|
|
11
|
+
import { Collectors } from './collectors';
|
|
11
12
|
export declare class Client<Ready extends boolean = boolean> extends BaseClient {
|
|
12
13
|
private __handleGuilds?;
|
|
13
14
|
gateway: ShardManager;
|
|
14
|
-
events?: EventHandler | undefined;
|
|
15
15
|
me: If<Ready, ClientUser>;
|
|
16
|
-
options: ClientOptions
|
|
16
|
+
options: Omit<ClientOptions, 'commands'> & {
|
|
17
|
+
commands: MakeRequired<NonNullable<ClientOptions['commands']>, 'argsParser' | 'optionsParser'>;
|
|
18
|
+
};
|
|
17
19
|
memberUpdateHandler: MemberUpdateHandler;
|
|
18
20
|
presenceUpdateHandler: PresenceUpdateHandler;
|
|
21
|
+
collectors: Collectors;
|
|
22
|
+
events?: EventHandler | undefined;
|
|
19
23
|
constructor(options?: ClientOptions);
|
|
20
24
|
setServices({ gateway, ...rest }: ServicesOptions & {
|
|
21
25
|
gateway?: ShardManager;
|
|
@@ -47,6 +51,14 @@ export interface ClientOptions extends BaseClientOptions {
|
|
|
47
51
|
deferReplyResponse?: (ctx: CommandContext) => Parameters<Message['write']>[0];
|
|
48
52
|
reply?: (ctx: CommandContext) => boolean;
|
|
49
53
|
argsParser?: (content: string, command: SubCommand | Command, message: Message) => Record<string, string>;
|
|
54
|
+
optionsParser?: (self: UsingClient, command: Command | SubCommand, message: GatewayMessageCreateDispatchData, args: Partial<Record<string, string>>, resolved: MakeRequired<ContextOptionsResolved>) => Awaitable<{
|
|
55
|
+
errors: {
|
|
56
|
+
name: string;
|
|
57
|
+
error: string;
|
|
58
|
+
fullError: MessageCommandOptionErrors;
|
|
59
|
+
}[];
|
|
60
|
+
options: APIApplicationCommandInteractionDataOption[];
|
|
61
|
+
}>;
|
|
50
62
|
};
|
|
51
63
|
handlePayload?: ShardManagerOptions['handlePayload'];
|
|
52
64
|
}
|