seyfert 4.4.1 → 4.6.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 -1
- package/lib/api/Routes/guilds.d.ts +12 -1
- package/lib/api/Routes/index.d.ts +3 -1
- package/lib/api/Routes/invites.d.ts +1 -1
- package/lib/api/Routes/oauth2.d.ts +11 -0
- package/lib/api/Routes/oauth2.js +2 -0
- package/lib/api/Routes/skus.d.ts +11 -4
- package/lib/api/Routes/users.d.ts +2 -1
- package/lib/api/Routes/voice.d.ts +4 -0
- package/lib/api/Routes/webhooks.d.ts +1 -1
- package/lib/api/api.d.ts +15 -5
- package/lib/api/api.js +243 -114
- package/lib/api/bucket.js +13 -7
- package/lib/api/shared.d.ts +3 -1
- package/lib/api/utils/constants.d.ts +1 -1
- package/lib/api/utils/constants.js +1 -1
- package/lib/builders/Attachment.d.ts +6 -1
- package/lib/builders/Attachment.js +13 -9
- package/lib/builders/CheckboxGroup.js +1 -1
- package/lib/builders/FileUpload.d.ts +8 -1
- package/lib/builders/FileUpload.js +9 -0
- package/lib/builders/RadioGroup.js +1 -1
- package/lib/client/base.d.ts +3 -3
- package/lib/client/client.d.ts +1 -1
- package/lib/client/client.js +5 -4
- package/lib/client/collectors.d.ts +10 -8
- package/lib/client/transformers.d.ts +5 -0
- package/lib/client/workerclient.d.ts +8 -1
- package/lib/client/workerclient.js +34 -14
- package/lib/commands/applications/chat.d.ts +6 -4
- package/lib/commands/applications/options.d.ts +6 -4
- package/lib/commands/applications/shared.d.ts +2 -2
- package/lib/commands/handle.d.ts +7 -3
- package/lib/commands/handle.js +36 -11
- package/lib/commands/handler.js +11 -0
- package/lib/commands/optionresolver.d.ts +6 -7
- package/lib/common/it/error.d.ts +13 -0
- package/lib/common/it/error.js +15 -1
- package/lib/common/it/logger.js +12 -9
- package/lib/common/shorters/application.d.ts +1 -1
- package/lib/common/shorters/application.js +1 -1
- package/lib/common/shorters/bans.js +1 -1
- package/lib/common/shorters/guilds.js +5 -1
- package/lib/common/shorters/interaction.js +7 -4
- package/lib/common/shorters/invites.d.ts +5 -0
- package/lib/common/shorters/members.js +2 -1
- package/lib/common/shorters/messages.js +2 -2
- package/lib/common/shorters/threads.js +1 -1
- package/lib/common/shorters/webhook.js +3 -3
- package/lib/common/types/util.d.ts +7 -0
- package/lib/components/componentcommand.js +2 -2
- package/lib/components/customId.d.ts +3 -0
- package/lib/components/customId.js +11 -0
- package/lib/components/handler.js +2 -3
- package/lib/components/modalcommand.js +2 -2
- package/lib/events/hooks/invite.d.ts +1 -0
- package/lib/events/hooks/presence.d.ts +1 -0
- package/lib/events/hooks/thread.d.ts +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -1
- package/lib/structures/AnonymousGuild.d.ts +1 -1
- package/lib/structures/AnonymousGuild.js +1 -1
- package/lib/structures/Guild.d.ts +3 -0
- package/lib/structures/GuildMember.d.ts +2 -2
- package/lib/structures/GuildMember.js +22 -4
- package/lib/structures/GuildPreview.d.ts +1 -1
- package/lib/structures/GuildPreview.js +1 -1
- package/lib/structures/GuildRole.d.ts +13 -0
- package/lib/structures/GuildRole.js +21 -0
- package/lib/structures/GuildTemplate.js +1 -1
- package/lib/structures/Interaction.d.ts +7 -7
- package/lib/structures/Interaction.js +35 -21
- package/lib/structures/Message.d.ts +2 -1
- package/lib/structures/channels.d.ts +29 -16
- package/lib/structures/channels.js +59 -19
- package/lib/structures/extra/BaseGuild.d.ts +4 -4
- package/lib/structures/extra/BaseGuild.js +4 -4
- package/lib/types/gateway.d.ts +243 -239
- package/lib/types/index.d.ts +2 -2
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/attachment.d.ts +5 -2
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/shared.d.ts +2 -2
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/shared.js +1 -1
- package/lib/types/payloads/_interactions/_applicationCommands/chatInput.d.ts +7 -7
- package/lib/types/payloads/_interactions/_applicationCommands/contextMenu.d.ts +13 -13
- package/lib/types/payloads/_interactions/_applicationCommands/permissions.d.ts +4 -4
- package/lib/types/payloads/_interactions/_applicationCommands/permissions.js +2 -2
- package/lib/types/payloads/_interactions/applicationCommands.d.ts +10 -10
- package/lib/types/payloads/_interactions/applicationCommands.js +4 -4
- package/lib/types/payloads/_interactions/autocomplete.d.ts +2 -2
- package/lib/types/payloads/_interactions/base.d.ts +13 -7
- package/lib/types/payloads/_interactions/modalSubmit.d.ts +4 -4
- package/lib/types/payloads/_interactions/responses.d.ts +10 -10
- package/lib/types/payloads/_interactions/responses.js +2 -2
- package/lib/types/payloads/application.d.ts +21 -15
- package/lib/types/payloads/application.js +7 -7
- package/lib/types/payloads/auditLog.d.ts +22 -17
- package/lib/types/payloads/auditLog.js +7 -2
- package/lib/types/payloads/autoModeration.d.ts +11 -11
- package/lib/types/payloads/autoModeration.js +5 -5
- package/lib/types/payloads/channel.d.ts +87 -78
- package/lib/types/payloads/channel.js +16 -11
- package/lib/types/payloads/components.d.ts +41 -31
- package/lib/types/payloads/components.js +9 -5
- package/lib/types/payloads/emoji.d.ts +2 -2
- package/lib/types/payloads/emoji.js +1 -1
- package/lib/types/payloads/gateway.d.ts +33 -29
- package/lib/types/payloads/gateway.js +5 -5
- package/lib/types/payloads/guild.d.ts +68 -68
- package/lib/types/payloads/guild.js +14 -14
- package/lib/types/payloads/guildScheduledEvent.d.ts +11 -11
- package/lib/types/payloads/guildScheduledEvent.js +3 -3
- package/lib/types/payloads/index.d.ts +2 -2
- package/lib/types/payloads/interactions.d.ts +3 -3
- package/lib/types/payloads/invite.d.ts +11 -11
- package/lib/types/payloads/invite.js +3 -3
- package/lib/types/payloads/monetization.d.ts +4 -4
- package/lib/types/payloads/monetization.js +2 -2
- package/lib/types/payloads/oauth2.d.ts +21 -17
- package/lib/types/payloads/oauth2.js +21 -17
- package/lib/types/payloads/permissions.d.ts +5 -5
- package/lib/types/payloads/permissions.js +2 -2
- package/lib/types/payloads/poll.d.ts +7 -7
- package/lib/types/payloads/poll.js +2 -2
- package/lib/types/payloads/soundboard.d.ts +2 -2
- package/lib/types/payloads/soundboard.js +1 -1
- package/lib/types/payloads/stageInstance.d.ts +5 -5
- package/lib/types/payloads/stageInstance.js +1 -1
- package/lib/types/payloads/sticker.d.ts +8 -8
- package/lib/types/payloads/sticker.js +3 -3
- package/lib/types/payloads/teams.d.ts +8 -8
- package/lib/types/payloads/teams.js +3 -3
- package/lib/types/payloads/template.d.ts +3 -3
- package/lib/types/payloads/template.js +1 -1
- package/lib/types/payloads/user.d.ts +24 -22
- package/lib/types/payloads/user.js +7 -5
- package/lib/types/payloads/voice.d.ts +4 -4
- package/lib/types/payloads/voice.js +1 -1
- package/lib/types/payloads/webhokEvents.d.ts +5 -5
- package/lib/types/payloads/webhokEvents.js +2 -2
- package/lib/types/payloads/webhook.d.ts +4 -4
- package/lib/types/payloads/webhook.js +1 -1
- package/lib/types/rest/application.d.ts +14 -14
- package/lib/types/rest/auditLog.d.ts +1 -1
- package/lib/types/rest/autoModeration.d.ts +7 -7
- package/lib/types/rest/channel.d.ts +79 -74
- package/lib/types/rest/channel.js +1 -1
- package/lib/types/rest/emoji.d.ts +8 -8
- package/lib/types/rest/gateway.d.ts +2 -2
- package/lib/types/rest/guild.d.ts +98 -98
- package/lib/types/rest/guild.js +5 -5
- package/lib/types/rest/guildScheduledEvent.d.ts +11 -11
- package/lib/types/rest/index.d.ts +34 -3
- package/lib/types/rest/index.js +33 -2
- package/lib/types/rest/interactions.d.ts +48 -48
- package/lib/types/rest/invite.d.ts +5 -5
- package/lib/types/rest/monetization.d.ts +9 -9
- package/lib/types/rest/monetization.js +1 -1
- package/lib/types/rest/oauth2.d.ts +22 -18
- package/lib/types/rest/poll.d.ts +4 -4
- package/lib/types/rest/soundboard.d.ts +8 -8
- package/lib/types/rest/stageInstance.d.ts +6 -6
- package/lib/types/rest/sticker.d.ts +10 -10
- package/lib/types/rest/template.d.ts +11 -11
- package/lib/types/rest/user.d.ts +18 -14
- package/lib/types/rest/voice.d.ts +5 -5
- package/lib/types/rest/webhook.d.ts +38 -38
- package/lib/types/utils/index.d.ts +19 -19
- package/lib/types/utils/index.js +19 -19
- package/lib/websocket/SharedTypes.d.ts +2 -2
- package/lib/websocket/constants/index.js +2 -2
- package/lib/websocket/discord/heartbeater.d.ts +1 -0
- package/lib/websocket/discord/heartbeater.js +8 -0
- package/lib/websocket/discord/shard.d.ts +19 -10
- package/lib/websocket/discord/shard.js +255 -122
- package/lib/websocket/discord/sharder.d.ts +2 -2
- package/lib/websocket/discord/sharder.js +2 -2
- package/lib/websocket/discord/shared.d.ts +7 -2
- package/lib/websocket/discord/workermanager.d.ts +3 -1
- package/lib/websocket/discord/workermanager.js +31 -24
- package/package.json +3 -3
package/lib/common/it/error.js
CHANGED
|
@@ -35,6 +35,9 @@ class SeyfertError extends Error {
|
|
|
35
35
|
* Optional contextual data attached to the error.
|
|
36
36
|
*/
|
|
37
37
|
metadata;
|
|
38
|
+
static is(error, code) {
|
|
39
|
+
return error instanceof SeyfertError && (code === undefined || error.code === code);
|
|
40
|
+
}
|
|
38
41
|
/**
|
|
39
42
|
* Creates a SeyfertError instance.
|
|
40
43
|
*
|
|
@@ -85,6 +88,15 @@ exports.SeyfertErrorMessages = {
|
|
|
85
88
|
INVALID_OPTIONS_LENGTH: 'Invalid options length.',
|
|
86
89
|
MISSING_COMPONENT: 'Cannot convert to JSON without a component.',
|
|
87
90
|
MISSING_ACCESSORY: 'Cannot convert to JSON without an accessory.',
|
|
91
|
+
MISSING_MEDIA: 'Cannot convert to JSON without media.',
|
|
92
|
+
MISSING_MODAL_CUSTOM_ID: 'Cannot convert to JSON without a custom_id.',
|
|
93
|
+
MISSING_MODAL_TITLE: 'Cannot convert to JSON without a title.',
|
|
94
|
+
MISSING_POLL_QUESTION: 'Cannot convert to JSON without a question.',
|
|
95
|
+
MISSING_POLL_ANSWERS: 'Cannot convert to JSON without answers.',
|
|
96
|
+
MISSING_RADIO_GROUP_OPTION_LABEL: 'Cannot convert to JSON without a label.',
|
|
97
|
+
MISSING_RADIO_GROUP_OPTION_VALUE: 'Cannot convert to JSON without a value.',
|
|
98
|
+
MISSING_STRING_SELECT_OPTION_LABEL: 'Cannot convert to JSON without a label.',
|
|
99
|
+
MISSING_STRING_SELECT_OPTION_VALUE: 'Cannot convert to JSON without a value.',
|
|
88
100
|
INVALID_ATTACHMENT_TYPE: 'Invalid attachment type.',
|
|
89
101
|
INVALID_ANSWER_ID: 'Invalid answer id.',
|
|
90
102
|
UNDEFINED_LOCALE: 'Undefined locale.',
|
|
@@ -127,7 +139,9 @@ exports.SeyfertErrorMessages = {
|
|
|
127
139
|
GUILD_SEARCH_INDEX_NOT_READY: 'Guild search index is not yet available.',
|
|
128
140
|
};
|
|
129
141
|
function resolveSeyfertErrorMessage(code) {
|
|
130
|
-
const preset = exports.SeyfertErrorMessages
|
|
142
|
+
const preset = Object.hasOwn(exports.SeyfertErrorMessages, code)
|
|
143
|
+
? exports.SeyfertErrorMessages[code]
|
|
144
|
+
: undefined;
|
|
131
145
|
if (preset)
|
|
132
146
|
return preset;
|
|
133
147
|
return code
|
package/lib/common/it/logger.js
CHANGED
|
@@ -72,15 +72,18 @@ class Logger {
|
|
|
72
72
|
Logger.__assignFileName = cb;
|
|
73
73
|
}
|
|
74
74
|
static async clearLogs() {
|
|
75
|
-
for (const
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
delete Logger.streams[
|
|
75
|
+
for (const [fileName, stream] of Object.entries(Logger.streams)) {
|
|
76
|
+
if (!stream)
|
|
77
|
+
continue;
|
|
78
|
+
await new Promise((resolve, reject) => stream.close(error => {
|
|
79
|
+
if (error)
|
|
80
|
+
return reject(error);
|
|
81
|
+
resolve();
|
|
82
|
+
}));
|
|
83
|
+
delete Logger.streams[fileName];
|
|
84
|
+
}
|
|
85
|
+
for (const entry of await node_fs_1.promises.readdir((0, node_path_1.join)(process.cwd(), Logger.dirname), { withFileTypes: true })) {
|
|
86
|
+
await node_fs_1.promises.unlink((0, node_path_1.join)(process.cwd(), Logger.dirname, entry.name)).catch(() => undefined);
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
/**
|
|
@@ -17,7 +17,7 @@ export declare class ApplicationShorter extends BaseShorter {
|
|
|
17
17
|
/**
|
|
18
18
|
* Creates a new emoji for the application.
|
|
19
19
|
* @param body.name The name of the emoji.
|
|
20
|
-
* @param body.image The [image data string](https://discord.com/developers/
|
|
20
|
+
* @param body.image The [image data string](https://docs.discord.com/developers/reference#image-data) of the emoji.
|
|
21
21
|
* @returns The created emoji.
|
|
22
22
|
*/
|
|
23
23
|
createEmoji(raw: ApplicationEmojiResolvable): Promise<ApplicationEmojiStructure>;
|
|
@@ -37,7 +37,7 @@ class ApplicationShorter extends base_1.BaseShorter {
|
|
|
37
37
|
/**
|
|
38
38
|
* Creates a new emoji for the application.
|
|
39
39
|
* @param body.name The name of the emoji.
|
|
40
|
-
* @param body.image The [image data string](https://discord.com/developers/
|
|
40
|
+
* @param body.image The [image data string](https://docs.discord.com/developers/reference#image-data) of the emoji.
|
|
41
41
|
* @returns The created emoji.
|
|
42
42
|
*/
|
|
43
43
|
async createEmoji(raw) {
|
|
@@ -12,7 +12,7 @@ class BanShorter extends base_1.BaseShorter {
|
|
|
12
12
|
* @param reason The reason for bulk banning members.
|
|
13
13
|
*/
|
|
14
14
|
async bulkCreate(guildId, body, reason) {
|
|
15
|
-
const bans = await this.client.proxy.guilds(guildId)['bulk-
|
|
15
|
+
const bans = await this.client.proxy.guilds(guildId)['bulk-ban'].post({ reason, body });
|
|
16
16
|
await Promise.all(bans.banned_users.map(id => this.client.cache.members?.removeIfNI('GuildModeration', id, guildId)));
|
|
17
17
|
return bans;
|
|
18
18
|
}
|
|
@@ -96,7 +96,11 @@ class GuildShorter extends base_1.BaseShorter {
|
|
|
96
96
|
if ('code' in result && result.code === 110_000) {
|
|
97
97
|
if (!wait)
|
|
98
98
|
throw new error_1.SeyfertError('GUILD_SEARCH_INDEX_NOT_READY', {
|
|
99
|
-
metadata: {
|
|
99
|
+
metadata: {
|
|
100
|
+
guildId,
|
|
101
|
+
retryAfter: result.retry_after,
|
|
102
|
+
detail: `Guild search index for ${guildId} is not ready; retry after ${result.retry_after} seconds.`,
|
|
103
|
+
},
|
|
100
104
|
});
|
|
101
105
|
await (0, utils_1.delay)(result.retry_after * 1000);
|
|
102
106
|
return this.searchMessages(guildId, query, wait);
|
|
@@ -14,10 +14,11 @@ class InteractionShorter extends base_1.BaseShorter {
|
|
|
14
14
|
return this.client.proxy
|
|
15
15
|
.interactions(id)(token)
|
|
16
16
|
.callback.post({
|
|
17
|
+
auth: false,
|
|
17
18
|
body: __1.BaseInteraction.transformBodyRequest({
|
|
18
19
|
type: body.type,
|
|
19
20
|
data,
|
|
20
|
-
},
|
|
21
|
+
}, files, this.client),
|
|
21
22
|
files: parsedFiles,
|
|
22
23
|
query: { with_response: withResponse },
|
|
23
24
|
});
|
|
@@ -40,7 +41,8 @@ class InteractionShorter extends base_1.BaseShorter {
|
|
|
40
41
|
.webhooks(this.client.applicationId)(token)
|
|
41
42
|
.messages(messageId)
|
|
42
43
|
.patch({
|
|
43
|
-
|
|
44
|
+
auth: false,
|
|
45
|
+
body: __1.BaseInteraction.transformBody(data, files, this.client),
|
|
44
46
|
files: parsedFiles,
|
|
45
47
|
});
|
|
46
48
|
return transformers_1.Transformers.WebhookMessage(this.client, apiMessage, this.client.applicationId, token);
|
|
@@ -52,7 +54,7 @@ class InteractionShorter extends base_1.BaseShorter {
|
|
|
52
54
|
return this.client.proxy
|
|
53
55
|
.webhooks(this.client.applicationId)(token)
|
|
54
56
|
.messages(messageId)
|
|
55
|
-
.delete()
|
|
57
|
+
.delete({ auth: false })
|
|
56
58
|
.then(() => this.client.components.deleteValue(messageId, 'messageDelete'));
|
|
57
59
|
}
|
|
58
60
|
deleteOriginal(token) {
|
|
@@ -63,7 +65,8 @@ class InteractionShorter extends base_1.BaseShorter {
|
|
|
63
65
|
const apiMessage = (await this.client.proxy
|
|
64
66
|
.webhooks(this.client.applicationId)(token)
|
|
65
67
|
.post({
|
|
66
|
-
|
|
68
|
+
auth: false,
|
|
69
|
+
body: __1.BaseInteraction.transformBody(body, files, this.client),
|
|
67
70
|
files: parsedFiles,
|
|
68
71
|
}));
|
|
69
72
|
return transformers_1.Transformers.WebhookMessage(this.client, apiMessage, this.client.applicationId, token);
|
|
@@ -84,6 +84,7 @@ export declare class InvitesShorter extends BaseShorter {
|
|
|
84
84
|
slug?: string | undefined;
|
|
85
85
|
coverImage?: string | undefined;
|
|
86
86
|
flags?: import("../../types").ApplicationFlags | undefined;
|
|
87
|
+
flagsNew?: string | undefined;
|
|
87
88
|
approximateGuildCount?: number | undefined;
|
|
88
89
|
approximateUserInstallCount?: number | undefined;
|
|
89
90
|
redirectUris?: string[] | undefined;
|
|
@@ -239,6 +240,7 @@ export declare class InvitesShorter extends BaseShorter {
|
|
|
239
240
|
slug?: string | undefined;
|
|
240
241
|
coverImage?: string | undefined;
|
|
241
242
|
flags?: import("../../types").ApplicationFlags | undefined;
|
|
243
|
+
flagsNew?: string | undefined;
|
|
242
244
|
approximateGuildCount?: number | undefined;
|
|
243
245
|
approximateUserInstallCount?: number | undefined;
|
|
244
246
|
redirectUris?: string[] | undefined;
|
|
@@ -415,6 +417,7 @@ export declare class InvitesShorter extends BaseShorter {
|
|
|
415
417
|
slug?: string | undefined;
|
|
416
418
|
coverImage?: string | undefined;
|
|
417
419
|
flags?: import("../../types").ApplicationFlags | undefined;
|
|
420
|
+
flagsNew?: string | undefined;
|
|
418
421
|
approximateGuildCount?: number | undefined;
|
|
419
422
|
approximateUserInstallCount?: number | undefined;
|
|
420
423
|
redirectUris?: string[] | undefined;
|
|
@@ -575,6 +578,7 @@ export declare class InvitesShorter extends BaseShorter {
|
|
|
575
578
|
slug?: string | undefined;
|
|
576
579
|
coverImage?: string | undefined;
|
|
577
580
|
flags?: import("../../types").ApplicationFlags | undefined;
|
|
581
|
+
flagsNew?: string | undefined;
|
|
578
582
|
approximateGuildCount?: number | undefined;
|
|
579
583
|
approximateUserInstallCount?: number | undefined;
|
|
580
584
|
redirectUris?: string[] | undefined;
|
|
@@ -750,6 +754,7 @@ export declare class InvitesShorter extends BaseShorter {
|
|
|
750
754
|
slug?: string | undefined;
|
|
751
755
|
coverImage?: string | undefined;
|
|
752
756
|
flags?: import("../../types").ApplicationFlags | undefined;
|
|
757
|
+
flagsNew?: string | undefined;
|
|
753
758
|
approximateGuildCount?: number | undefined;
|
|
754
759
|
approximateUserInstallCount?: number | undefined;
|
|
755
760
|
redirectUris?: string[] | undefined;
|
|
@@ -4,6 +4,7 @@ exports.MemberShorter = void 0;
|
|
|
4
4
|
const cache_1 = require("../../cache");
|
|
5
5
|
const transformers_1 = require("../../client/transformers");
|
|
6
6
|
const Permissions_1 = require("../../structures/extra/Permissions");
|
|
7
|
+
const GuildRole_1 = require("../../structures/GuildRole");
|
|
7
8
|
const types_1 = require("../../types");
|
|
8
9
|
const base_1 = require("./base");
|
|
9
10
|
class MemberShorter extends base_1.BaseShorter {
|
|
@@ -182,7 +183,7 @@ class MemberShorter extends base_1.BaseShorter {
|
|
|
182
183
|
}
|
|
183
184
|
async sortRoles(guildId, memberId, force = false) {
|
|
184
185
|
const roles = await this.listRoles(guildId, memberId, force);
|
|
185
|
-
return roles.sort((a, b) => b
|
|
186
|
+
return roles.sort((a, b) => GuildRole_1.GuildRole.comparePositions(b, a));
|
|
186
187
|
}
|
|
187
188
|
async permissions(guildId, memberId, force = false) {
|
|
188
189
|
const roles = await this.listRoles(guildId, memberId, force);
|
|
@@ -9,7 +9,7 @@ const base_1 = require("./base");
|
|
|
9
9
|
class MessageShorter extends base_1.BaseShorter {
|
|
10
10
|
async write(channelId, { files, ...body }) {
|
|
11
11
|
const parsedFiles = files ? await (0, builders_1.resolveFiles)(files) : undefined;
|
|
12
|
-
const transformedBody = structures_1.MessagesMethods.transformMessageBody(body,
|
|
12
|
+
const transformedBody = structures_1.MessagesMethods.transformMessageBody(body, files, this.client);
|
|
13
13
|
return this.client.proxy
|
|
14
14
|
.channels(channelId)
|
|
15
15
|
.messages.post({
|
|
@@ -27,7 +27,7 @@ class MessageShorter extends base_1.BaseShorter {
|
|
|
27
27
|
.channels(channelId)
|
|
28
28
|
.messages(messageId)
|
|
29
29
|
.patch({
|
|
30
|
-
body: structures_1.MessagesMethods.transformMessageBody(body,
|
|
30
|
+
body: structures_1.MessagesMethods.transformMessageBody(body, files, this.client),
|
|
31
31
|
files: parsedFiles,
|
|
32
32
|
})
|
|
33
33
|
.then(async (message) => {
|
|
@@ -17,7 +17,7 @@ class ThreadShorter extends base_1.BaseShorter {
|
|
|
17
17
|
if ('message' in body || 'files' in body) {
|
|
18
18
|
const { message, files, ...rest } = body;
|
|
19
19
|
const parsedFiles = files ? await (0, __1.resolveFiles)(files) : undefined;
|
|
20
|
-
const transformedBody = structures_1.MessagesMethods.transformMessageBody(message ?? {},
|
|
20
|
+
const transformedBody = structures_1.MessagesMethods.transformMessageBody(message ?? {}, files, this.client);
|
|
21
21
|
thread = await this.client.proxy.channels(channelId).threads.post({
|
|
22
22
|
body: {
|
|
23
23
|
...rest,
|
|
@@ -69,10 +69,10 @@ class WebhookShorter extends base_1.BaseShorter {
|
|
|
69
69
|
async writeMessage(webhookId, token, { body: data, ...payload }) {
|
|
70
70
|
const { files, ...body } = data;
|
|
71
71
|
const parsedFiles = files ? await (0, builders_1.resolveFiles)(files) : undefined;
|
|
72
|
-
const transformedBody = structures_1.MessagesMethods.transformMessageBody(body,
|
|
72
|
+
const transformedBody = structures_1.MessagesMethods.transformMessageBody(body, files, this.client);
|
|
73
73
|
return this.client.proxy
|
|
74
74
|
.webhooks(webhookId)(token)
|
|
75
|
-
.post({ ...payload, files: parsedFiles, body: transformedBody })
|
|
75
|
+
.post({ ...payload, auth: false, files: parsedFiles, body: transformedBody })
|
|
76
76
|
.then(m => (m?.id ? transformers_1.Transformers.WebhookMessage(this.client, m, webhookId, token) : null));
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
@@ -86,7 +86,7 @@ class WebhookShorter extends base_1.BaseShorter {
|
|
|
86
86
|
async editMessage(webhookId, token, { messageId, body: data, ...json }) {
|
|
87
87
|
const { files, ...body } = data;
|
|
88
88
|
const parsedFiles = files ? await (0, builders_1.resolveFiles)(files) : undefined;
|
|
89
|
-
const transformedBody = structures_1.MessagesMethods.transformMessageBody(body,
|
|
89
|
+
const transformedBody = structures_1.MessagesMethods.transformMessageBody(body, files, this.client);
|
|
90
90
|
return this.client.proxy
|
|
91
91
|
.webhooks(webhookId)(token)
|
|
92
92
|
.messages(messageId)
|
|
@@ -51,7 +51,14 @@ export type MakeRequired<T, K extends keyof T = keyof T> = T & {
|
|
|
51
51
|
export type PickRequired<T, K extends keyof T> = Omit<T, K> & {
|
|
52
52
|
[P in K]: NonFalsy<T[P]>;
|
|
53
53
|
};
|
|
54
|
+
export type MakePresent<T, K extends keyof T = keyof T> = T & {
|
|
55
|
+
[P in K]-?: NonNullish<T[P]>;
|
|
56
|
+
};
|
|
57
|
+
export type PickPresent<T, K extends keyof T> = Omit<T, K> & {
|
|
58
|
+
[P in K]-?: NonNullish<T[P]>;
|
|
59
|
+
};
|
|
54
60
|
export type NonFalsy<T> = T extends false | 0 | '' | null | undefined | 0n ? never : T;
|
|
61
|
+
export type NonNullish<T> = T extends null | undefined ? never : T;
|
|
55
62
|
export type CamelCase<S extends string> = S extends `${infer P1}_${infer P2}${infer P3}` ? `${Lowercase<P1>}${Uppercase<P2>}${CamelCase<P3>}` : Lowercase<S>;
|
|
56
63
|
export type SnakeCase<S extends string> = S extends `${infer A}${infer Rest}` ? A extends Uppercase<A> ? `_${Lowercase<A>}${SnakeCase<Rest>}` : `${A}${SnakeCase<Rest>}` : Lowercase<S>;
|
|
57
64
|
export type ObjectToLower<T> = T extends unknown[] ? ObjectToLower<T[0]>[] : Identify<{
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ComponentCommand = exports.InteractionCommandType = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
|
+
const customId_1 = require("./customId");
|
|
5
6
|
exports.InteractionCommandType = {
|
|
6
7
|
COMPONENT: 0,
|
|
7
8
|
MODAL: 1,
|
|
@@ -12,8 +13,7 @@ class ComponentCommand {
|
|
|
12
13
|
/** @internal */
|
|
13
14
|
_filter(context) {
|
|
14
15
|
if (this.customId) {
|
|
15
|
-
|
|
16
|
-
if (!matches)
|
|
16
|
+
if (!(0, customId_1.matchesCustomId)(this.customId, context.customId))
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
19
19
|
if (this.filter)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.matchesCustomId = matchesCustomId;
|
|
4
|
+
function matchesCustomId(customId, value) {
|
|
5
|
+
if (typeof customId === 'string')
|
|
6
|
+
return customId === value;
|
|
7
|
+
if (!customId.global && !customId.sticky)
|
|
8
|
+
return customId.test(value);
|
|
9
|
+
// String#search ignores and restores lastIndex for standard stateful regular expressions.
|
|
10
|
+
return value.search(customId) !== -1;
|
|
11
|
+
}
|
|
@@ -5,6 +5,7 @@ const collection_1 = require("../collection");
|
|
|
5
5
|
const commands_1 = require("../commands");
|
|
6
6
|
const common_1 = require("../common");
|
|
7
7
|
const componentcommand_1 = require("./componentcommand");
|
|
8
|
+
const customId_1 = require("./customId");
|
|
8
9
|
const modalcommand_1 = require("./modalcommand");
|
|
9
10
|
class ComponentHandler extends common_1.BaseHandler {
|
|
10
11
|
client;
|
|
@@ -19,11 +20,9 @@ class ComponentHandler extends common_1.BaseHandler {
|
|
|
19
20
|
this.client = client;
|
|
20
21
|
}
|
|
21
22
|
createMatchCallback(match) {
|
|
22
|
-
if (typeof match === 'string')
|
|
23
|
-
return str => str === match;
|
|
24
23
|
if (Array.isArray(match))
|
|
25
24
|
return str => match.includes(str);
|
|
26
|
-
return str =>
|
|
25
|
+
return str => (0, customId_1.matchesCustomId)(match, str);
|
|
27
26
|
}
|
|
28
27
|
createComponentCollector(messageId, channelId, guildId, options = {}, components = []) {
|
|
29
28
|
this.values.set(messageId, {
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ModalCommand = void 0;
|
|
4
4
|
const componentcommand_1 = require("./componentcommand");
|
|
5
|
+
const customId_1 = require("./customId");
|
|
5
6
|
class ModalCommand {
|
|
6
7
|
type = componentcommand_1.InteractionCommandType.MODAL;
|
|
7
8
|
customId;
|
|
8
9
|
/** @internal */
|
|
9
10
|
_filter(context) {
|
|
10
11
|
if (this.customId) {
|
|
11
|
-
|
|
12
|
-
if (!matches)
|
|
12
|
+
if (!(0, customId_1.matchesCustomId)(this.customId, context.customId))
|
|
13
13
|
return false;
|
|
14
14
|
}
|
|
15
15
|
if (this.filter)
|
|
@@ -70,6 +70,7 @@ export declare const INVITE_CREATE: (_self: UsingClient, data: GatewayInviteCrea
|
|
|
70
70
|
slug?: string | undefined;
|
|
71
71
|
coverImage?: string | undefined;
|
|
72
72
|
flags?: import("../../types").ApplicationFlags | undefined;
|
|
73
|
+
flagsNew?: string | undefined;
|
|
73
74
|
approximateGuildCount?: number | undefined;
|
|
74
75
|
approximateUserInstallCount?: number | undefined;
|
|
75
76
|
redirectUris?: string[] | undefined;
|
|
@@ -81,6 +81,7 @@ export declare const PRESENCE_UPDATE: (self: UsingClient, data: GatewayPresenceU
|
|
|
81
81
|
desktop?: import("../../types").PresenceUpdateReceiveStatus | undefined;
|
|
82
82
|
mobile?: import("../../types").PresenceUpdateReceiveStatus | undefined;
|
|
83
83
|
web?: import("../../types").PresenceUpdateReceiveStatus | undefined;
|
|
84
|
+
vr?: import("../../types").PresenceUpdateReceiveStatus | undefined;
|
|
84
85
|
} | undefined;
|
|
85
86
|
}, import("../..").ReturnCache<(Omit<import("../../types").GatewayPresenceUpdate, "user"> & {
|
|
86
87
|
id: string;
|
|
@@ -30,6 +30,7 @@ export declare const THREAD_LIST_SYNC: (_self: UsingClient, data: GatewayThreadL
|
|
|
30
30
|
appliedTags: string[];
|
|
31
31
|
id: string;
|
|
32
32
|
type: import("../../types").ThreadChannelType;
|
|
33
|
+
applicationId?: string | null | undefined;
|
|
33
34
|
flags?: import("../../types").ChannelFlags | undefined;
|
|
34
35
|
rateLimitPerUser?: number | undefined;
|
|
35
36
|
lastMessageId?: string | null | undefined;
|
package/lib/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export * from './builders';
|
|
|
6
6
|
export * from './cache';
|
|
7
7
|
export { Collection, LimitedCollection } from './collection';
|
|
8
8
|
export * from './commands';
|
|
9
|
-
export { Formatter, Logger, PermissionStrings } from './common';
|
|
9
|
+
export { type AssignFilenameCallback, type CustomizeLoggerCallback, Formatter, Logger, type LoggerOptions, LogLevels, PermissionStrings, } from './common';
|
|
10
10
|
export * from './components';
|
|
11
11
|
export * from './events';
|
|
12
12
|
export * from './langs';
|
package/lib/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.config = exports.WorkerManager = exports.ShardManager = exports.Logger = exports.Formatter = exports.LimitedCollection = exports.Collection = void 0;
|
|
17
|
+
exports.config = exports.WorkerManager = exports.ShardManager = exports.LogLevels = exports.Logger = exports.Formatter = exports.LimitedCollection = exports.Collection = void 0;
|
|
18
18
|
exports.createEvent = createEvent;
|
|
19
19
|
exports.extendContext = extendContext;
|
|
20
20
|
__exportStar(require("./client"), exports);
|
|
@@ -33,6 +33,7 @@ __exportStar(require("./commands"), exports);
|
|
|
33
33
|
var common_2 = require("./common");
|
|
34
34
|
Object.defineProperty(exports, "Formatter", { enumerable: true, get: function () { return common_2.Formatter; } });
|
|
35
35
|
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return common_2.Logger; } });
|
|
36
|
+
Object.defineProperty(exports, "LogLevels", { enumerable: true, get: function () { return common_2.LogLevels; } });
|
|
36
37
|
__exportStar(require("./components"), exports);
|
|
37
38
|
__exportStar(require("./events"), exports);
|
|
38
39
|
__exportStar(require("./langs"), exports);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseGuild } from './extra/BaseGuild';
|
|
2
2
|
/**
|
|
3
3
|
* Class for anonymous guilds.
|
|
4
|
-
* @link https://discord.com/developers/
|
|
4
|
+
* @link https://docs.discord.com/developers/resources/guild#guild-resource
|
|
5
5
|
*/
|
|
6
6
|
export declare class AnonymousGuild extends BaseGuild {
|
|
7
7
|
}
|
|
@@ -4,7 +4,7 @@ exports.AnonymousGuild = void 0;
|
|
|
4
4
|
const BaseGuild_1 = require("./extra/BaseGuild");
|
|
5
5
|
/**
|
|
6
6
|
* Class for anonymous guilds.
|
|
7
|
-
* @link https://discord.com/developers/
|
|
7
|
+
* @link https://docs.discord.com/developers/resources/guild#guild-resource
|
|
8
8
|
*/
|
|
9
9
|
class AnonymousGuild extends BaseGuild_1.BaseGuild {
|
|
10
10
|
}
|
|
@@ -178,6 +178,7 @@ export declare class Guild<State extends StructStates = 'api'> extends Guild_bas
|
|
|
178
178
|
slug?: string | undefined;
|
|
179
179
|
coverImage?: string | undefined;
|
|
180
180
|
flags?: import("../types").ApplicationFlags | undefined;
|
|
181
|
+
flagsNew?: string | undefined;
|
|
181
182
|
approximateGuildCount?: number | undefined;
|
|
182
183
|
approximateUserInstallCount?: number | undefined;
|
|
183
184
|
redirectUris?: string[] | undefined;
|
|
@@ -338,6 +339,7 @@ export declare class Guild<State extends StructStates = 'api'> extends Guild_bas
|
|
|
338
339
|
slug?: string | undefined;
|
|
339
340
|
coverImage?: string | undefined;
|
|
340
341
|
flags?: import("../types").ApplicationFlags | undefined;
|
|
342
|
+
flagsNew?: string | undefined;
|
|
341
343
|
approximateGuildCount?: number | undefined;
|
|
342
344
|
approximateUserInstallCount?: number | undefined;
|
|
343
345
|
redirectUris?: string[] | undefined;
|
|
@@ -493,6 +495,7 @@ export declare class Guild<State extends StructStates = 'api'> extends Guild_bas
|
|
|
493
495
|
slug?: string | undefined;
|
|
494
496
|
coverImage?: string | undefined;
|
|
495
497
|
flags?: import("../types").ApplicationFlags | undefined;
|
|
498
|
+
flagsNew?: string | undefined;
|
|
496
499
|
approximateGuildCount?: number | undefined;
|
|
497
500
|
approximateUserInstallCount?: number | undefined;
|
|
498
501
|
redirectUris?: string[] | undefined;
|
|
@@ -64,7 +64,7 @@ export interface GuildMember extends ObjectToLower<Omit<APIGuildMember, 'user' |
|
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
66
|
* Represents a guild member
|
|
67
|
-
* @link https://discord.com/developers/
|
|
67
|
+
* @link https://docs.discord.com/developers/resources/guild#guild-member-object
|
|
68
68
|
*/
|
|
69
69
|
export declare class GuildMember extends BaseGuildMember {
|
|
70
70
|
/** the choosen guild id */
|
|
@@ -111,7 +111,7 @@ export interface InteractionGuildMember extends ObjectToLower<Omit<APIInteractio
|
|
|
111
111
|
}
|
|
112
112
|
/**
|
|
113
113
|
* Represents a guild member
|
|
114
|
-
* @link https://discord.com/developers/
|
|
114
|
+
* @link https://docs.discord.com/developers/resources/guild#guild-member-object
|
|
115
115
|
*/
|
|
116
116
|
export declare class InteractionGuildMember extends GuildMember {
|
|
117
117
|
permissions: PermissionsBitField;
|
|
@@ -5,6 +5,7 @@ const DiscordBase_1 = require("./extra/DiscordBase");
|
|
|
5
5
|
const transformers_1 = require("../client/transformers");
|
|
6
6
|
const common_1 = require("../common");
|
|
7
7
|
const Permissions_1 = require("./extra/Permissions");
|
|
8
|
+
const GuildRole_1 = require("./GuildRole");
|
|
8
9
|
class BaseGuildMember extends DiscordBase_1.DiscordBase {
|
|
9
10
|
guildId;
|
|
10
11
|
_roles;
|
|
@@ -80,7 +81,7 @@ class BaseGuildMember extends DiscordBase_1.DiscordBase {
|
|
|
80
81
|
add: (id) => this.client.members.addRole(this.guildId, this.id, id),
|
|
81
82
|
remove: (id) => this.client.members.removeRole(this.guildId, this.id, id),
|
|
82
83
|
permissions: (force = false) => this.roles.list(force).then(roles => new Permissions_1.PermissionsBitField(roles.map(x => BigInt(x.permissions.bits)))),
|
|
83
|
-
sorted: (force = false) => this.roles.list(force).then(roles => roles.sort((a, b) => b
|
|
84
|
+
sorted: (force = false) => this.roles.list(force).then(roles => roles.sort((a, b) => GuildRole_1.GuildRole.comparePositions(b, a))),
|
|
84
85
|
highest: (force = false) => this.roles.sorted(force).then(roles => roles[0]),
|
|
85
86
|
};
|
|
86
87
|
}
|
|
@@ -103,7 +104,7 @@ class BaseGuildMember extends DiscordBase_1.DiscordBase {
|
|
|
103
104
|
exports.BaseGuildMember = BaseGuildMember;
|
|
104
105
|
/**
|
|
105
106
|
* Represents a guild member
|
|
106
|
-
* @link https://discord.com/developers/
|
|
107
|
+
* @link https://docs.discord.com/developers/resources/guild#guild-member-object
|
|
107
108
|
*/
|
|
108
109
|
class GuildMember extends BaseGuildMember {
|
|
109
110
|
guildId;
|
|
@@ -170,7 +171,24 @@ class GuildMember extends BaseGuildMember {
|
|
|
170
171
|
return false;
|
|
171
172
|
if (this.client.botId === ownerId)
|
|
172
173
|
return true;
|
|
173
|
-
|
|
174
|
+
const highestFromCompleteRoles = async (member, forceRoles) => {
|
|
175
|
+
const roles = await member.roles.sorted(forceRoles);
|
|
176
|
+
const roleIds = new Set(roles.map(role => role.id));
|
|
177
|
+
if (!member.roles.keys.every(roleId => roleIds.has(roleId)))
|
|
178
|
+
return;
|
|
179
|
+
return roles.at(0);
|
|
180
|
+
};
|
|
181
|
+
const myHighest = await highestFromCompleteRoles(this.__me, force);
|
|
182
|
+
const theirHighest = await highestFromCompleteRoles(this, force);
|
|
183
|
+
if (myHighest && theirHighest)
|
|
184
|
+
return GuildRole_1.GuildRole.comparePositions(myHighest, theirHighest) > 0;
|
|
185
|
+
if (force)
|
|
186
|
+
return false;
|
|
187
|
+
const forcedMyHighest = await highestFromCompleteRoles(this.__me, true);
|
|
188
|
+
const forcedTheirHighest = await highestFromCompleteRoles(this, true);
|
|
189
|
+
if (!forcedMyHighest || !forcedTheirHighest)
|
|
190
|
+
return false;
|
|
191
|
+
return GuildRole_1.GuildRole.comparePositions(forcedMyHighest, forcedTheirHighest) > 0;
|
|
174
192
|
}
|
|
175
193
|
async bannable(force = false) {
|
|
176
194
|
return (await this.manageable(force)) && (await this.__me.fetchPermissions(force)).has(['BanMembers']);
|
|
@@ -190,7 +208,7 @@ class UnavailableMember extends BaseGuildMember {
|
|
|
190
208
|
exports.UnavailableMember = UnavailableMember;
|
|
191
209
|
/**
|
|
192
210
|
* Represents a guild member
|
|
193
|
-
* @link https://discord.com/developers/
|
|
211
|
+
* @link https://docs.discord.com/developers/resources/guild#guild-member-object
|
|
194
212
|
*/
|
|
195
213
|
class InteractionGuildMember extends GuildMember {
|
|
196
214
|
permissions;
|
|
@@ -3,7 +3,7 @@ import type { APIGuildPreview } from '../types';
|
|
|
3
3
|
import { AnonymousGuild } from './AnonymousGuild';
|
|
4
4
|
/**
|
|
5
5
|
* Represent Discord Guild Preview Object
|
|
6
|
-
* @link https://discord.com/developers/
|
|
6
|
+
* @link https://docs.discord.com/developers/resources/guild#guild-preview-object
|
|
7
7
|
*/
|
|
8
8
|
export declare class GuildPreview extends AnonymousGuild {
|
|
9
9
|
constructor(client: UsingClient, data: APIGuildPreview);
|
|
@@ -4,7 +4,7 @@ exports.GuildPreview = void 0;
|
|
|
4
4
|
const AnonymousGuild_1 = require("./AnonymousGuild");
|
|
5
5
|
/**
|
|
6
6
|
* Represent Discord Guild Preview Object
|
|
7
|
-
* @link https://discord.com/developers/
|
|
7
|
+
* @link https://docs.discord.com/developers/resources/guild#guild-preview-object
|
|
8
8
|
*/
|
|
9
9
|
class GuildPreview extends AnonymousGuild_1.AnonymousGuild {
|
|
10
10
|
constructor(client, data) {
|
|
@@ -11,6 +11,19 @@ export declare class GuildRole extends DiscordBase {
|
|
|
11
11
|
readonly guildId: string;
|
|
12
12
|
permissions: PermissionsBitField;
|
|
13
13
|
constructor(client: UsingClient, data: APIRole, guildId: string);
|
|
14
|
+
/**
|
|
15
|
+
* Compares the hierarchy positions of two roles.
|
|
16
|
+
* Discord ranks the lower snowflake higher when roles share the same position.
|
|
17
|
+
* @returns A positive number when the first role is higher, a negative number when the second role is higher, or 0
|
|
18
|
+
* when both roles have the same position and ID.
|
|
19
|
+
*/
|
|
20
|
+
static comparePositions(first: Pick<APIRole, 'id' | 'position'>, second: Pick<APIRole, 'id' | 'position'>): number;
|
|
21
|
+
/**
|
|
22
|
+
* Compares this role's hierarchy position with another role.
|
|
23
|
+
* @returns A positive number when this role is higher, a negative number when the other role is higher, or 0 when
|
|
24
|
+
* both roles have the same position and ID.
|
|
25
|
+
*/
|
|
26
|
+
comparePositionTo(role: Pick<APIRole, 'id' | 'position'>): number;
|
|
14
27
|
guild(mode?: 'rest' | 'flow'): Promise<GuildStructure<'cached' | 'api'>>;
|
|
15
28
|
guild(mode: 'cache'): ReturnCache<GuildStructure<'cached'> | undefined>;
|
|
16
29
|
fetch(force?: boolean): Promise<GuildRoleStructure>;
|
|
@@ -12,6 +12,27 @@ class GuildRole extends DiscordBase_1.DiscordBase {
|
|
|
12
12
|
this.guildId = guildId;
|
|
13
13
|
this.permissions = new Permissions_1.PermissionsBitField(BigInt(data.permissions));
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Compares the hierarchy positions of two roles.
|
|
17
|
+
* Discord ranks the lower snowflake higher when roles share the same position.
|
|
18
|
+
* @returns A positive number when the first role is higher, a negative number when the second role is higher, or 0
|
|
19
|
+
* when both roles have the same position and ID.
|
|
20
|
+
*/
|
|
21
|
+
static comparePositions(first, second) {
|
|
22
|
+
if (first.position !== second.position)
|
|
23
|
+
return first.position - second.position;
|
|
24
|
+
if (first.id === second.id)
|
|
25
|
+
return 0;
|
|
26
|
+
return BigInt(first.id) < BigInt(second.id) ? 1 : -1;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Compares this role's hierarchy position with another role.
|
|
30
|
+
* @returns A positive number when this role is higher, a negative number when the other role is higher, or 0 when
|
|
31
|
+
* both roles have the same position and ID.
|
|
32
|
+
*/
|
|
33
|
+
comparePositionTo(role) {
|
|
34
|
+
return GuildRole.comparePositions(this, role);
|
|
35
|
+
}
|
|
15
36
|
guild(mode = 'flow') {
|
|
16
37
|
switch (mode) {
|
|
17
38
|
case 'cache':
|