seyfert 1.2.1 → 1.2.2
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/cache/index.d.ts +1 -5
- package/lib/cache/resources/voice-states.d.ts +7 -2
- package/lib/cache/resources/voice-states.js +11 -0
- package/lib/client/http/adapters/bun.d.ts +14 -0
- package/lib/client/http/adapters/bun.js +117 -0
- package/lib/client/http/adapters/index.d.ts +15 -0
- package/lib/client/http/adapters/index.js +27 -0
- package/lib/client/http/adapters/uws.d.ts +17 -0
- package/lib/client/http/adapters/uws.js +142 -0
- package/lib/client/http/httpclient.d.ts +13 -0
- package/lib/client/http/httpclient.js +48 -0
- package/lib/client/oninteractioncreate.js +7 -7
- package/lib/client/onmessagecreate.js +12 -3
- package/lib/client/workerclient.js +1 -1
- package/lib/commands/applications/chat.d.ts +11 -9
- package/lib/commands/applications/chat.js +9 -6
- package/lib/commands/applications/chatcontext.d.ts +2 -1
- package/lib/commands/applications/chatcontext.js +3 -0
- package/lib/commands/applications/menu.d.ts +4 -3
- package/lib/commands/applications/menu.js +9 -6
- package/lib/commands/applications/menucontext.d.ts +4 -1
- package/lib/commands/applications/menucontext.js +9 -0
- package/lib/commands/basecontex.d.ts +1 -1
- package/lib/commands/basecontex.js +5 -11
- package/lib/commands/decorators.d.ts +3 -3
- package/lib/commands/decorators.js +5 -5
- package/lib/commands/handler.js +2 -0
- package/lib/common/shorters/channels.d.ts +9 -2
- package/lib/common/shorters/channels.js +13 -0
- package/lib/common/shorters/members.d.ts +6 -0
- package/lib/common/shorters/members.js +6 -0
- package/lib/common/shorters/messages.d.ts +2 -2
- package/lib/common/shorters/messages.js +7 -3
- package/lib/components/componentcontext.d.ts +1 -0
- package/lib/components/componentcontext.js +3 -0
- package/lib/structures/GuildMember.d.ts +1 -5
- package/lib/structures/GuildMember.js +2 -2
- package/lib/structures/Message.d.ts +1 -1
- package/lib/structures/User.js +1 -1
- package/lib/structures/VoiceState.d.ts +18 -0
- package/lib/structures/VoiceState.js +48 -0
- package/lib/structures/channels.d.ts +6 -3
- package/lib/structures/channels.js +14 -1
- package/lib/structures/extra/Permissions.d.ts +1 -1
- package/lib/structures/index.d.ts +1 -0
- package/lib/structures/index.js +1 -0
- package/lib/websocket/discord/shard.d.ts +4 -4
- package/lib/websocket/discord/shard.js +12 -17
- package/lib/websocket/discord/sharder.d.ts +1 -1
- package/lib/websocket/discord/sharder.js +2 -2
- package/lib/websocket/discord/workermanager.js +1 -1
- package/lib/websocket/structures/index.d.ts +6 -99
- package/lib/websocket/structures/index.js +29 -211
- package/lib/websocket/structures/timeout.d.ts +2 -2
- package/lib/websocket/structures/timeout.js +4 -4
- package/package.json +2 -2
|
@@ -29,7 +29,7 @@ export declare class CommandContext<T extends OptionsRecord = {}, M extends keyo
|
|
|
29
29
|
write<FR extends boolean = false>(body: InteractionCreateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessage | Message, void | WebhookMessage | Message>>;
|
|
30
30
|
deferReply(ephemeral?: boolean): Promise<void | Message>;
|
|
31
31
|
editResponse(body: InteractionMessageUpdateBodyRequest): Promise<Message>;
|
|
32
|
-
deleteResponse(): Promise<void
|
|
32
|
+
deleteResponse(): Promise<void>;
|
|
33
33
|
editOrReply<FR extends boolean = false>(body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessage | Message, void | WebhookMessage | Message>>;
|
|
34
34
|
fetchResponse(): Promise<If<InferWithPrefix, WebhookMessage | Message | undefined, WebhookMessage | undefined>>;
|
|
35
35
|
channel(mode?: 'rest' | 'flow'): Promise<If<InferWithPrefix, AllChannels | undefined, AllChannels>>;
|
|
@@ -42,4 +42,5 @@ export declare class CommandContext<T extends OptionsRecord = {}, M extends keyo
|
|
|
42
42
|
get channelId(): string;
|
|
43
43
|
get author(): import("../..").User;
|
|
44
44
|
get member(): If<InferWithPrefix, GuildMember | InteractionGuildMember | undefined, InteractionGuildMember | undefined>;
|
|
45
|
+
isChat(): this is CommandContext;
|
|
45
46
|
}
|
|
@@ -10,14 +10,14 @@ export declare abstract class ContextMenuCommand {
|
|
|
10
10
|
name: string | undefined;
|
|
11
11
|
description: string | undefined;
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
guildId?: string[];
|
|
14
14
|
name: string;
|
|
15
15
|
type: ApplicationCommandType.User | ApplicationCommandType.Message;
|
|
16
16
|
nsfw?: boolean;
|
|
17
|
-
|
|
17
|
+
integrationTypes?: IntegrationTypes[];
|
|
18
18
|
contexts?: InteractionContextTypes[];
|
|
19
19
|
description: string;
|
|
20
|
-
|
|
20
|
+
defaultMemberPermissions?: bigint;
|
|
21
21
|
botPermissions?: bigint;
|
|
22
22
|
dm?: boolean;
|
|
23
23
|
name_localizations?: Partial<Record<LocaleString, string>>;
|
|
@@ -40,6 +40,7 @@ export declare abstract class ContextMenuCommand {
|
|
|
40
40
|
onAfterRun?(context: MenuCommandContext<any>, error: unknown | undefined): any;
|
|
41
41
|
onRunError(context: MenuCommandContext<any, never>, error: unknown): any;
|
|
42
42
|
onMiddlewaresError(context: MenuCommandContext<any, never>, error: string): any;
|
|
43
|
+
onBotPermissionsFail(context: MenuCommandContext<any, never>, permissions: PermissionStrings): any;
|
|
43
44
|
onPermissionsFail(context: MenuCommandContext<any, never>, permissions: PermissionStrings): any;
|
|
44
45
|
onInternalError(client: UsingClient, error?: unknown): any;
|
|
45
46
|
}
|
|
@@ -6,14 +6,14 @@ class ContextMenuCommand {
|
|
|
6
6
|
middlewares = [];
|
|
7
7
|
__filePath;
|
|
8
8
|
__t;
|
|
9
|
-
|
|
9
|
+
guildId;
|
|
10
10
|
name;
|
|
11
11
|
type;
|
|
12
12
|
nsfw;
|
|
13
|
-
|
|
13
|
+
integrationTypes;
|
|
14
14
|
contexts;
|
|
15
15
|
description;
|
|
16
|
-
|
|
16
|
+
defaultMemberPermissions;
|
|
17
17
|
botPermissions;
|
|
18
18
|
dm;
|
|
19
19
|
name_localizations;
|
|
@@ -74,11 +74,11 @@ class ContextMenuCommand {
|
|
|
74
74
|
description: this.description,
|
|
75
75
|
name_localizations: this.name_localizations,
|
|
76
76
|
description_localizations: this.description_localizations,
|
|
77
|
-
guild_id: this.
|
|
77
|
+
guild_id: this.guildId,
|
|
78
78
|
dm_permission: this.dm,
|
|
79
|
-
default_member_permissions: this.
|
|
79
|
+
default_member_permissions: this.defaultMemberPermissions ? this.defaultMemberPermissions.toString() : undefined,
|
|
80
80
|
contexts: this.contexts,
|
|
81
|
-
integration_types: this.
|
|
81
|
+
integration_types: this.integrationTypes,
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
async reload() {
|
|
@@ -92,6 +92,9 @@ class ContextMenuCommand {
|
|
|
92
92
|
onMiddlewaresError(context, error) {
|
|
93
93
|
context.client.logger.fatal(`${this.name}.<onMiddlewaresError>`, context.author.id, error);
|
|
94
94
|
}
|
|
95
|
+
onBotPermissionsFail(context, permissions) {
|
|
96
|
+
context.client.logger.fatal(`${this.name}.<onBotPermissionsFail>`, context.author.id, permissions);
|
|
97
|
+
}
|
|
95
98
|
onPermissionsFail(context, permissions) {
|
|
96
99
|
context.client.logger.fatal(`${this.name}.<onPermissionsFail>`, context.author.id, permissions);
|
|
97
100
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ContextMenuCommand, ReturnCache, WebhookMessage } from '../..';
|
|
2
|
-
import { type InteractionCreateBodyRequest, type InteractionMessageUpdateBodyRequest, type
|
|
2
|
+
import { type InteractionCreateBodyRequest, type InteractionMessageUpdateBodyRequest, type ModalCreateBodyRequest, type UnionToTuple, type When } from '../../common';
|
|
3
3
|
import { Message, User, type AllChannels, type Guild, type GuildMember, type MessageCommandInteraction, type UserCommandInteraction } from '../../structures';
|
|
4
4
|
import { BaseContext } from '../basecontex';
|
|
5
5
|
import type { RegisteredMiddlewares } from '../decorators';
|
|
@@ -37,4 +37,7 @@ export declare class MenuCommandContext<T extends MessageCommandInteraction | Us
|
|
|
37
37
|
get channelId(): string;
|
|
38
38
|
get author(): User;
|
|
39
39
|
get member(): import("../..").InteractionGuildMember | undefined;
|
|
40
|
+
isMenu(): this is MenuCommandContext<UserCommandInteraction | MessageCommandInteraction>;
|
|
41
|
+
isMenuUser(): this is MenuCommandContext<UserCommandInteraction>;
|
|
42
|
+
isMenuMessage(): this is MenuCommandContext<MessageCommandInteraction>;
|
|
40
43
|
}
|
|
@@ -96,5 +96,14 @@ class MenuCommandContext extends basecontex_1.BaseContext {
|
|
|
96
96
|
get member() {
|
|
97
97
|
return this.interaction.member;
|
|
98
98
|
}
|
|
99
|
+
isMenu() {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
isMenuUser() {
|
|
103
|
+
return this.target instanceof structures_1.User;
|
|
104
|
+
}
|
|
105
|
+
isMenuMessage() {
|
|
106
|
+
return this.target instanceof structures_1.Message;
|
|
107
|
+
}
|
|
99
108
|
}
|
|
100
109
|
exports.MenuCommandContext = MenuCommandContext;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentCommandInteractionMap, ComponentContext } from '../components/componentcontext';
|
|
2
|
-
import {
|
|
2
|
+
import type { MessageCommandInteraction, UserCommandInteraction } from '../structures';
|
|
3
3
|
import type { CommandContext } from './applications/chatcontext';
|
|
4
4
|
import type { MenuCommandContext } from './applications/menucontext';
|
|
5
5
|
import type { UsingClient } from './applications/shared';
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseContext = void 0;
|
|
4
|
-
const v10_1 = require("discord-api-types/v10");
|
|
5
|
-
const structures_1 = require("../structures");
|
|
6
4
|
class BaseContext {
|
|
7
5
|
client;
|
|
8
6
|
constructor(client) {
|
|
@@ -12,23 +10,19 @@ class BaseContext {
|
|
|
12
10
|
return this.client.proxy;
|
|
13
11
|
}
|
|
14
12
|
isChat() {
|
|
15
|
-
|
|
16
|
-
return this.message || this.interaction.type === v10_1.ApplicationCommandType.ChatInput;
|
|
13
|
+
return false;
|
|
17
14
|
}
|
|
18
15
|
isMenu() {
|
|
19
|
-
return
|
|
16
|
+
return false;
|
|
20
17
|
}
|
|
21
18
|
isMenuUser() {
|
|
22
|
-
|
|
23
|
-
return this.target instanceof structures_1.User;
|
|
19
|
+
return false;
|
|
24
20
|
}
|
|
25
21
|
isMenuMessage() {
|
|
26
|
-
|
|
27
|
-
return this.target instanceof structures_1.Message;
|
|
22
|
+
return false;
|
|
28
23
|
}
|
|
29
24
|
isComponent() {
|
|
30
|
-
|
|
31
|
-
return this.interaction.type === v10_1.InteractionType.MessageComponent;
|
|
25
|
+
return false;
|
|
32
26
|
}
|
|
33
27
|
}
|
|
34
28
|
exports.BaseContext = BaseContext;
|
|
@@ -109,12 +109,12 @@ export declare function Declare(declare: DeclareOptions): <T extends new (...arg
|
|
|
109
109
|
name: string;
|
|
110
110
|
nsfw: boolean | undefined;
|
|
111
111
|
contexts: InteractionContextTypes[] | undefined;
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
integrationTypes: IntegrationTypes[] | undefined;
|
|
113
|
+
defaultMemberPermissions: bigint | undefined;
|
|
114
114
|
botPermissions: bigint | undefined;
|
|
115
115
|
description: string;
|
|
116
116
|
type: ApplicationCommandType;
|
|
117
|
-
|
|
117
|
+
guildId?: string[] | undefined;
|
|
118
118
|
};
|
|
119
119
|
} & T;
|
|
120
120
|
export {};
|
|
@@ -74,16 +74,16 @@ function Declare(declare) {
|
|
|
74
74
|
name = declare.name;
|
|
75
75
|
nsfw = declare.nsfw;
|
|
76
76
|
contexts = declare.contexts?.map(i => InteractionContextTypes[i]);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
? declare.defaultMemberPermissions?.reduce((acc, prev) => acc | v10_1.PermissionFlagsBits[prev], BigInt(0))
|
|
77
|
+
integrationTypes = declare.integrationTypes?.map(i => IntegrationTypes[i]);
|
|
78
|
+
defaultMemberPermissions = Array.isArray(declare.defaultMemberPermissions)
|
|
79
|
+
? declare.defaultMemberPermissions?.reduce((acc, prev) => acc | v10_1.PermissionFlagsBits[prev], BigInt(0))
|
|
80
80
|
: declare.defaultMemberPermissions;
|
|
81
81
|
botPermissions = Array.isArray(declare.botPermissions)
|
|
82
82
|
? declare.botPermissions?.reduce((acc, prev) => acc | v10_1.PermissionFlagsBits[prev], BigInt(0))
|
|
83
83
|
: declare.botPermissions;
|
|
84
84
|
description = '';
|
|
85
85
|
type = v10_1.ApplicationCommandType.ChatInput;
|
|
86
|
-
|
|
86
|
+
guildId;
|
|
87
87
|
constructor(...args) {
|
|
88
88
|
super(...args);
|
|
89
89
|
if ('description' in declare)
|
|
@@ -91,7 +91,7 @@ function Declare(declare) {
|
|
|
91
91
|
if ('type' in declare)
|
|
92
92
|
this.type = declare.type;
|
|
93
93
|
if ('guildId' in declare)
|
|
94
|
-
this.
|
|
94
|
+
this.guildId = declare.guildId;
|
|
95
95
|
// check if all properties are valid
|
|
96
96
|
}
|
|
97
97
|
};
|
package/lib/commands/handler.js
CHANGED
|
@@ -96,6 +96,8 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
96
96
|
option.onInternalError =
|
|
97
97
|
option.onInternalError?.bind(option) ?? commandInstance.onInternalError?.bind(commandInstance);
|
|
98
98
|
option.onAfterRun = option.onAfterRun?.bind(option) ?? commandInstance.onAfterRun?.bind(commandInstance);
|
|
99
|
+
option.onBotPermissionsFail =
|
|
100
|
+
option.onBotPermissionsFail?.bind(option) ?? commandInstance.onBotPermissionsFail?.bind(commandInstance);
|
|
99
101
|
option.onPermissionsFail =
|
|
100
102
|
option.onPermissionsFail?.bind(option) ?? commandInstance.onPermissionsFail?.bind(commandInstance);
|
|
101
103
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type RESTPatchAPIChannelJSONBody } from 'discord-api-types/v10';
|
|
1
|
+
import { type RESTPatchAPIChannelJSONBody, type RESTPostAPIChannelThreadsJSONBody, type RESTPostAPIGuildForumThreadsJSONBody } from 'discord-api-types/v10';
|
|
2
2
|
import { Message, type GuildMember, type GuildRole } from '../../structures';
|
|
3
|
-
import { type AllChannels } from '../../structures/channels';
|
|
3
|
+
import { type AllChannels, type ThreadChannel } from '../../structures/channels';
|
|
4
4
|
import { PermissionsBitField } from '../../structures/extra/Permissions';
|
|
5
5
|
import { BaseShorter } from './base';
|
|
6
6
|
export declare class ChannelShorter extends BaseShorter {
|
|
@@ -49,6 +49,13 @@ export declare class ChannelShorter extends BaseShorter {
|
|
|
49
49
|
* @returns A Promise that resolves when the message is successfully unpinned.
|
|
50
50
|
*/
|
|
51
51
|
deletePin(messageId: string, channelId: string, reason?: string): Promise<never>;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a new thread in the channel (only guild based channels).
|
|
54
|
+
* @param channelId The ID of the parent channel.
|
|
55
|
+
* @param reason The reason for unpinning the message.
|
|
56
|
+
* @returns A promise that resolves when the thread is succesfully created.
|
|
57
|
+
*/
|
|
58
|
+
thread(channelId: string, body: RESTPostAPIChannelThreadsJSONBody | RESTPostAPIGuildForumThreadsJSONBody, reason?: string): Promise<ThreadChannel>;
|
|
52
59
|
memberPermissions(channelId: string, member: GuildMember, checkAdmin?: boolean): Promise<PermissionsBitField>;
|
|
53
60
|
overwritesFor(channelId: string, member: GuildMember): Promise<{
|
|
54
61
|
everyone: {
|
|
@@ -84,6 +84,19 @@ class ChannelShorter extends base_1.BaseShorter {
|
|
|
84
84
|
deletePin(messageId, channelId, reason) {
|
|
85
85
|
return this.client.proxy.channels(channelId).pins(messageId).delete({ reason });
|
|
86
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Creates a new thread in the channel (only guild based channels).
|
|
89
|
+
* @param channelId The ID of the parent channel.
|
|
90
|
+
* @param reason The reason for unpinning the message.
|
|
91
|
+
* @returns A promise that resolves when the thread is succesfully created.
|
|
92
|
+
*/
|
|
93
|
+
async thread(channelId, body, reason) {
|
|
94
|
+
return (this.client.proxy
|
|
95
|
+
.channels(channelId)
|
|
96
|
+
.threads.post({ body, reason })
|
|
97
|
+
// When testing this, discord returns the thread object, but in discord api types it does not.
|
|
98
|
+
.then(thread => (0, channels_1.default)(thread, this.client)));
|
|
99
|
+
}
|
|
87
100
|
async memberPermissions(channelId, member, checkAdmin = true) {
|
|
88
101
|
const permissions = await member.fetchPermissions();
|
|
89
102
|
if (checkAdmin && permissions.has(v10_1.PermissionFlagsBits.Administrator)) {
|
|
@@ -91,4 +91,10 @@ export declare class MemberShorter extends BaseShorter {
|
|
|
91
91
|
listRoles(guildId: string, memberId: string, force?: boolean): Promise<import("../../structures").GuildRole[]>;
|
|
92
92
|
sortRoles(guildId: string, memberId: string, force?: boolean): Promise<import("../../structures").GuildRole[]>;
|
|
93
93
|
permissions(guildId: string, memberId: string, force?: boolean): Promise<PermissionsBitField>;
|
|
94
|
+
presence(memberId: string): import("../..").ReturnCache<(Omit<import("discord-api-types/v10").GatewayPresenceUpdate, "user"> & {
|
|
95
|
+
id: string;
|
|
96
|
+
} & {
|
|
97
|
+
guild_id: string;
|
|
98
|
+
}) | undefined>;
|
|
99
|
+
voice(guildId: string, memberId: string): import("../..").ReturnCache<import("../../structures").VoiceState | undefined>;
|
|
94
100
|
}
|
|
@@ -183,5 +183,11 @@ class MemberShorter extends base_1.BaseShorter {
|
|
|
183
183
|
const roles = await this.listRoles(guildId, memberId, force);
|
|
184
184
|
return new Permissions_1.PermissionsBitField(roles.map(x => BigInt(x.permissions.bits)));
|
|
185
185
|
}
|
|
186
|
+
presence(memberId) {
|
|
187
|
+
return this.client.cache.presences?.get(memberId);
|
|
188
|
+
}
|
|
189
|
+
voice(guildId, memberId) {
|
|
190
|
+
return this.client.cache.voiceStates?.get(memberId, guildId);
|
|
191
|
+
}
|
|
186
192
|
}
|
|
187
193
|
exports.MemberShorter = MemberShorter;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { RESTPostAPIChannelMessagesThreadsJSONBody } from 'discord-api-types/v10';
|
|
2
|
-
import { Message, ThreadChannel } from '../../structures';
|
|
2
|
+
import { Message, type ThreadChannel } from '../../structures';
|
|
3
3
|
import type { MessageCreateBodyRequest, MessageUpdateBodyRequest } from '../types/write';
|
|
4
4
|
import { BaseShorter } from './base';
|
|
5
5
|
export declare class MessageShorter extends BaseShorter {
|
|
6
6
|
write(channelId: string, { files, ...body }: MessageCreateBodyRequest): Promise<Message>;
|
|
7
7
|
edit(messageId: string, channelId: string, { files, ...body }: MessageUpdateBodyRequest): Promise<Message>;
|
|
8
8
|
crosspost(messageId: string, channelId: string, reason?: string): Promise<Message>;
|
|
9
|
-
delete(messageId: string, channelId: string, reason?: string): Promise<void
|
|
9
|
+
delete(messageId: string, channelId: string, reason?: string): Promise<void>;
|
|
10
10
|
fetch(messageId: string, channelId: string): Promise<Message>;
|
|
11
11
|
purge(messages: string[], channelId: string, reason?: string): Promise<never>;
|
|
12
12
|
thread(channelId: string, messageId: string, options: RESTPostAPIChannelMessagesThreadsJSONBody & {
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.MessageShorter = void 0;
|
|
4
7
|
const builders_1 = require("../../builders");
|
|
5
8
|
const structures_1 = require("../../structures");
|
|
9
|
+
const channels_1 = __importDefault(require("../../structures/channels"));
|
|
6
10
|
const base_1 = require("./base");
|
|
7
11
|
class MessageShorter extends base_1.BaseShorter {
|
|
8
12
|
async write(channelId, { files, ...body }) {
|
|
@@ -44,7 +48,7 @@ class MessageShorter extends base_1.BaseShorter {
|
|
|
44
48
|
.messages(messageId)
|
|
45
49
|
.delete({ reason })
|
|
46
50
|
.then(() => {
|
|
47
|
-
|
|
51
|
+
void this.client.components?.onMessageDelete(messageId);
|
|
48
52
|
});
|
|
49
53
|
}
|
|
50
54
|
fetch(messageId, channelId) {
|
|
@@ -57,13 +61,13 @@ class MessageShorter extends base_1.BaseShorter {
|
|
|
57
61
|
purge(messages, channelId, reason) {
|
|
58
62
|
return this.client.proxy.channels(channelId).messages['bulk-delete'].post({ body: { messages }, reason });
|
|
59
63
|
}
|
|
60
|
-
thread(channelId, messageId, options) {
|
|
64
|
+
async thread(channelId, messageId, options) {
|
|
61
65
|
const { reason, ...body } = options;
|
|
62
66
|
return this.client.proxy
|
|
63
67
|
.channels(channelId)
|
|
64
68
|
.messages(messageId)
|
|
65
69
|
.threads.post({ body, reason })
|
|
66
|
-
.then(
|
|
70
|
+
.then(thread => (0, channels_1.default)(thread, this.client));
|
|
67
71
|
}
|
|
68
72
|
}
|
|
69
73
|
exports.MessageShorter = MessageShorter;
|
|
@@ -100,6 +100,7 @@ export declare class ComponentContext<Type extends keyof ComponentCommandInterac
|
|
|
100
100
|
* Gets the member of the interaction.
|
|
101
101
|
*/
|
|
102
102
|
get member(): import("..").InteractionGuildMember | undefined;
|
|
103
|
+
isComponent(): this is ComponentContext<keyof ComponentCommandInteractionMap>;
|
|
103
104
|
}
|
|
104
105
|
export interface ComponentCommandInteractionMap {
|
|
105
106
|
ActionRow: never;
|
|
@@ -31,11 +31,7 @@ export declare class BaseGuildMember extends DiscordBase {
|
|
|
31
31
|
} & {
|
|
32
32
|
guild_id: string;
|
|
33
33
|
}) | undefined>;
|
|
34
|
-
voice(): import("..").ReturnCache<
|
|
35
|
-
guild_id: string;
|
|
36
|
-
} & {
|
|
37
|
-
guild_id: string;
|
|
38
|
-
}) | undefined>;
|
|
34
|
+
voice(): import("..").ReturnCache<import("./VoiceState").VoiceState | undefined>;
|
|
39
35
|
toString(): string;
|
|
40
36
|
private patch;
|
|
41
37
|
get roles(): {
|
|
@@ -34,10 +34,10 @@ class BaseGuildMember extends DiscordBase_1.DiscordBase {
|
|
|
34
34
|
return this.client.members.edit(this.guildId, this.id, body, reason);
|
|
35
35
|
}
|
|
36
36
|
presence() {
|
|
37
|
-
return this.
|
|
37
|
+
return this.client.members.presence(this.id);
|
|
38
38
|
}
|
|
39
39
|
voice() {
|
|
40
|
-
return this.
|
|
40
|
+
return this.client.members.voice(this.guildId, this.id);
|
|
41
41
|
}
|
|
42
42
|
toString() {
|
|
43
43
|
return `<@${this.id}>`;
|
|
@@ -44,7 +44,7 @@ export declare class Message extends BaseMessage {
|
|
|
44
44
|
reply(body: Omit<MessageCreateBodyRequest, 'message_reference'>, fail?: boolean): Promise<Message>;
|
|
45
45
|
edit(body: MessageUpdateBodyRequest): Promise<Message>;
|
|
46
46
|
write(body: MessageCreateBodyRequest): Promise<Message>;
|
|
47
|
-
delete(reason?: string): Promise<void
|
|
47
|
+
delete(reason?: string): Promise<void>;
|
|
48
48
|
crosspost(reason?: string): Promise<Message>;
|
|
49
49
|
}
|
|
50
50
|
export type EditMessageWebhook = Omit<MessageWebhookMethodEditParams, 'messageId'>;
|
package/lib/structures/User.js
CHANGED
|
@@ -37,7 +37,7 @@ class User extends DiscordBase_1.DiscordBase {
|
|
|
37
37
|
return this.rest.cdn.banner(this.id, this.banner, options);
|
|
38
38
|
}
|
|
39
39
|
presence() {
|
|
40
|
-
return this.
|
|
40
|
+
return this.client.members.presence(this.id);
|
|
41
41
|
}
|
|
42
42
|
toString() {
|
|
43
43
|
return `<@${this.id}>`;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { GuildMember, UsingClient } from '../';
|
|
2
|
+
import type { VoiceStateResource } from '../cache/resources/voice-states';
|
|
3
|
+
import type { ObjectToLower } from '../common';
|
|
4
|
+
import { Base } from './extra/Base';
|
|
5
|
+
export interface VoiceState extends Base, ObjectToLower<VoiceStateResource> {
|
|
6
|
+
}
|
|
7
|
+
export declare class VoiceState extends Base {
|
|
8
|
+
private withMember?;
|
|
9
|
+
constructor(client: UsingClient, data: VoiceStateResource, withMember?: GuildMember | undefined);
|
|
10
|
+
isMuted(): boolean;
|
|
11
|
+
member(force?: boolean): Promise<GuildMember>;
|
|
12
|
+
user(force?: boolean): Promise<import("./User").User>;
|
|
13
|
+
channel(force?: boolean): Promise<import("./channels").BaseChannel<import("discord-api-types/v10").ChannelType> | import("./channels").DMChannel | import("./channels").CategoryChannel | undefined>;
|
|
14
|
+
setMute(mute?: boolean, reason?: string): Promise<GuildMember>;
|
|
15
|
+
setDeaf(deaf?: boolean, reason?: string): Promise<GuildMember>;
|
|
16
|
+
disconnect(reason?: string): Promise<GuildMember>;
|
|
17
|
+
setChannel(channel_id: null | string, reason?: string): Promise<GuildMember>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VoiceState = void 0;
|
|
4
|
+
const Base_1 = require("./extra/Base");
|
|
5
|
+
class VoiceState extends Base_1.Base {
|
|
6
|
+
withMember;
|
|
7
|
+
constructor(client, data, withMember) {
|
|
8
|
+
super(client);
|
|
9
|
+
this.withMember = withMember;
|
|
10
|
+
this.__patchThis(data);
|
|
11
|
+
}
|
|
12
|
+
isMuted() {
|
|
13
|
+
return this.mute || this.selfMute;
|
|
14
|
+
}
|
|
15
|
+
async member(force) {
|
|
16
|
+
return (this.withMember ??= await this.client.members.fetch(this.guildId, this.userId, force));
|
|
17
|
+
}
|
|
18
|
+
async user(force) {
|
|
19
|
+
return this.client.users.fetch(this.userId, force);
|
|
20
|
+
}
|
|
21
|
+
async channel(force) {
|
|
22
|
+
if (!this.channelId)
|
|
23
|
+
return;
|
|
24
|
+
return this.client.channels.fetch(this.channelId, force);
|
|
25
|
+
}
|
|
26
|
+
async setMute(mute = !this.mute, reason) {
|
|
27
|
+
return this.client.members.edit(this.guildId, this.userId, { mute }, reason).then(member => {
|
|
28
|
+
this.mute = mute;
|
|
29
|
+
return member;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async setDeaf(deaf = !this.deaf, reason) {
|
|
33
|
+
return this.client.members.edit(this.guildId, this.userId, { deaf }, reason).then(member => {
|
|
34
|
+
this.deaf = deaf;
|
|
35
|
+
return member;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async disconnect(reason) {
|
|
39
|
+
return this.setChannel(null, reason);
|
|
40
|
+
}
|
|
41
|
+
async setChannel(channel_id, reason) {
|
|
42
|
+
return this.client.members.edit(this.guildId, this.userId, { channel_id }, reason).then(member => {
|
|
43
|
+
this.channelId = channel_id;
|
|
44
|
+
return member;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.VoiceState = VoiceState;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type APIChannelBase, type
|
|
1
|
+
import { ChannelType, VideoQualityMode, type APIChannelBase, type APIDMChannel, type APIGuildCategoryChannel, type APIGuildChannel, type APIGuildForumChannel, type APIGuildForumDefaultReactionEmoji, type APIGuildForumTag, type APIGuildMediaChannel, type APIGuildStageVoiceChannel, type APIGuildVoiceChannel, type APINewsChannel, type APITextChannel, type APIThreadChannel, type RESTGetAPIChannelMessageReactionUsersQuery, type RESTPatchAPIChannelJSONBody, type RESTPatchAPIGuildChannelPositionsJSONBody, type RESTPostAPIChannelWebhookJSONBody, type RESTPostAPIGuildChannelJSONBody, type RESTPostAPIGuildForumThreadsJSONBody, type SortOrderType, type ThreadAutoArchiveDuration } from 'discord-api-types/v10';
|
|
2
2
|
import type { UsingClient } from '../commands';
|
|
3
3
|
import type { EmojiResolvable, MessageCreateBodyRequest, MessageUpdateBodyRequest, MethodContext, ObjectToLower, StringToNumber, ToClass } from '../common';
|
|
4
4
|
import type { GuildMember } from './GuildMember';
|
|
@@ -108,7 +108,7 @@ export declare class MessagesMethods extends DiscordBase {
|
|
|
108
108
|
write: (body: MessageCreateBodyRequest) => Promise<import("./Message").Message>;
|
|
109
109
|
edit: (messageId: string, body: MessageUpdateBodyRequest) => Promise<import("./Message").Message>;
|
|
110
110
|
crosspost: (messageId: string, reason?: string) => Promise<import("./Message").Message>;
|
|
111
|
-
delete: (messageId: string, reason?: string) => Promise<void
|
|
111
|
+
delete: (messageId: string, reason?: string) => Promise<void>;
|
|
112
112
|
fetch: (messageId: string) => Promise<import("./Message").Message>;
|
|
113
113
|
purge: (messages: string[], reason?: string) => Promise<never>;
|
|
114
114
|
};
|
|
@@ -129,7 +129,7 @@ export declare class MessagesMethods extends DiscordBase {
|
|
|
129
129
|
write: (body: MessageCreateBodyRequest) => Promise<import("./Message").Message>;
|
|
130
130
|
edit: (messageId: string, body: MessageUpdateBodyRequest) => Promise<import("./Message").Message>;
|
|
131
131
|
crosspost: (messageId: string, reason?: string) => Promise<import("./Message").Message>;
|
|
132
|
-
delete: (messageId: string, reason?: string) => Promise<void
|
|
132
|
+
delete: (messageId: string, reason?: string) => Promise<void>;
|
|
133
133
|
fetch: (messageId: string) => Promise<import("./Message").Message>;
|
|
134
134
|
purge: (messages: string[], reason?: string) => Promise<never>;
|
|
135
135
|
};
|
|
@@ -168,14 +168,17 @@ export declare class ThreadOnlyMethods extends DiscordBase {
|
|
|
168
168
|
setReactionEmoji(emoji: APIGuildForumDefaultReactionEmoji, reason?: string): Promise<AllChannels>;
|
|
169
169
|
setSortOrder(sort: SortOrderType, reason?: string): Promise<AllChannels>;
|
|
170
170
|
setThreadRateLimit(rate: number, reason?: string): Promise<AllChannels>;
|
|
171
|
+
thread(body: RESTPostAPIGuildForumThreadsJSONBody, reason?: string): Promise<ThreadChannel>;
|
|
171
172
|
}
|
|
172
173
|
export interface VoiceChannelMethods extends BaseChannel<ChannelType> {
|
|
173
174
|
}
|
|
174
175
|
export declare class VoiceChannelMethods extends DiscordBase {
|
|
176
|
+
guildId?: string;
|
|
175
177
|
setBitrate(bitrate: number | null, reason?: string): Promise<AllChannels>;
|
|
176
178
|
setUserLimit(user_limit: number | null, reason?: string): Promise<AllChannels>;
|
|
177
179
|
setRTC(rtc_region: string | null, reason?: string): Promise<AllChannels>;
|
|
178
180
|
setVideoQuality(quality: keyof typeof VideoQualityMode, reason?: string): Promise<AllChannels>;
|
|
181
|
+
states(): Promise<import("./VoiceState").VoiceState[]>;
|
|
179
182
|
}
|
|
180
183
|
export declare class WebhookGuildMethods extends DiscordBase {
|
|
181
184
|
webhooks: {
|
|
@@ -229,12 +229,16 @@ let ThreadOnlyMethods = class ThreadOnlyMethods extends DiscordBase_1.DiscordBas
|
|
|
229
229
|
setThreadRateLimit(rate, reason) {
|
|
230
230
|
return this.edit({ default_thread_rate_limit_per_user: rate }, reason);
|
|
231
231
|
}
|
|
232
|
+
async thread(body, reason) {
|
|
233
|
+
return this.client.channels.thread(this.id, body, reason);
|
|
234
|
+
}
|
|
232
235
|
};
|
|
233
236
|
exports.ThreadOnlyMethods = ThreadOnlyMethods;
|
|
234
237
|
exports.ThreadOnlyMethods = ThreadOnlyMethods = __decorate([
|
|
235
238
|
(0, ts_mixer_1.mix)(TopicableGuildChannel)
|
|
236
239
|
], ThreadOnlyMethods);
|
|
237
240
|
class VoiceChannelMethods extends DiscordBase_1.DiscordBase {
|
|
241
|
+
guildId;
|
|
238
242
|
setBitrate(bitrate, reason) {
|
|
239
243
|
return this.edit({ bitrate }, reason);
|
|
240
244
|
}
|
|
@@ -247,13 +251,22 @@ class VoiceChannelMethods extends DiscordBase_1.DiscordBase {
|
|
|
247
251
|
setVideoQuality(quality, reason) {
|
|
248
252
|
return this.edit({ video_quality_mode: v10_1.VideoQualityMode[quality] }, reason);
|
|
249
253
|
}
|
|
254
|
+
async states() {
|
|
255
|
+
if (!this.guildId)
|
|
256
|
+
return [];
|
|
257
|
+
const states = await this.cache.voiceStates?.values(this.guildId);
|
|
258
|
+
if (!states?.length)
|
|
259
|
+
return [];
|
|
260
|
+
const filter = states.filter(state => state.channelId === this.id);
|
|
261
|
+
return filter;
|
|
262
|
+
}
|
|
250
263
|
}
|
|
251
264
|
exports.VoiceChannelMethods = VoiceChannelMethods;
|
|
252
265
|
class WebhookGuildMethods extends DiscordBase_1.DiscordBase {
|
|
253
266
|
webhooks = WebhookGuildMethods.guild({ client: this.client, guildId: this.id });
|
|
254
267
|
static guild(ctx) {
|
|
255
268
|
return {
|
|
256
|
-
list: () => ctx.client.webhooks.
|
|
269
|
+
list: () => ctx.client.webhooks.listFromGuild(ctx.guildId),
|
|
257
270
|
};
|
|
258
271
|
}
|
|
259
272
|
}
|
|
@@ -53,7 +53,7 @@ export declare class PermissionsBitField extends BitField<typeof PermissionFlags
|
|
|
53
53
|
readonly SendVoiceMessages: bigint;
|
|
54
54
|
};
|
|
55
55
|
static All: bigint;
|
|
56
|
-
keys: (bits
|
|
56
|
+
keys: (bits?: BitFieldResolvable<typeof PermissionFlagsBits>[]) => PermissionStrings;
|
|
57
57
|
has(...bits: BitFieldResolvable<typeof PermissionFlagsBits>[]): boolean;
|
|
58
58
|
strictHas(...bits: BitFieldResolvable<typeof PermissionFlagsBits>[]): boolean;
|
|
59
59
|
}
|
package/lib/structures/index.js
CHANGED
|
@@ -27,5 +27,6 @@ __exportStar(require("./Interaction"), exports);
|
|
|
27
27
|
__exportStar(require("./Message"), exports);
|
|
28
28
|
__exportStar(require("./Sticker"), exports);
|
|
29
29
|
__exportStar(require("./User"), exports);
|
|
30
|
+
__exportStar(require("./VoiceState"), exports);
|
|
30
31
|
__exportStar(require("./Webhook"), exports);
|
|
31
32
|
__exportStar(require("./channels"), exports);
|
|
@@ -3,7 +3,7 @@ import type { GatewayReceivePayload, GatewaySendPayload } from 'discord-api-type
|
|
|
3
3
|
import type WS from 'ws';
|
|
4
4
|
import { type CloseEvent } from 'ws';
|
|
5
5
|
import type { Logger } from '../../common';
|
|
6
|
-
import { DynamicBucket
|
|
6
|
+
import { DynamicBucket } from '../structures';
|
|
7
7
|
import { ConnectTimeout } from '../structures/timeout';
|
|
8
8
|
import { BaseSocket } from './basesocket';
|
|
9
9
|
import type { ShardData, ShardOptions } from './shared';
|
|
@@ -23,7 +23,7 @@ export declare class Shard {
|
|
|
23
23
|
connectTimeout: ConnectTimeout;
|
|
24
24
|
heart: ShardHeart;
|
|
25
25
|
bucket: DynamicBucket;
|
|
26
|
-
offlineSendQueue:
|
|
26
|
+
offlineSendQueue: ((_?: unknown) => void)[];
|
|
27
27
|
constructor(id: number, options: ShardOptions);
|
|
28
28
|
get latency(): number;
|
|
29
29
|
get isOpen(): boolean;
|
|
@@ -31,7 +31,7 @@ export declare class Shard {
|
|
|
31
31
|
get resumeGatewayURL(): string | undefined;
|
|
32
32
|
get currentGatewayURL(): string;
|
|
33
33
|
connect(): Promise<void>;
|
|
34
|
-
send<T extends GatewaySendPayload = GatewaySendPayload>(
|
|
34
|
+
send<T extends GatewaySendPayload = GatewaySendPayload>(force: boolean, message: T): Promise<void>;
|
|
35
35
|
identify(): Promise<void>;
|
|
36
36
|
get resumable(): boolean;
|
|
37
37
|
resume(): Promise<void>;
|
|
@@ -42,6 +42,6 @@ export declare class Shard {
|
|
|
42
42
|
protected handleClosed(close: CloseEvent): Promise<void>;
|
|
43
43
|
close(code: number, reason: string): Promise<void>;
|
|
44
44
|
protected handleMessage({ data }: WS.MessageEvent): Promise<void>;
|
|
45
|
-
checkOffline(
|
|
45
|
+
checkOffline(force: boolean): Promise<unknown>;
|
|
46
46
|
calculateSafeRequests(): number;
|
|
47
47
|
}
|