seyfert 2.0.0 → 2.1.1-dev-11310514874.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/Router.d.ts +2 -2
- package/lib/api/Router.js +2 -1
- package/lib/api/Routes/applications.d.ts +29 -30
- package/lib/api/Routes/cdn.d.ts +6 -1
- package/lib/api/Routes/channels.d.ts +44 -45
- package/lib/api/Routes/gateway.d.ts +3 -4
- package/lib/api/Routes/guilds.d.ts +81 -80
- package/lib/api/Routes/index.d.ts +3 -1
- package/lib/api/Routes/interactions.d.ts +9 -3
- package/lib/api/Routes/invites.d.ts +3 -4
- package/lib/api/Routes/skus.d.ts +10 -0
- package/lib/api/Routes/skus.js +2 -0
- package/lib/api/Routes/soundboard.d.ts +23 -0
- package/lib/api/Routes/soundboard.js +2 -0
- package/lib/api/Routes/stage-instances.d.ts +5 -6
- package/lib/api/Routes/stickers.d.ts +3 -4
- package/lib/api/Routes/users.d.ts +11 -12
- package/lib/api/Routes/voice.d.ts +2 -3
- package/lib/api/Routes/webhooks.d.ts +16 -15
- package/lib/api/api.d.ts +17 -11
- package/lib/api/api.js +26 -22
- package/lib/api/shared.d.ts +2 -2
- package/lib/api/utils/constants.d.ts +3 -1
- package/lib/api/utils/constants.js +3 -2
- package/lib/builders/ActionRow.d.ts +1 -1
- package/lib/builders/Attachment.d.ts +3 -3
- package/lib/builders/Attachment.js +13 -13
- package/lib/builders/Button.d.ts +1 -1
- package/lib/builders/Button.js +1 -1
- package/lib/builders/Embed.d.ts +1 -1
- package/lib/builders/Embed.js +2 -2
- package/lib/builders/Modal.d.ts +1 -1
- package/lib/builders/Poll.d.ts +1 -1
- package/lib/builders/Poll.js +1 -1
- package/lib/builders/SelectMenu.d.ts +1 -1
- package/lib/builders/SelectMenu.js +1 -1
- package/lib/builders/types.d.ts +2 -1
- package/lib/cache/adapters/default.js +5 -3
- package/lib/cache/adapters/limited.d.ts +1 -2
- package/lib/cache/adapters/limited.js +34 -30
- package/lib/cache/adapters/workeradapter.js +3 -1
- package/lib/cache/index.d.ts +12 -12
- package/lib/cache/index.js +48 -39
- package/lib/cache/resources/bans.d.ts +2 -2
- package/lib/cache/resources/bans.js +1 -1
- package/lib/cache/resources/channels.d.ts +1 -1
- package/lib/cache/resources/default/guild-related.d.ts +1 -2
- package/lib/cache/resources/emojis.d.ts +2 -2
- package/lib/cache/resources/emojis.js +1 -1
- package/lib/cache/resources/guilds.d.ts +2 -2
- package/lib/cache/resources/guilds.js +7 -11
- package/lib/cache/resources/members.d.ts +2 -2
- package/lib/cache/resources/members.js +1 -1
- package/lib/cache/resources/messages.d.ts +2 -2
- package/lib/cache/resources/messages.js +3 -3
- package/lib/cache/resources/overwrites.d.ts +1 -1
- package/lib/cache/resources/roles.d.ts +2 -2
- package/lib/cache/resources/roles.js +1 -1
- package/lib/cache/resources/stickers.d.ts +2 -2
- package/lib/cache/resources/stickers.js +1 -1
- package/lib/cache/resources/users.d.ts +2 -2
- package/lib/cache/resources/users.js +1 -1
- package/lib/cache/resources/voice-states.d.ts +2 -2
- package/lib/cache/resources/voice-states.js +1 -1
- package/lib/client/base.d.ts +10 -15
- package/lib/client/base.js +48 -44
- package/lib/client/client.d.ts +4 -4
- package/lib/client/client.js +37 -38
- package/lib/client/collectors.js +1 -1
- package/lib/client/httpclient.d.ts +1 -1
- package/lib/client/httpclient.js +2 -2
- package/lib/client/transformers.d.ts +37 -34
- package/lib/client/transformers.js +66 -63
- package/lib/client/workerclient.d.ts +13 -13
- package/lib/client/workerclient.js +182 -65
- package/lib/collection.d.ts +3 -3
- package/lib/commands/applications/chat.d.ts +3 -3
- package/lib/commands/applications/chat.js +5 -6
- package/lib/commands/applications/chatcontext.d.ts +6 -6
- package/lib/commands/applications/chatcontext.js +16 -8
- package/lib/commands/applications/entryPoint.d.ts +46 -0
- package/lib/commands/applications/entryPoint.js +56 -0
- package/lib/commands/applications/entrycontext.d.ts +40 -0
- package/lib/commands/applications/entrycontext.js +85 -0
- package/lib/commands/applications/menu.d.ts +1 -1
- package/lib/commands/applications/menucontext.d.ts +5 -5
- package/lib/commands/applications/menucontext.js +6 -6
- package/lib/commands/applications/options.d.ts +7 -6
- package/lib/commands/applications/shared.d.ts +5 -2
- package/lib/commands/basecontext.d.ts +1 -1
- package/lib/commands/decorators.d.ts +20 -26
- package/lib/commands/decorators.js +8 -4
- package/lib/commands/handle.d.ts +13 -12
- package/lib/commands/handle.js +133 -65
- package/lib/commands/handler.d.ts +9 -7
- package/lib/commands/handler.js +27 -18
- package/lib/commands/index.d.ts +2 -0
- package/lib/commands/index.js +2 -0
- package/lib/commands/optionresolver.d.ts +4 -4
- package/lib/commands/optionresolver.js +4 -4
- package/lib/common/bot/watcher.d.ts +1 -1
- package/lib/common/it/formatter.d.ts +21 -21
- package/lib/common/it/formatter.js +40 -41
- package/lib/common/it/logger.js +1 -1
- package/lib/common/it/utils.d.ts +14 -6
- package/lib/common/it/utils.js +62 -27
- package/lib/common/shorters/application.d.ts +2 -3
- package/lib/common/shorters/application.js +3 -3
- package/lib/common/shorters/bans.js +1 -1
- package/lib/common/shorters/channels.d.ts +3 -3
- package/lib/common/shorters/channels.js +3 -3
- package/lib/common/shorters/emojis.js +4 -4
- package/lib/common/shorters/guilds.d.ts +3 -3
- package/lib/common/shorters/guilds.js +5 -9
- package/lib/common/shorters/interaction.d.ts +3 -3
- package/lib/common/shorters/interaction.js +6 -5
- package/lib/common/shorters/members.d.ts +4 -5
- package/lib/common/shorters/members.js +6 -7
- package/lib/common/shorters/messages.d.ts +1 -1
- package/lib/common/shorters/messages.js +4 -4
- package/lib/common/shorters/reactions.d.ts +1 -1
- package/lib/common/shorters/reactions.js +1 -1
- package/lib/common/shorters/roles.js +1 -1
- package/lib/common/shorters/templates.js +2 -2
- package/lib/common/shorters/threads.d.ts +1 -1
- package/lib/common/shorters/threads.js +17 -11
- package/lib/common/shorters/webhook.d.ts +1 -1
- package/lib/common/shorters/webhook.js +4 -4
- package/lib/common/types/options.d.ts +2 -2
- package/lib/common/types/resolvables.d.ts +1 -1
- package/lib/common/types/util.d.ts +4 -1
- package/lib/common/types/write.d.ts +3 -3
- package/lib/components/BaseComponent.js +1 -1
- package/lib/components/ButtonComponent.d.ts +1 -1
- package/lib/components/componentcommand.d.ts +1 -1
- package/lib/components/componentcontext.d.ts +4 -4
- package/lib/components/componentcontext.js +1 -1
- package/lib/components/handler.d.ts +10 -8
- package/lib/components/handler.js +16 -13
- package/lib/components/index.js +2 -1
- package/lib/components/modalcontext.d.ts +2 -2
- package/lib/components/modalcontext.js +1 -1
- package/lib/deps/mixer.d.ts +1 -1
- package/lib/deps/mixer.js +6 -1
- package/lib/events/handler.d.ts +5 -5
- package/lib/events/handler.js +69 -19
- package/lib/events/hooks/application_command.d.ts +1 -1
- package/lib/events/hooks/auto_moderation.d.ts +1 -1
- package/lib/events/hooks/auto_moderation.js +1 -1
- package/lib/events/hooks/channel.d.ts +1 -1
- package/lib/events/hooks/custom.d.ts +1 -0
- package/lib/events/hooks/custom.js +5 -1
- package/lib/events/hooks/dispatch.d.ts +1 -1
- package/lib/events/hooks/entitlement.d.ts +4 -5
- package/lib/events/hooks/entitlement.js +4 -4
- package/lib/events/hooks/guild.d.ts +3 -3
- package/lib/events/hooks/guild.js +1 -1
- package/lib/events/hooks/index.d.ts +1 -0
- package/lib/events/hooks/index.js +1 -0
- package/lib/events/hooks/integration.d.ts +1 -1
- package/lib/events/hooks/integration.js +1 -1
- package/lib/events/hooks/interactions.d.ts +3 -3
- package/lib/events/hooks/invite.d.ts +1 -1
- package/lib/events/hooks/message.d.ts +3 -3
- package/lib/events/hooks/message.js +1 -1
- package/lib/events/hooks/presence.d.ts +2 -2
- package/lib/events/hooks/soundboard.d.ts +155 -0
- package/lib/events/hooks/soundboard.js +28 -0
- package/lib/events/hooks/stage.d.ts +2 -2
- package/lib/events/hooks/subscriptions.d.ts +35 -0
- package/lib/events/hooks/subscriptions.js +16 -0
- package/lib/events/hooks/thread.d.ts +2 -2
- package/lib/events/hooks/thread.js +2 -2
- package/lib/events/hooks/typing.d.ts +1 -1
- package/lib/events/hooks/typing.js +1 -1
- package/lib/events/hooks/user.d.ts +2 -2
- package/lib/events/hooks/voice.d.ts +2 -2
- package/lib/events/hooks/voice.js +1 -1
- package/lib/events/hooks/webhook.d.ts +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +3 -5
- package/lib/langs/handler.d.ts +2 -2
- package/lib/structures/Guild.d.ts +7 -4
- package/lib/structures/Guild.js +1 -1
- package/lib/structures/GuildBan.d.ts +1 -1
- package/lib/structures/GuildMember.d.ts +7 -5
- package/lib/structures/GuildMember.js +5 -3
- package/lib/structures/GuildRole.d.ts +1 -1
- package/lib/structures/GuildTemplate.d.ts +1 -1
- package/lib/structures/Interaction.d.ts +39 -16
- package/lib/structures/Interaction.js +82 -26
- package/lib/structures/Message.d.ts +4 -10
- package/lib/structures/Message.js +5 -8
- package/lib/structures/Poll.d.ts +3 -3
- package/lib/structures/Sticker.d.ts +2 -2
- package/lib/structures/Sticker.js +1 -1
- package/lib/structures/VoiceState.d.ts +2 -1
- package/lib/structures/VoiceState.js +1 -1
- package/lib/structures/Webhook.d.ts +3 -3
- package/lib/structures/Webhook.js +1 -1
- package/lib/structures/channels.d.ts +4 -4
- package/lib/structures/channels.js +8 -7
- package/lib/structures/extra/BaseGuild.d.ts +11 -1
- package/lib/structures/extra/BaseGuild.js +27 -0
- package/lib/structures/extra/BitField.d.ts +3 -3
- package/lib/structures/extra/BitField.js +34 -33
- package/lib/structures/extra/DiscordBase.js +1 -1
- package/lib/structures/extra/Permissions.d.ts +2 -0
- package/lib/structures/extra/Permissions.js +21 -0
- package/lib/types/gateway.d.ts +71 -6
- package/lib/types/payloads/_interactions/_applicationCommands/chatInput.d.ts +6 -1
- package/lib/types/payloads/_interactions/applicationCommands.d.ts +41 -6
- package/lib/types/payloads/_interactions/applicationCommands.js +28 -1
- package/lib/types/payloads/_interactions/base.d.ts +1 -1
- package/lib/types/payloads/_interactions/responses.d.ts +74 -2
- package/lib/types/payloads/_interactions/responses.js +4 -0
- package/lib/types/payloads/channel.d.ts +46 -6
- package/lib/types/payloads/channel.js +5 -1
- package/lib/types/payloads/guild.d.ts +9 -1
- package/lib/types/payloads/guild.js +8 -0
- package/lib/types/payloads/index.d.ts +1 -0
- package/lib/types/payloads/index.js +1 -0
- package/lib/types/payloads/monetization.d.ts +29 -1
- package/lib/types/payloads/monetization.js +10 -1
- package/lib/types/payloads/soundboard.d.ts +23 -0
- package/lib/types/payloads/soundboard.js +5 -0
- package/lib/types/payloads/user.js +0 -1
- package/lib/types/rest/application.d.ts +3 -3
- package/lib/types/rest/auditLog.d.ts +1 -1
- package/lib/types/rest/channel.d.ts +5 -18
- package/lib/types/rest/guild.d.ts +2 -2
- package/lib/types/rest/guildScheduledEvent.d.ts +1 -1
- package/lib/types/rest/index.d.ts +1 -0
- package/lib/types/rest/index.js +1 -0
- package/lib/types/rest/interactions.d.ts +30 -8
- package/lib/types/rest/monetization.d.ts +22 -1
- package/lib/types/rest/oauth2.d.ts +1 -1
- package/lib/types/rest/poll.d.ts +1 -1
- package/lib/types/rest/soundboard.d.ts +64 -0
- package/lib/types/rest/soundboard.js +2 -0
- package/lib/types/rest/stageInstance.d.ts +1 -1
- package/lib/types/rest/template.d.ts +1 -1
- package/lib/types/rest/user.d.ts +1 -1
- package/lib/types/rest/webhook.d.ts +3 -3
- package/lib/types/utils/index.d.ts +27 -7
- package/lib/types/utils/index.js +25 -6
- package/lib/websocket/SharedTypes.d.ts +18 -3
- package/lib/websocket/constants/index.d.ts +3 -2
- package/lib/websocket/constants/index.js +4 -4
- package/lib/websocket/discord/basesocket.d.ts +1 -1
- package/lib/websocket/discord/shard.d.ts +4 -3
- package/lib/websocket/discord/shard.js +47 -24
- package/lib/websocket/discord/sharder.d.ts +9 -6
- package/lib/websocket/discord/sharder.js +92 -17
- package/lib/websocket/discord/shared.d.ts +12 -3
- package/lib/websocket/discord/socket/custom.d.ts +1 -1
- package/lib/websocket/discord/socket/custom.js +70 -40
- package/lib/websocket/discord/worker.d.ts +9 -2
- package/lib/websocket/discord/workermanager.d.ts +42 -16
- package/lib/websocket/discord/workermanager.js +170 -46
- package/lib/websocket/structures/timeout.d.ts +4 -5
- package/lib/websocket/structures/timeout.js +23 -24
- package/package.json +72 -65
- package/lib/cache/resources/threads.d.ts +0 -14
- package/lib/cache/resources/threads.js +0 -32
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { type GatewayDispatchPayload } from '../types';
|
|
2
|
-
import type { Cache } from '../cache';
|
|
3
1
|
import { type DeepPartial, type When } from '../common';
|
|
4
2
|
import { EventHandler } from '../events';
|
|
3
|
+
import { type GatewayDispatchPayload } from '../types';
|
|
5
4
|
import { Shard, type ShardManagerOptions, type WorkerData } from '../websocket';
|
|
6
|
-
import type { WorkerShardInfo } from '../websocket/discord/worker';
|
|
5
|
+
import type { WorkerMessage, WorkerShardInfo } from '../websocket/discord/worker';
|
|
7
6
|
import type { ManagerMessages } from '../websocket/discord/workermanager';
|
|
8
7
|
import type { BaseClientOptions, ServicesOptions, StartOptions } from './base';
|
|
9
8
|
import { BaseClient } from './base';
|
|
10
9
|
import type { Client, ClientOptions } from './client';
|
|
11
|
-
import { Collectors } from './collectors';
|
|
12
|
-
import { type ClientUserStructure } from './transformers';
|
|
13
10
|
import { MemberUpdateHandler } from '../websocket/discord/events/memberUpdate';
|
|
14
11
|
import { PresenceUpdateHandler } from '../websocket/discord/events/presenceUpdate';
|
|
12
|
+
import { Collectors } from './collectors';
|
|
13
|
+
import { type ClientUserStructure } from './transformers';
|
|
15
14
|
export declare class WorkerClient<Ready extends boolean = boolean> extends BaseClient {
|
|
16
15
|
private __handleGuilds?;
|
|
16
|
+
private __handleGuildsResharding?;
|
|
17
17
|
memberUpdateHandler: MemberUpdateHandler;
|
|
18
18
|
presenceUpdateHandler: PresenceUpdateHandler;
|
|
19
19
|
collectors: Collectors;
|
|
@@ -24,32 +24,32 @@ export declare class WorkerClient<Ready extends boolean = boolean> extends BaseC
|
|
|
24
24
|
timeout: NodeJS.Timeout;
|
|
25
25
|
}>;
|
|
26
26
|
shards: Map<number, Shard>;
|
|
27
|
+
resharding: Map<number, Shard>;
|
|
28
|
+
private _ready?;
|
|
27
29
|
private __setServicesCache?;
|
|
28
30
|
options: WorkerClientOptions;
|
|
29
31
|
constructor(options?: WorkerClientOptions);
|
|
30
32
|
get workerId(): number;
|
|
31
33
|
get latency(): number;
|
|
32
|
-
setServices(
|
|
33
|
-
handlers?: ServicesOptions['handlers'] & {
|
|
34
|
-
events?: EventHandler['callback'];
|
|
35
|
-
};
|
|
36
|
-
}): void;
|
|
34
|
+
setServices(rest: ServicesOptions): void;
|
|
37
35
|
setWorkerData(data: WorkerData): void;
|
|
36
|
+
get workerData(): WorkerData;
|
|
38
37
|
start(options?: Omit<DeepPartial<StartOptions>, 'httpConnection' | 'token' | 'connection'>): Promise<void>;
|
|
39
38
|
loadEvents(dir?: string): Promise<void>;
|
|
40
|
-
postMessage(body:
|
|
39
|
+
postMessage(body: WorkerMessage): unknown;
|
|
41
40
|
handleManagerMessages(data: ManagerMessages): Promise<any>;
|
|
42
41
|
private generateNonce;
|
|
43
42
|
private generateSendPromise;
|
|
44
|
-
tellWorker(workerId: number, func: (_: this) =>
|
|
43
|
+
tellWorker(workerId: number, func: (_: this) => any): Promise<unknown>;
|
|
45
44
|
protected onPacket(packet: GatewayDispatchPayload, shardId: number): Promise<void>;
|
|
46
45
|
}
|
|
47
46
|
export declare function generateShardInfo(shard: Shard): WorkerShardInfo;
|
|
48
47
|
interface WorkerClientOptions extends BaseClientOptions {
|
|
49
|
-
disabledCache?: Cache['disabledCache'];
|
|
50
48
|
commands?: NonNullable<Client['options']>['commands'];
|
|
51
49
|
handlePayload?: ShardManagerOptions['handlePayload'];
|
|
52
50
|
gateway?: ClientOptions['gateway'];
|
|
53
51
|
postMessage?: (body: unknown) => unknown;
|
|
52
|
+
/** can have perfomance issues in big bots if the client sends every event, specially in startup (false by default) */
|
|
53
|
+
sendPayloadToParent?: boolean;
|
|
54
54
|
}
|
|
55
55
|
export {};
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WorkerClient = void 0;
|
|
4
4
|
exports.generateShardInfo = generateShardInfo;
|
|
5
|
-
const types_1 = require("../types");
|
|
6
5
|
const node_crypto_1 = require("node:crypto");
|
|
7
6
|
const __1 = require("..");
|
|
8
7
|
const cache_1 = require("../cache");
|
|
9
8
|
const common_1 = require("../common");
|
|
10
9
|
const events_1 = require("../events");
|
|
10
|
+
const types_1 = require("../types");
|
|
11
11
|
const websocket_1 = require("../websocket");
|
|
12
12
|
const base_1 = require("./base");
|
|
13
|
-
const collectors_1 = require("./collectors");
|
|
14
|
-
const transformers_1 = require("./transformers");
|
|
15
13
|
const memberUpdate_1 = require("../websocket/discord/events/memberUpdate");
|
|
16
14
|
const presenceUpdate_1 = require("../websocket/discord/events/presenceUpdate");
|
|
15
|
+
const collectors_1 = require("./collectors");
|
|
16
|
+
const transformers_1 = require("./transformers");
|
|
17
17
|
let workerData;
|
|
18
18
|
let manager;
|
|
19
19
|
try {
|
|
@@ -27,11 +27,15 @@ try {
|
|
|
27
27
|
workerProxy: process.env.SEYFERT_WORKER_WORKERPROXY === 'true',
|
|
28
28
|
totalShards: Number(process.env.SEYFERT_WORKER_TOTALSHARDS),
|
|
29
29
|
mode: process.env.SEYFERT_WORKER_MODE,
|
|
30
|
+
resharding: process.env.SEYFERT_WORKER_RESHARDING === 'true',
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
|
-
catch {
|
|
33
|
+
catch {
|
|
34
|
+
//
|
|
35
|
+
}
|
|
33
36
|
class WorkerClient extends base_1.BaseClient {
|
|
34
37
|
__handleGuilds = new Set();
|
|
38
|
+
__handleGuildsResharding;
|
|
35
39
|
memberUpdateHandler = new memberUpdate_1.MemberUpdateHandler();
|
|
36
40
|
presenceUpdateHandler = new presenceUpdate_1.PresenceUpdateHandler();
|
|
37
41
|
collectors = new collectors_1.Collectors();
|
|
@@ -39,6 +43,8 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
39
43
|
me;
|
|
40
44
|
promises = new Map();
|
|
41
45
|
shards = new Map();
|
|
46
|
+
resharding = new Map();
|
|
47
|
+
_ready;
|
|
42
48
|
__setServicesCache;
|
|
43
49
|
constructor(options) {
|
|
44
50
|
super(options);
|
|
@@ -54,26 +60,18 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
54
60
|
this.shards.forEach(s => (acc += s.latency));
|
|
55
61
|
return acc / this.shards.size;
|
|
56
62
|
}
|
|
57
|
-
setServices(
|
|
63
|
+
setServices(rest) {
|
|
58
64
|
super.setServices(rest);
|
|
59
65
|
if (rest.cache) {
|
|
60
66
|
this.__setServicesCache = true;
|
|
61
67
|
}
|
|
62
|
-
if (rest.handlers && 'events' in rest.handlers) {
|
|
63
|
-
if (!rest.handlers.events) {
|
|
64
|
-
this.events = undefined;
|
|
65
|
-
}
|
|
66
|
-
else if (typeof rest.handlers.events === 'function') {
|
|
67
|
-
this.events = new events_1.EventHandler(this);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
this.events = rest.handlers.events;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
68
|
}
|
|
74
69
|
setWorkerData(data) {
|
|
75
70
|
workerData = data;
|
|
76
71
|
}
|
|
72
|
+
get workerData() {
|
|
73
|
+
return workerData;
|
|
74
|
+
}
|
|
77
75
|
async start(options = {}) {
|
|
78
76
|
const worker_threads = (0, common_1.lazyLoadPackage)('node:worker_threads');
|
|
79
77
|
if (worker_threads?.parentPort) {
|
|
@@ -87,7 +85,7 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
87
85
|
if (this.__setServicesCache) {
|
|
88
86
|
this.setServices({
|
|
89
87
|
cache: {
|
|
90
|
-
disabledCache: this.
|
|
88
|
+
disabledCache: this.cache.disabledCache,
|
|
91
89
|
},
|
|
92
90
|
});
|
|
93
91
|
}
|
|
@@ -99,7 +97,7 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
99
97
|
this.setServices({
|
|
100
98
|
cache: {
|
|
101
99
|
adapter,
|
|
102
|
-
disabledCache: this.
|
|
100
|
+
disabledCache: this.cache.disabledCache,
|
|
103
101
|
},
|
|
104
102
|
});
|
|
105
103
|
}
|
|
@@ -120,9 +118,12 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
120
118
|
});
|
|
121
119
|
}
|
|
122
120
|
this.postMessage({
|
|
123
|
-
type: 'WORKER_START',
|
|
121
|
+
type: workerData.resharding ? 'WORKER_START_RESHARDING' : 'WORKER_START',
|
|
124
122
|
workerId: workerData.workerId,
|
|
125
123
|
});
|
|
124
|
+
if (workerData.resharding) {
|
|
125
|
+
this.__handleGuildsResharding = new Set();
|
|
126
|
+
}
|
|
126
127
|
await super.start(options);
|
|
127
128
|
await this.loadEvents(options.eventsDir);
|
|
128
129
|
this.cache.intents = workerData.intents;
|
|
@@ -166,6 +167,17 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
166
167
|
});
|
|
167
168
|
}
|
|
168
169
|
break;
|
|
170
|
+
case 'ALLOW_CONNECT_RESHARDING':
|
|
171
|
+
{
|
|
172
|
+
const shard = this.resharding.get(data.shardId);
|
|
173
|
+
if (!shard) {
|
|
174
|
+
this.logger.fatal('Worker trying reshard non-existent shard');
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
shard.options.presence = data.presence;
|
|
178
|
+
await shard.connect();
|
|
179
|
+
}
|
|
180
|
+
break;
|
|
169
181
|
case 'ALLOW_CONNECT':
|
|
170
182
|
{
|
|
171
183
|
const shard = this.shards.get(data.shardId);
|
|
@@ -177,37 +189,96 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
177
189
|
await shard.connect();
|
|
178
190
|
}
|
|
179
191
|
break;
|
|
192
|
+
case 'SPAWN_SHARDS_RESHARDING':
|
|
193
|
+
{
|
|
194
|
+
let shardsConnected = 0;
|
|
195
|
+
const self = this;
|
|
196
|
+
for (const id of workerData.shards) {
|
|
197
|
+
const existsShard = this.resharding.has(id);
|
|
198
|
+
if (existsShard) {
|
|
199
|
+
this.logger.warn(`Trying to re-spawn existing shard #${id}`);
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
const shard = new websocket_1.Shard(id, {
|
|
203
|
+
token: workerData.token,
|
|
204
|
+
intents: workerData.intents,
|
|
205
|
+
info: data.info,
|
|
206
|
+
compress: data.compress,
|
|
207
|
+
debugger: this.debugger,
|
|
208
|
+
properties: {
|
|
209
|
+
...websocket_1.properties,
|
|
210
|
+
...this.options.gateway?.properties,
|
|
211
|
+
},
|
|
212
|
+
handlePayload(_, payload) {
|
|
213
|
+
if (payload.t === 'GUILD_CREATE' || payload.t === 'GUILD_DELETE') {
|
|
214
|
+
self.__handleGuildsResharding.delete(payload.d.id);
|
|
215
|
+
if (!self.__handleGuildsResharding?.size && shardsConnected === workerData.shards.length) {
|
|
216
|
+
delete self.__handleGuildsResharding;
|
|
217
|
+
self.postMessage({
|
|
218
|
+
type: 'WORKER_READY_RESHARDING',
|
|
219
|
+
workerId: workerData.workerId,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (payload.t !== 'READY')
|
|
224
|
+
return;
|
|
225
|
+
shardsConnected++;
|
|
226
|
+
for (const guild of payload.d.guilds) {
|
|
227
|
+
self.__handleGuildsResharding.add(guild.id);
|
|
228
|
+
}
|
|
229
|
+
if (shardsConnected === workerData.shards.length &&
|
|
230
|
+
!(0, common_1.hasIntent)(workerData.intents, types_1.GatewayIntentBits.Guilds)) {
|
|
231
|
+
delete self.__handleGuildsResharding;
|
|
232
|
+
self.postMessage({
|
|
233
|
+
type: 'WORKER_READY_RESHARDING',
|
|
234
|
+
workerId: workerData.workerId,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
this.resharding.set(id, shard);
|
|
240
|
+
this.postMessage({
|
|
241
|
+
type: 'CONNECT_QUEUE_RESHARDING',
|
|
242
|
+
shardId: id,
|
|
243
|
+
workerId: workerData.workerId,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
break;
|
|
180
248
|
case 'SPAWN_SHARDS':
|
|
181
249
|
{
|
|
182
250
|
const onPacket = this.onPacket.bind(this);
|
|
183
251
|
const handlePayload = this.options?.handlePayload?.bind(this);
|
|
184
252
|
const self = this;
|
|
185
253
|
for (const id of workerData.shards) {
|
|
186
|
-
|
|
187
|
-
if (
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
254
|
+
const existsShard = this.shards.has(id);
|
|
255
|
+
if (existsShard) {
|
|
256
|
+
this.logger.warn(`Trying to spawn existing shard #${id}`);
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
const shard = new websocket_1.Shard(id, {
|
|
260
|
+
token: workerData.token,
|
|
261
|
+
intents: workerData.intents,
|
|
262
|
+
info: data.info,
|
|
263
|
+
compress: data.compress,
|
|
264
|
+
debugger: this.debugger,
|
|
265
|
+
properties: {
|
|
266
|
+
...websocket_1.properties,
|
|
267
|
+
...this.options.gateway?.properties,
|
|
268
|
+
},
|
|
269
|
+
async handlePayload(shardId, payload) {
|
|
270
|
+
await handlePayload?.(shardId, payload);
|
|
271
|
+
await onPacket(payload, shardId);
|
|
272
|
+
if (self.options.sendPayloadToParent)
|
|
201
273
|
self.postMessage({
|
|
202
274
|
workerId: workerData.workerId,
|
|
203
275
|
shardId,
|
|
204
276
|
type: 'RECEIVE_PAYLOAD',
|
|
205
277
|
payload,
|
|
206
278
|
});
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
279
|
+
},
|
|
280
|
+
});
|
|
281
|
+
this.shards.set(id, shard);
|
|
211
282
|
this.postMessage({
|
|
212
283
|
type: 'CONNECT_QUEUE',
|
|
213
284
|
shardId: id,
|
|
@@ -284,14 +355,47 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
284
355
|
evalResponse.resolve(data.response);
|
|
285
356
|
}
|
|
286
357
|
break;
|
|
358
|
+
case 'WORKER_ALREADY_EXISTS_RESHARDING':
|
|
359
|
+
{
|
|
360
|
+
this.__handleGuildsResharding = new Set();
|
|
361
|
+
this.postMessage({
|
|
362
|
+
type: 'WORKER_START_RESHARDING',
|
|
363
|
+
workerId: workerData.workerId,
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
break;
|
|
367
|
+
case 'DISCONNECT_ALL_SHARDS_RESHARDING':
|
|
368
|
+
{
|
|
369
|
+
for (const i of this.shards.values()) {
|
|
370
|
+
await i.disconnect();
|
|
371
|
+
}
|
|
372
|
+
this.postMessage({
|
|
373
|
+
type: 'DISCONNECTED_ALL_SHARDS_RESHARDING',
|
|
374
|
+
workerId: workerData.workerId,
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
break;
|
|
378
|
+
case 'CONNECT_ALL_SHARDS_RESHARDING':
|
|
379
|
+
{
|
|
380
|
+
this.shards.clear();
|
|
381
|
+
const handlePayload = this.options?.handlePayload?.bind(this);
|
|
382
|
+
for (const [id, shard] of this.resharding) {
|
|
383
|
+
this.shards.set(id, shard);
|
|
384
|
+
shard.options.handlePayload = async (shardId, packet) => {
|
|
385
|
+
await handlePayload?.(shardId, packet);
|
|
386
|
+
return this.onPacket(packet, shardId);
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
this.resharding.clear();
|
|
390
|
+
}
|
|
391
|
+
break;
|
|
287
392
|
}
|
|
288
393
|
}
|
|
289
|
-
generateNonce(
|
|
394
|
+
generateNonce() {
|
|
290
395
|
const uuid = (0, node_crypto_1.randomUUID)();
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
return nonce;
|
|
396
|
+
if (this.promises.has(uuid))
|
|
397
|
+
return this.generateNonce();
|
|
398
|
+
return uuid;
|
|
295
399
|
}
|
|
296
400
|
generateSendPromise(nonce, message = 'Timeout') {
|
|
297
401
|
return new Promise((res, rej) => {
|
|
@@ -342,7 +446,7 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
342
446
|
this.__handleGuilds?.delete(packet.d.id);
|
|
343
447
|
if (!this.__handleGuilds?.size && [...this.shards.values()].every(shard => shard.data.session_id)) {
|
|
344
448
|
delete this.__handleGuilds;
|
|
345
|
-
await this.cache.onPacket
|
|
449
|
+
await this.cache.onPacket(packet);
|
|
346
450
|
this.postMessage({
|
|
347
451
|
type: 'WORKER_READY',
|
|
348
452
|
workerId: this.workerId,
|
|
@@ -351,7 +455,7 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
351
455
|
}
|
|
352
456
|
if (!this.__handleGuilds?.size)
|
|
353
457
|
delete this.__handleGuilds;
|
|
354
|
-
return this.cache.onPacket
|
|
458
|
+
return this.cache.onPacket(packet);
|
|
355
459
|
}
|
|
356
460
|
await this.events?.execute(packet.t, packet, this, shardId);
|
|
357
461
|
break;
|
|
@@ -359,35 +463,48 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
359
463
|
default: {
|
|
360
464
|
switch (packet.t) {
|
|
361
465
|
case 'INTERACTION_CREATE':
|
|
362
|
-
|
|
363
|
-
|
|
466
|
+
{
|
|
467
|
+
await this.events?.execute(packet.t, packet, this, shardId);
|
|
468
|
+
await this.handleCommand.interaction(packet.d, shardId);
|
|
469
|
+
}
|
|
364
470
|
break;
|
|
365
471
|
case 'MESSAGE_CREATE':
|
|
366
|
-
|
|
367
|
-
|
|
472
|
+
{
|
|
473
|
+
await this.events?.execute(packet.t, packet, this, shardId);
|
|
474
|
+
await this.handleCommand.message(packet.d, shardId);
|
|
475
|
+
}
|
|
368
476
|
break;
|
|
369
477
|
case 'READY':
|
|
370
|
-
|
|
371
|
-
this.__handleGuilds
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
(
|
|
381
|
-
|
|
478
|
+
{
|
|
479
|
+
if (!this.__handleGuilds)
|
|
480
|
+
this.__handleGuilds = new Set();
|
|
481
|
+
for (const g of packet.d.guilds) {
|
|
482
|
+
this.__handleGuilds?.add(g.id);
|
|
483
|
+
}
|
|
484
|
+
this.botId = packet.d.user.id;
|
|
485
|
+
this.applicationId = packet.d.application.id;
|
|
486
|
+
this.me = transformers_1.Transformers.ClientUser(this, packet.d.user, packet.d.application);
|
|
487
|
+
await this.events?.execute(packet.t, packet, this, shardId);
|
|
488
|
+
if (!this._ready && [...this.shards.values()].every(shard => shard.data.session_id)) {
|
|
489
|
+
this._ready = true;
|
|
382
490
|
this.postMessage({
|
|
383
|
-
type: '
|
|
491
|
+
type: 'WORKER_SHARDS_CONNECTED',
|
|
384
492
|
workerId: this.workerId,
|
|
385
493
|
});
|
|
386
|
-
await this.events?.runEvent('
|
|
494
|
+
await this.events?.runEvent('WORKER_SHARDS_CONNECTED', this, this.me, -1);
|
|
495
|
+
}
|
|
496
|
+
if (!(0, common_1.hasIntent)(workerData.intents, types_1.GatewayIntentBits.Guilds)) {
|
|
497
|
+
if ([...this.shards.values()].every(shard => shard.data.session_id)) {
|
|
498
|
+
this.postMessage({
|
|
499
|
+
type: 'WORKER_READY',
|
|
500
|
+
workerId: this.workerId,
|
|
501
|
+
});
|
|
502
|
+
await this.events?.runEvent('WORKER_READY', this, this.me, -1);
|
|
503
|
+
}
|
|
504
|
+
delete this.__handleGuilds;
|
|
387
505
|
}
|
|
388
|
-
|
|
506
|
+
this.debugger?.debug(`#${shardId}[${packet.d.user.username}](${this.botId}) is online...`);
|
|
389
507
|
}
|
|
390
|
-
this.debugger?.debug(`#${shardId}[${packet.d.user.username}](${this.botId}) is online...`);
|
|
391
508
|
break;
|
|
392
509
|
default:
|
|
393
510
|
await this.events?.execute(packet.t, packet, this, shardId);
|
package/lib/collection.d.ts
CHANGED
|
@@ -229,9 +229,9 @@ export declare class LimitedCollection<K, V> {
|
|
|
229
229
|
private resetTimeout;
|
|
230
230
|
private stopTimeout;
|
|
231
231
|
private startTimeout;
|
|
232
|
-
keys():
|
|
233
|
-
values():
|
|
234
|
-
entries():
|
|
232
|
+
keys(): MapIterator<K>;
|
|
233
|
+
values(): MapIterator<LimitedCollectionData<V>>;
|
|
234
|
+
entries(): MapIterator<[K, LimitedCollectionData<V>]>;
|
|
235
235
|
clear(): void;
|
|
236
236
|
private clearExpired;
|
|
237
237
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ApplicationCommandOptionType, ApplicationCommandType, type ApplicationIntegrationType, type InteractionContextType, type APIApplicationCommandBasicOption, type APIApplicationCommandOption, type LocaleString } from '../../types';
|
|
2
1
|
import type { PermissionStrings, SeyfertNumberOption, SeyfertStringOption } from '../..';
|
|
3
2
|
import type { Attachment } from '../../builders';
|
|
3
|
+
import type { GuildRoleStructure, InteractionGuildMemberStructure, UserStructure } from '../../client/transformers';
|
|
4
4
|
import { type Awaitable, type FlatObjectKeys } from '../../common';
|
|
5
5
|
import type { AllChannels, AutocompleteInteraction } from '../../structures';
|
|
6
|
+
import { type APIApplicationCommandBasicOption, type APIApplicationCommandOption, ApplicationCommandOptionType, ApplicationCommandType, type ApplicationIntegrationType, type InteractionContextType, type LocaleString } from '../../types';
|
|
6
7
|
import type { Groups, RegisteredMiddlewares } from '../decorators';
|
|
7
8
|
import type { CommandContext } from './chatcontext';
|
|
8
9
|
import type { DefaultLocale, ExtraProps, IgnoreCommand, OKFunction, OnOptionsReturnObject, StopFunction, UsingClient } from './shared';
|
|
9
|
-
import type { GuildRoleStructure, InteractionGuildMemberStructure, UserStructure } from '../../client/transformers';
|
|
10
10
|
export interface ReturnOptionsTypes {
|
|
11
11
|
1: never;
|
|
12
12
|
2: never;
|
|
@@ -150,6 +150,6 @@ export declare abstract class SubCommand extends BaseCommand {
|
|
|
150
150
|
contexts: BaseCommand["contexts"];
|
|
151
151
|
integration_types: BaseCommand["integrationTypes"];
|
|
152
152
|
};
|
|
153
|
-
abstract run(context: CommandContext
|
|
153
|
+
abstract run(context: CommandContext): any;
|
|
154
154
|
}
|
|
155
155
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SubCommand = exports.Command = exports.BaseCommand = void 0;
|
|
4
|
-
const types_1 = require("../../types");
|
|
5
|
-
const common_1 = require("../../common");
|
|
6
4
|
const node_util_1 = require("node:util");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
const types_1 = require("../../types");
|
|
7
7
|
class BaseCommand {
|
|
8
8
|
middlewares = [];
|
|
9
9
|
__filePath;
|
|
@@ -89,13 +89,12 @@ class BaseCommand {
|
|
|
89
89
|
running = false;
|
|
90
90
|
return res({ pass: true });
|
|
91
91
|
};
|
|
92
|
-
function next(
|
|
92
|
+
function next(...args) {
|
|
93
93
|
if (!running) {
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
|
-
if (
|
|
97
|
-
|
|
98
|
-
context[global ? 'globalMetadata' : 'metadata'][middlewares[index]] = obj;
|
|
96
|
+
if (args.length) {
|
|
97
|
+
context[global ? 'globalMetadata' : 'metadata'][middlewares[index]] = args[0];
|
|
99
98
|
}
|
|
100
99
|
if (++index >= middlewares.length) {
|
|
101
100
|
running = false;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { AllChannels, InferWithPrefix,
|
|
1
|
+
import type { AllChannels, InferWithPrefix, ReturnCache } from '../..';
|
|
2
|
+
import type { GuildMemberStructure, GuildStructure, InteractionGuildMemberStructure, MessageStructure, OptionResolverStructure, WebhookMessageStructure } from '../../client/transformers';
|
|
2
3
|
import type { If, UnionToTuple, When } from '../../common';
|
|
3
4
|
import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest } from '../../common/types/write';
|
|
4
5
|
import { ChatInputCommandInteraction } from '../../structures';
|
|
@@ -6,7 +7,6 @@ import { BaseContext } from '../basecontext';
|
|
|
6
7
|
import type { RegisteredMiddlewares } from '../decorators';
|
|
7
8
|
import type { Command, ContextOptions, OptionsRecord, SubCommand } from './chat';
|
|
8
9
|
import type { CommandMetadata, ExtendContext, GlobalMetadata, UsingClient } from './shared';
|
|
9
|
-
import type { GuildMemberStructure, GuildStructure, InteractionGuildMemberStructure, MessageStructure, OptionResolverStructure, WebhookMessageStructure } from '../../client/transformers';
|
|
10
10
|
export interface CommandContext<T extends OptionsRecord = {}, M extends keyof RegisteredMiddlewares = never> extends BaseContext, ExtendContext {
|
|
11
11
|
}
|
|
12
12
|
export declare class CommandContext<T extends OptionsRecord = {}, M extends keyof RegisteredMiddlewares = never> extends BaseContext {
|
|
@@ -26,11 +26,11 @@ export declare class CommandContext<T extends OptionsRecord = {}, M extends keyo
|
|
|
26
26
|
get(locale?: string): import("./shared").DefaultLocale;
|
|
27
27
|
};
|
|
28
28
|
get fullCommandName(): string;
|
|
29
|
-
write<
|
|
30
|
-
deferReply(ephemeral?: boolean): Promise<
|
|
31
|
-
editResponse(body: InteractionMessageUpdateBodyRequest): Promise<
|
|
29
|
+
write<WR extends boolean = false>(body: InteractionCreateBodyRequest, withResponse?: WR): Promise<When<WR, WebhookMessageStructure | When<InferWithPrefix, MessageStructure, never>, void | WebhookMessageStructure | When<InferWithPrefix, MessageStructure, never>>>;
|
|
30
|
+
deferReply<WR extends boolean = false>(ephemeral?: boolean, withResponse?: WR): Promise<When<WR, WebhookMessageStructure | When<InferWithPrefix, MessageStructure, never>, When<InferWithPrefix, MessageStructure, never> | undefined>>;
|
|
31
|
+
editResponse(body: InteractionMessageUpdateBodyRequest): Promise<When<InferWithPrefix, WebhookMessageStructure | MessageStructure, WebhookMessageStructure>>;
|
|
32
32
|
deleteResponse(): Promise<void>;
|
|
33
|
-
editOrReply<
|
|
33
|
+
editOrReply<WR extends boolean = false>(body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest, withResponse?: WR): Promise<When<WR, WebhookMessageStructure | When<InferWithPrefix, MessageStructure, never>, void | WebhookMessageStructure | When<InferWithPrefix, MessageStructure, never>>>;
|
|
34
34
|
fetchResponse(): Promise<If<InferWithPrefix, WebhookMessageStructure | MessageStructure | undefined, WebhookMessageStructure | undefined>>;
|
|
35
35
|
channel(mode?: 'rest' | 'flow'): Promise<If<InferWithPrefix, AllChannels | undefined, AllChannels>>;
|
|
36
36
|
channel(mode?: 'cache'): ReturnCache<If<InferWithPrefix, AllChannels | undefined, AllChannels>>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CommandContext = void 0;
|
|
4
|
-
const types_1 = require("../../types");
|
|
5
4
|
const structures_1 = require("../../structures");
|
|
5
|
+
const types_1 = require("../../types");
|
|
6
6
|
const basecontext_1 = require("../basecontext");
|
|
7
7
|
class CommandContext extends basecontext_1.BaseContext {
|
|
8
8
|
client;
|
|
@@ -37,21 +37,29 @@ class CommandContext extends basecontext_1.BaseContext {
|
|
|
37
37
|
get fullCommandName() {
|
|
38
38
|
return this.resolver.fullCommandName;
|
|
39
39
|
}
|
|
40
|
-
async write(body,
|
|
40
|
+
async write(body, withResponse) {
|
|
41
41
|
if (this.interaction)
|
|
42
|
-
return this.interaction.write(body,
|
|
42
|
+
return this.interaction.write(body, withResponse);
|
|
43
43
|
const options = this.client.options?.commands;
|
|
44
44
|
return (this.messageResponse = await this.message[!this.messageResponse && options?.reply?.(this) ? 'reply' : 'write'](body));
|
|
45
45
|
}
|
|
46
|
-
async deferReply(ephemeral = false) {
|
|
46
|
+
async deferReply(ephemeral = false, withResponse) {
|
|
47
47
|
if (this.interaction)
|
|
48
|
-
return this.interaction.deferReply(ephemeral ? types_1.MessageFlags.Ephemeral : undefined);
|
|
48
|
+
return this.interaction.deferReply(ephemeral ? types_1.MessageFlags.Ephemeral : undefined, withResponse);
|
|
49
|
+
this.__deferred = true;
|
|
49
50
|
const options = this.client.options?.commands;
|
|
50
51
|
return (this.messageResponse = await this.message[options?.reply?.(this) ? 'reply' : 'write'](options?.deferReplyResponse?.(this) ?? { content: 'Thinking...' }));
|
|
51
52
|
}
|
|
52
53
|
async editResponse(body) {
|
|
53
54
|
if (this.interaction)
|
|
54
55
|
return this.interaction.editResponse(body);
|
|
56
|
+
if (this.__deferred && !this.__edited) {
|
|
57
|
+
this.__edited = true;
|
|
58
|
+
if (this.messageResponse?.content)
|
|
59
|
+
body.content ??= '';
|
|
60
|
+
if (this.messageResponse?.embeds.length)
|
|
61
|
+
body.embeds ??= [];
|
|
62
|
+
}
|
|
55
63
|
return (this.messageResponse = await this.messageResponse.edit(body));
|
|
56
64
|
}
|
|
57
65
|
deleteResponse() {
|
|
@@ -59,13 +67,13 @@ class CommandContext extends basecontext_1.BaseContext {
|
|
|
59
67
|
return this.interaction.deleteResponse();
|
|
60
68
|
return this.messageResponse.delete();
|
|
61
69
|
}
|
|
62
|
-
editOrReply(body,
|
|
70
|
+
editOrReply(body, withResponse) {
|
|
63
71
|
if (this.interaction)
|
|
64
|
-
return this.interaction.editOrReply(body,
|
|
72
|
+
return this.interaction.editOrReply(body, withResponse);
|
|
65
73
|
if (this.messageResponse) {
|
|
66
74
|
return this.editResponse(body);
|
|
67
75
|
}
|
|
68
|
-
return this.write(body,
|
|
76
|
+
return this.write(body, withResponse);
|
|
69
77
|
}
|
|
70
78
|
async fetchResponse() {
|
|
71
79
|
if (this.interaction)
|