@wolfstar/plugin-gateway 0.13.0 → 0.14.0-next-20261009112235
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 +26 -2
- package/dist/esm/index.d.ts +336 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +482 -6
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -5,8 +5,8 @@ import { MemoryEntityCache, applyGatewayDispatch, autoModerationRuleKey, banKey,
|
|
|
5
5
|
import { ActivityType, ApplicationFlags, AuditLogEvent, ButtonStyle, ChannelType, ComponentType, FormattingPatterns, GatewayDispatchEvents, GatewayIntentBits, GatewayOpcodes, GuildFeature, GuildMemberFlags, GuildPremiumTier, GuildScheduledEventStatus, GuildSystemChannelFlags, GuildWidgetStyle, InviteType, MessageFlags, MessageReferenceType, MessageType, OverwriteType, PermissionFlagsBits, PresenceUpdateStatus, RESTJSONErrorCodes, RoleFlags, RouteBases, Routes, SeparatorSpacingSize, StickerFormatType, UserFlags, WebhookType } from "discord-api-types/v10";
|
|
6
6
|
import { ActionRowComponent, Activity as Activity$1, ActivityFlagsBitField as ActivityFlagsBitField$1, AnnouncementChannel as AnnouncementChannel$1, AnnouncementThreadChannel as AnnouncementThreadChannel$1, Attachment as Attachment$1, AttachmentFlagsBitField as AttachmentFlagsBitField$1, AutoModerationRule as AutoModerationRule$1, BitField, BitField as BitField$1, CategoryChannel as CategoryChannel$1, Channel as Channel$1, ChannelFlagsBitField as ChannelFlagsBitField$1, ChannelSelectMenuComponent as ChannelSelectMenuComponent$1, Component as Component$1, ContainerComponent as ContainerComponent$1, DMChannel as DMChannel$1, Embed as Embed$1, Emoji as Emoji$1, FileComponent as FileComponent$1, FileUploadComponent as FileUploadComponent$1, ForumChannel as ForumChannel$1, GroupDMChannel as GroupDMChannel$1, InteractiveButtonComponent as InteractiveButtonComponent$1, Invite, LinkButtonComponent as LinkButtonComponent$1, MediaChannel as MediaChannel$1, MediaGalleryComponent as MediaGalleryComponent$1, MediaGalleryItem as MediaGalleryItem$1, MentionableSelectMenuComponent as MentionableSelectMenuComponent$1, Message as Message$1, MessageFlagsBitField as MessageFlagsBitField$1, PermissionsBitField, Poll as Poll$1, PollAnswer as PollAnswer$1, PremiumButtonComponent as PremiumButtonComponent$1, Presence as Presence$1, PrivateThreadChannel as PrivateThreadChannel$1, PublicThreadChannel as PublicThreadChannel$1, Reaction, RoleSelectMenuComponent as RoleSelectMenuComponent$1, SectionComponent as SectionComponent$1, SeparatorComponent as SeparatorComponent$1, SoundboardSound as SoundboardSound$1, StageChannel as StageChannel$1, StageInstance as StageInstance$1, Sticker as Sticker$1, StickerPack as StickerPack$1, StringSelectMenuComponent as StringSelectMenuComponent$1, Structure as Structure$1, TextChannel as TextChannel$1, TextDisplayComponent as TextDisplayComponent$1, TextInputComponent as TextInputComponent$1, ThumbnailComponent as ThumbnailComponent$1, UnfurledMediaItem as UnfurledMediaItem$1, User as User$1, UserSelectMenuComponent as UserSelectMenuComponent$1, VoiceChannel as VoiceChannel$1, VoiceState as VoiceState$1, Webhook as Webhook$1 } from "@discordjs/structures";
|
|
7
7
|
import { CDN, DiscordAPIError } from "@discordjs/rest";
|
|
8
|
-
import { basename as basename$1, parse, resolve } from "node:path";
|
|
9
8
|
import { readFile, stat } from "node:fs/promises";
|
|
9
|
+
import { basename as basename$1, parse, resolve } from "node:path";
|
|
10
10
|
import { Collection } from "@discordjs/collection";
|
|
11
11
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
12
12
|
import { randomBytes } from "node:crypto";
|
|
@@ -1166,6 +1166,21 @@ function findName(thing) {
|
|
|
1166
1166
|
return "file.jpg";
|
|
1167
1167
|
}
|
|
1168
1168
|
/**
|
|
1169
|
+
* Finds a custom emoji by its ID in the cache of every guild, like discord.js's `resolveGuildEmoji`.
|
|
1170
|
+
*
|
|
1171
|
+
* @remarks
|
|
1172
|
+
* Emojis are cached per guild, so it enumerates the whole emoji cache: it needs a store able to list its entries, and
|
|
1173
|
+
* never calls the API.
|
|
1174
|
+
*
|
|
1175
|
+
* @param client The client whose cache to search.
|
|
1176
|
+
* @param emojiId The ID of the emoji.
|
|
1177
|
+
* @returns The emoji, `null` when no cached guild has it.
|
|
1178
|
+
* @throws {TypeError} When the emoji cache cannot enumerate its entries.
|
|
1179
|
+
*/
|
|
1180
|
+
function resolveGuildEmoji(client, emojiId) {
|
|
1181
|
+
return client.guilds.emojis("").findCachedInAnyGuild(emojiId);
|
|
1182
|
+
}
|
|
1183
|
+
/**
|
|
1169
1184
|
* Resolves a SKU, or its ID, to its ID.
|
|
1170
1185
|
*
|
|
1171
1186
|
* @param resolvable The SKU or its ID.
|
|
@@ -1530,8 +1545,8 @@ function isBufferResolvable(file) {
|
|
|
1530
1545
|
return typeof file === "string" || file instanceof Uint8Array || file instanceof ArrayBuffer || file instanceof Blob || typeof file === "object" && file !== null && Symbol.asyncIterator in file;
|
|
1531
1546
|
}
|
|
1532
1547
|
function nameOf(path) {
|
|
1533
|
-
if (/^https?:\/\//.test(path)) return basename
|
|
1534
|
-
return basename
|
|
1548
|
+
if (/^https?:\/\//.test(path)) return basename(new URL(path).pathname) || "file.jpg";
|
|
1549
|
+
return basename(path);
|
|
1535
1550
|
}
|
|
1536
1551
|
|
|
1537
1552
|
//#endregion
|
|
@@ -8678,11 +8693,30 @@ var GuildEmojiManager = class extends CachedManager {
|
|
|
8678
8693
|
* @throws {TypeError} When the store cannot enumerate its entries.
|
|
8679
8694
|
*/
|
|
8680
8695
|
async listCached() {
|
|
8696
|
+
return this.collectCached((key) => key.startsWith(`${this.guildId}:`));
|
|
8697
|
+
}
|
|
8698
|
+
/**
|
|
8699
|
+
* Finds a custom emoji by its ID across every guild held in the cache, without calling the API.
|
|
8700
|
+
*
|
|
8701
|
+
* @remarks
|
|
8702
|
+
* Emojis are keyed by guild and ID, so it enumerates the whole entity cache like {@link GuildEmojiManager.listCached}.
|
|
8703
|
+
* The manager's own guild plays no part in the lookup.
|
|
8704
|
+
*
|
|
8705
|
+
* @param emojiId The ID of the emoji.
|
|
8706
|
+
* @returns The cached emoji, `null` when no guild has it or this entity is not cached.
|
|
8707
|
+
* @throws {TypeError} When the store cannot enumerate its entries.
|
|
8708
|
+
* @internal
|
|
8709
|
+
*/
|
|
8710
|
+
async findCachedInAnyGuild(emojiId) {
|
|
8711
|
+
const suffix = `:${emojiId}`;
|
|
8712
|
+
const [emoji] = await this.collectCached((key) => key.endsWith(suffix), 1);
|
|
8713
|
+
return emoji ?? null;
|
|
8714
|
+
}
|
|
8715
|
+
async collectCached(matches, limit = Infinity) {
|
|
8681
8716
|
const cache = this.iterableCache();
|
|
8682
8717
|
if (!cache) return [];
|
|
8683
|
-
const prefix = `${this.guildId}:`;
|
|
8684
8718
|
const keys = await this.guard("keys", null, () => cache.keys(), []);
|
|
8685
|
-
const values = await Promise.all(keys.filter(
|
|
8719
|
+
const values = await Promise.all(keys.filter(matches).slice(0, limit).map((key) => this.guard("get", key, () => cache.get(key), void 0)));
|
|
8686
8720
|
return Promise.all(values.filter((value) => value !== void 0).map((value) => this._build(value)));
|
|
8687
8721
|
}
|
|
8688
8722
|
async fetchRaw(emojiId) {
|
|
@@ -15266,6 +15300,435 @@ var UserManager = class extends CachedManager {
|
|
|
15266
15300
|
}
|
|
15267
15301
|
};
|
|
15268
15302
|
|
|
15303
|
+
//#endregion
|
|
15304
|
+
//#region src/structures/applications/Application.ts
|
|
15305
|
+
/**
|
|
15306
|
+
* The public attributes of an application, like discord.js's `Application`.
|
|
15307
|
+
*
|
|
15308
|
+
* @typeParam Data The raw application data this structure wraps.
|
|
15309
|
+
*/
|
|
15310
|
+
var Application = class extends Structure {
|
|
15311
|
+
get id() {
|
|
15312
|
+
return this[kData].id;
|
|
15313
|
+
}
|
|
15314
|
+
/**
|
|
15315
|
+
* The name of the application, or `null` while it is not known.
|
|
15316
|
+
*/
|
|
15317
|
+
get name() {
|
|
15318
|
+
return this[kData].name ?? null;
|
|
15319
|
+
}
|
|
15320
|
+
/**
|
|
15321
|
+
* The description of the application, or `null` if it has none or is not known.
|
|
15322
|
+
*/
|
|
15323
|
+
get description() {
|
|
15324
|
+
return this[kData].description ?? null;
|
|
15325
|
+
}
|
|
15326
|
+
/**
|
|
15327
|
+
* The hash of the application's icon, or `null` if it has none or is not known.
|
|
15328
|
+
*/
|
|
15329
|
+
get icon() {
|
|
15330
|
+
return this[kData].icon ?? null;
|
|
15331
|
+
}
|
|
15332
|
+
/**
|
|
15333
|
+
* The hash of the application's cover image, or `null` if it has none or is not known.
|
|
15334
|
+
*/
|
|
15335
|
+
get cover() {
|
|
15336
|
+
return this[kData].cover_image ?? null;
|
|
15337
|
+
}
|
|
15338
|
+
get createdTimestamp() {
|
|
15339
|
+
return snowflakeTimestamp(this.id);
|
|
15340
|
+
}
|
|
15341
|
+
get createdAt() {
|
|
15342
|
+
return new Date(this.createdTimestamp);
|
|
15343
|
+
}
|
|
15344
|
+
/**
|
|
15345
|
+
* Gets the URL of the application's icon, or `null` if it has none.
|
|
15346
|
+
*
|
|
15347
|
+
* @param options The image options.
|
|
15348
|
+
*/
|
|
15349
|
+
iconURL(options) {
|
|
15350
|
+
const { icon } = this[kData];
|
|
15351
|
+
return icon ? cdn.appIcon(this.id, icon, options) : null;
|
|
15352
|
+
}
|
|
15353
|
+
/**
|
|
15354
|
+
* Gets the URL of the application's cover image, or `null` if it has none.
|
|
15355
|
+
*
|
|
15356
|
+
* @param options The image options.
|
|
15357
|
+
*/
|
|
15358
|
+
coverURL(options) {
|
|
15359
|
+
const { cover_image: cover } = this[kData];
|
|
15360
|
+
return cover ? cdn.appIcon(this.id, cover, options) : null;
|
|
15361
|
+
}
|
|
15362
|
+
/**
|
|
15363
|
+
* The name of the application, its ID while the name is not known.
|
|
15364
|
+
*/
|
|
15365
|
+
toString() {
|
|
15366
|
+
return this.name ?? this.id;
|
|
15367
|
+
}
|
|
15368
|
+
};
|
|
15369
|
+
|
|
15370
|
+
//#endregion
|
|
15371
|
+
//#region src/structures/applications/TeamMember.ts
|
|
15372
|
+
/**
|
|
15373
|
+
* A member of a {@link Team}, like discord.js's `TeamMember`.
|
|
15374
|
+
*/
|
|
15375
|
+
var TeamMember = class extends Structure {
|
|
15376
|
+
#user = null;
|
|
15377
|
+
/**
|
|
15378
|
+
* @param data The raw team member.
|
|
15379
|
+
* @param relations The team the member belongs to, set by the team itself.
|
|
15380
|
+
*/
|
|
15381
|
+
constructor(data, relations = {}) {
|
|
15382
|
+
super(data, relations);
|
|
15383
|
+
}
|
|
15384
|
+
/**
|
|
15385
|
+
* The ID of the member's user.
|
|
15386
|
+
*/
|
|
15387
|
+
get id() {
|
|
15388
|
+
return this[kData].user.id;
|
|
15389
|
+
}
|
|
15390
|
+
/**
|
|
15391
|
+
* The team the member belongs to, or `null` when the member was built by hand.
|
|
15392
|
+
*/
|
|
15393
|
+
get team() {
|
|
15394
|
+
return this[kRelations].team ?? null;
|
|
15395
|
+
}
|
|
15396
|
+
/**
|
|
15397
|
+
* The permissions of the member in the team. Discord only ever sends `["*"]`.
|
|
15398
|
+
*/
|
|
15399
|
+
get permissions() {
|
|
15400
|
+
return this[kData].permissions;
|
|
15401
|
+
}
|
|
15402
|
+
/**
|
|
15403
|
+
* Whether the member accepted the invite to the team, or is still invited.
|
|
15404
|
+
*/
|
|
15405
|
+
get membershipState() {
|
|
15406
|
+
return this[kData].membership_state;
|
|
15407
|
+
}
|
|
15408
|
+
/**
|
|
15409
|
+
* The role of the member in the team.
|
|
15410
|
+
*/
|
|
15411
|
+
get role() {
|
|
15412
|
+
return this[kData].role;
|
|
15413
|
+
}
|
|
15414
|
+
/**
|
|
15415
|
+
* The user of the member.
|
|
15416
|
+
*/
|
|
15417
|
+
get user() {
|
|
15418
|
+
const source = this[kData].user;
|
|
15419
|
+
if (this.#user?.source !== source) {
|
|
15420
|
+
const user = new User(source);
|
|
15421
|
+
const client = this[kClient];
|
|
15422
|
+
this.#user = {
|
|
15423
|
+
source,
|
|
15424
|
+
value: client ? bindClient(user, client) : user
|
|
15425
|
+
};
|
|
15426
|
+
}
|
|
15427
|
+
return this.#user.value;
|
|
15428
|
+
}
|
|
15429
|
+
/**
|
|
15430
|
+
* The mention of the member's user.
|
|
15431
|
+
*/
|
|
15432
|
+
toString() {
|
|
15433
|
+
return `<@${this.id}>`;
|
|
15434
|
+
}
|
|
15435
|
+
};
|
|
15436
|
+
|
|
15437
|
+
//#endregion
|
|
15438
|
+
//#region src/structures/applications/Team.ts
|
|
15439
|
+
/**
|
|
15440
|
+
* A team of developers owning an application, like discord.js's `Team`.
|
|
15441
|
+
*/
|
|
15442
|
+
var Team = class extends Structure {
|
|
15443
|
+
#members = null;
|
|
15444
|
+
get id() {
|
|
15445
|
+
return this[kData].id;
|
|
15446
|
+
}
|
|
15447
|
+
get name() {
|
|
15448
|
+
return this[kData].name;
|
|
15449
|
+
}
|
|
15450
|
+
/**
|
|
15451
|
+
* The hash of the team's icon, or `null` if it has none.
|
|
15452
|
+
*/
|
|
15453
|
+
get icon() {
|
|
15454
|
+
return this[kData].icon;
|
|
15455
|
+
}
|
|
15456
|
+
/**
|
|
15457
|
+
* The ID of the user owning the team.
|
|
15458
|
+
*/
|
|
15459
|
+
get ownerId() {
|
|
15460
|
+
return this[kData].owner_user_id;
|
|
15461
|
+
}
|
|
15462
|
+
/**
|
|
15463
|
+
* The members of the team, by the ID of their user.
|
|
15464
|
+
*/
|
|
15465
|
+
get members() {
|
|
15466
|
+
const source = this[kData].members;
|
|
15467
|
+
if (this.#members?.source !== source) {
|
|
15468
|
+
const value = new Collection();
|
|
15469
|
+
const client = this[kClient];
|
|
15470
|
+
for (const data of source) {
|
|
15471
|
+
const member = new TeamMember(data, { team: this });
|
|
15472
|
+
if (client) bindClient(member, client);
|
|
15473
|
+
value.set(member.id, member);
|
|
15474
|
+
}
|
|
15475
|
+
this.#members = {
|
|
15476
|
+
source,
|
|
15477
|
+
value
|
|
15478
|
+
};
|
|
15479
|
+
}
|
|
15480
|
+
return this.#members.value;
|
|
15481
|
+
}
|
|
15482
|
+
/**
|
|
15483
|
+
* The member owning the team, if it is among {@link Team.members}.
|
|
15484
|
+
*/
|
|
15485
|
+
get owner() {
|
|
15486
|
+
return this.members.get(this.ownerId) ?? null;
|
|
15487
|
+
}
|
|
15488
|
+
get createdTimestamp() {
|
|
15489
|
+
return snowflakeTimestamp(this.id);
|
|
15490
|
+
}
|
|
15491
|
+
get createdAt() {
|
|
15492
|
+
return new Date(this.createdTimestamp);
|
|
15493
|
+
}
|
|
15494
|
+
/**
|
|
15495
|
+
* Gets the URL of the team's icon, or `null` if it has none.
|
|
15496
|
+
*
|
|
15497
|
+
* @param options The image options.
|
|
15498
|
+
*/
|
|
15499
|
+
iconURL(options) {
|
|
15500
|
+
const { icon } = this[kData];
|
|
15501
|
+
return icon ? cdn.teamIcon(this.id, icon, options) : null;
|
|
15502
|
+
}
|
|
15503
|
+
toString() {
|
|
15504
|
+
return this.name;
|
|
15505
|
+
}
|
|
15506
|
+
};
|
|
15507
|
+
|
|
15508
|
+
//#endregion
|
|
15509
|
+
//#region src/structures/applications/ClientApplication.ts
|
|
15510
|
+
function toRoleConnectionMetadata(record) {
|
|
15511
|
+
return {
|
|
15512
|
+
name: record.name,
|
|
15513
|
+
nameLocalizations: record.name_localizations,
|
|
15514
|
+
description: record.description,
|
|
15515
|
+
descriptionLocalizations: record.description_localizations,
|
|
15516
|
+
key: record.key,
|
|
15517
|
+
type: record.type
|
|
15518
|
+
};
|
|
15519
|
+
}
|
|
15520
|
+
function fromInstallParams(params) {
|
|
15521
|
+
return {
|
|
15522
|
+
scopes: params.scopes,
|
|
15523
|
+
permissions: new PermissionsBitField(BigInt(params.permissions)).freeze()
|
|
15524
|
+
};
|
|
15525
|
+
}
|
|
15526
|
+
function toInstallParams(params) {
|
|
15527
|
+
return {
|
|
15528
|
+
scopes: params.scopes,
|
|
15529
|
+
permissions: PermissionsBitField.resolve(params.permissions).toString()
|
|
15530
|
+
};
|
|
15531
|
+
}
|
|
15532
|
+
/**
|
|
15533
|
+
* The application of the bot, the entry point for everything owned by the application rather than by a guild, like
|
|
15534
|
+
* discord.js's `ClientApplication`.
|
|
15535
|
+
*
|
|
15536
|
+
* @remarks
|
|
15537
|
+
* Unlike discord.js, `client.application` exists from the construction of the client, with only its ID known until
|
|
15538
|
+
* `READY` patches in the flags, and {@link ClientApplication.fetch} the rest: check {@link ClientApplication.partial}
|
|
15539
|
+
* before relying on the other fields.
|
|
15540
|
+
*/
|
|
15541
|
+
var ClientApplication = class extends Application {
|
|
15542
|
+
#owner = null;
|
|
15543
|
+
/**
|
|
15544
|
+
* Whether only the ID and flags of the application are known: it has neither been fetched nor edited yet.
|
|
15545
|
+
*/
|
|
15546
|
+
get partial() {
|
|
15547
|
+
return this[kData].name === void 0;
|
|
15548
|
+
}
|
|
15549
|
+
/**
|
|
15550
|
+
* The flags of the application.
|
|
15551
|
+
*/
|
|
15552
|
+
get flags() {
|
|
15553
|
+
return new ApplicationFlagsBitField(this[kData].flags ?? 0).freeze();
|
|
15554
|
+
}
|
|
15555
|
+
/**
|
|
15556
|
+
* The tags describing the application, at most five.
|
|
15557
|
+
*/
|
|
15558
|
+
get tags() {
|
|
15559
|
+
return [...this[kData].tags ?? []];
|
|
15560
|
+
}
|
|
15561
|
+
/**
|
|
15562
|
+
* The scopes and permissions the application asks for when it is added to a guild, or `null` if it sets none.
|
|
15563
|
+
*/
|
|
15564
|
+
get installParams() {
|
|
15565
|
+
const params = this[kData].install_params;
|
|
15566
|
+
return params ? fromInstallParams(params) : null;
|
|
15567
|
+
}
|
|
15568
|
+
/**
|
|
15569
|
+
* The install parameters of the application for each integration type, or `null` if it sets none.
|
|
15570
|
+
*/
|
|
15571
|
+
get integrationTypesConfig() {
|
|
15572
|
+
const config = this[kData].integration_types_config;
|
|
15573
|
+
if (!config) return null;
|
|
15574
|
+
const result = {};
|
|
15575
|
+
for (const [type, value] of Object.entries(config)) {
|
|
15576
|
+
const params = value.oauth2_install_params;
|
|
15577
|
+
result[Number(type)] = { oauth2InstallParams: params ? fromInstallParams(params) : null };
|
|
15578
|
+
}
|
|
15579
|
+
return result;
|
|
15580
|
+
}
|
|
15581
|
+
/**
|
|
15582
|
+
* The URL the application is installed through, instead of Discord's own install link.
|
|
15583
|
+
*/
|
|
15584
|
+
get customInstallURL() {
|
|
15585
|
+
return this[kData].custom_install_url ?? null;
|
|
15586
|
+
}
|
|
15587
|
+
/**
|
|
15588
|
+
* The team owning the application, else the user who does, `null` while it is not known.
|
|
15589
|
+
*/
|
|
15590
|
+
get owner() {
|
|
15591
|
+
const { team, owner } = this[kData];
|
|
15592
|
+
if (!this.#owner || this.#owner.team !== team || this.#owner.user !== owner) {
|
|
15593
|
+
let value = null;
|
|
15594
|
+
if (team) value = new Team(team);
|
|
15595
|
+
else if (owner) value = new User(owner);
|
|
15596
|
+
const client = this[kClient];
|
|
15597
|
+
if (value && client) bindClient(value, client);
|
|
15598
|
+
this.#owner = {
|
|
15599
|
+
team,
|
|
15600
|
+
user: owner,
|
|
15601
|
+
value
|
|
15602
|
+
};
|
|
15603
|
+
}
|
|
15604
|
+
return this.#owner.value;
|
|
15605
|
+
}
|
|
15606
|
+
/**
|
|
15607
|
+
* Whether anyone can add the bot to a guild, or `null` if it is not known.
|
|
15608
|
+
*/
|
|
15609
|
+
get botPublic() {
|
|
15610
|
+
return this[kData].bot_public ?? null;
|
|
15611
|
+
}
|
|
15612
|
+
/**
|
|
15613
|
+
* Whether the bot only joins guilds after the full OAuth2 code grant flow, or `null` if it is not known.
|
|
15614
|
+
*/
|
|
15615
|
+
get botRequireCodeGrant() {
|
|
15616
|
+
return this[kData].bot_require_code_grant ?? null;
|
|
15617
|
+
}
|
|
15618
|
+
/**
|
|
15619
|
+
* The ID of the guild linked to the application, or `null` if there is none.
|
|
15620
|
+
*/
|
|
15621
|
+
get guildId() {
|
|
15622
|
+
return this[kData].guild_id ?? null;
|
|
15623
|
+
}
|
|
15624
|
+
/**
|
|
15625
|
+
* The guild linked to the application, from the cache.
|
|
15626
|
+
*/
|
|
15627
|
+
get guild() {
|
|
15628
|
+
return this.lazyRelation("guild", (client) => cachedGuild(client, this.guildId));
|
|
15629
|
+
}
|
|
15630
|
+
/**
|
|
15631
|
+
* The approximate number of guilds the bot is in, or `null` if it is not known.
|
|
15632
|
+
*/
|
|
15633
|
+
get approximateGuildCount() {
|
|
15634
|
+
return this[kData].approximate_guild_count ?? null;
|
|
15635
|
+
}
|
|
15636
|
+
/**
|
|
15637
|
+
* The approximate number of users who installed the application, or `null` if it is not known.
|
|
15638
|
+
*/
|
|
15639
|
+
get approximateUserInstallCount() {
|
|
15640
|
+
return this[kData].approximate_user_install_count ?? null;
|
|
15641
|
+
}
|
|
15642
|
+
/**
|
|
15643
|
+
* The URL interactions are sent to, or `null` if there is none.
|
|
15644
|
+
*/
|
|
15645
|
+
get interactionsEndpointURL() {
|
|
15646
|
+
return this[kData].interactions_endpoint_url ?? null;
|
|
15647
|
+
}
|
|
15648
|
+
/**
|
|
15649
|
+
* The URL of the role connections verification, or `null` if there is none.
|
|
15650
|
+
*/
|
|
15651
|
+
get roleConnectionsVerificationURL() {
|
|
15652
|
+
return this[kData].role_connections_verification_url ?? null;
|
|
15653
|
+
}
|
|
15654
|
+
/**
|
|
15655
|
+
* The URL event webhooks are sent to, or `null` if there is none.
|
|
15656
|
+
*/
|
|
15657
|
+
get eventWebhooksURL() {
|
|
15658
|
+
return this[kData].event_webhooks_url ?? null;
|
|
15659
|
+
}
|
|
15660
|
+
/**
|
|
15661
|
+
* Whether event webhooks are enabled, or `null` if it is not known.
|
|
15662
|
+
*/
|
|
15663
|
+
get eventWebhooksStatus() {
|
|
15664
|
+
return this[kData].event_webhooks_status ?? null;
|
|
15665
|
+
}
|
|
15666
|
+
/**
|
|
15667
|
+
* The event types sent to {@link ClientApplication.eventWebhooksURL}, or `null` if it is not known.
|
|
15668
|
+
*/
|
|
15669
|
+
get eventWebhooksTypes() {
|
|
15670
|
+
const types = this[kData].event_webhooks_types;
|
|
15671
|
+
return types ? [...types] : null;
|
|
15672
|
+
}
|
|
15673
|
+
/**
|
|
15674
|
+
* Fetches the application from the API, and patches this structure with it.
|
|
15675
|
+
*
|
|
15676
|
+
* @returns This application.
|
|
15677
|
+
*/
|
|
15678
|
+
async fetch() {
|
|
15679
|
+
const data = await this.client.api.applications.getCurrent();
|
|
15680
|
+
return this[kPatch](data);
|
|
15681
|
+
}
|
|
15682
|
+
/**
|
|
15683
|
+
* Edits the application, and patches this structure with the result.
|
|
15684
|
+
*
|
|
15685
|
+
* @param options The fields to edit.
|
|
15686
|
+
* @returns This application.
|
|
15687
|
+
*/
|
|
15688
|
+
async edit(options) {
|
|
15689
|
+
const body = {
|
|
15690
|
+
custom_install_url: options.customInstallURL,
|
|
15691
|
+
description: options.description,
|
|
15692
|
+
event_webhooks_url: options.eventWebhooksURL,
|
|
15693
|
+
event_webhooks_status: options.eventWebhooksStatus,
|
|
15694
|
+
event_webhooks_types: options.eventWebhooksTypes,
|
|
15695
|
+
flags: options.flags === void 0 ? void 0 : Number(ApplicationFlagsBitField.resolve(options.flags)),
|
|
15696
|
+
icon: await resolveImageOption(options.icon),
|
|
15697
|
+
cover_image: await resolveImageOption(options.coverImage),
|
|
15698
|
+
interactions_endpoint_url: options.interactionsEndpointURL,
|
|
15699
|
+
role_connections_verification_url: options.roleConnectionsVerificationURL,
|
|
15700
|
+
tags: options.tags,
|
|
15701
|
+
install_params: options.installParams && toInstallParams(options.installParams),
|
|
15702
|
+
integration_types_config: options.integrationTypesConfig && Object.fromEntries(Object.entries(options.integrationTypesConfig).map(([type, config]) => [type, { oauth2_install_params: config.oauth2InstallParams && toInstallParams(config.oauth2InstallParams) }]))
|
|
15703
|
+
};
|
|
15704
|
+
for (const key of Object.keys(body)) if (body[key] === void 0) delete body[key];
|
|
15705
|
+
const data = await this.client.api.applications.editCurrent(body);
|
|
15706
|
+
return this[kPatch](data);
|
|
15707
|
+
}
|
|
15708
|
+
/**
|
|
15709
|
+
* Fetches the role connection metadata records of the application.
|
|
15710
|
+
*/
|
|
15711
|
+
async fetchRoleConnectionMetadataRecords() {
|
|
15712
|
+
return (await this.client.api.roleConnections.getMetadataRecords(this.id)).map(toRoleConnectionMetadata);
|
|
15713
|
+
}
|
|
15714
|
+
/**
|
|
15715
|
+
* Replaces the role connection metadata records of the application.
|
|
15716
|
+
*
|
|
15717
|
+
* @param records The records to set, up to five. Records left out are removed.
|
|
15718
|
+
* @returns The records as stored.
|
|
15719
|
+
*/
|
|
15720
|
+
async editRoleConnectionMetadataRecords(records) {
|
|
15721
|
+
return (await this.client.api.roleConnections.updateMetadataRecords(this.id, records.map((record) => ({
|
|
15722
|
+
key: record.key,
|
|
15723
|
+
name: record.name,
|
|
15724
|
+
name_localizations: record.nameLocalizations,
|
|
15725
|
+
description: record.description,
|
|
15726
|
+
description_localizations: record.descriptionLocalizations,
|
|
15727
|
+
type: record.type
|
|
15728
|
+
})))).map(toRoleConnectionMetadata);
|
|
15729
|
+
}
|
|
15730
|
+
};
|
|
15731
|
+
|
|
15269
15732
|
//#endregion
|
|
15270
15733
|
//#region src/structures/users/ClientUser.ts
|
|
15271
15734
|
/**
|
|
@@ -15823,6 +16286,7 @@ const DispatchHandlers = {
|
|
|
15823
16286
|
build: (client, data, _state, shardId) => {
|
|
15824
16287
|
const user = new ClientUser(data.user);
|
|
15825
16288
|
client.user = user;
|
|
16289
|
+
client.application[kPatch](data.application);
|
|
15826
16290
|
return [shardId, user];
|
|
15827
16291
|
}
|
|
15828
16292
|
},
|
|
@@ -17432,6 +17896,17 @@ var GatewayClient = class extends Client {
|
|
|
17432
17896
|
* `null` if neither source answers (the failure is reported through `error`).
|
|
17433
17897
|
*/
|
|
17434
17898
|
user = null;
|
|
17899
|
+
/**
|
|
17900
|
+
* The application of the bot, like discord.js's `Client#application`.
|
|
17901
|
+
*
|
|
17902
|
+
* @remarks
|
|
17903
|
+
* Unlike discord.js, it is never `null`: it is built from {@link GatewayClientOptions.clientId} when the client is,
|
|
17904
|
+
* so it exists before `READY` and without any gateway connection. It is then partial, see
|
|
17905
|
+
* {@link ClientApplication.partial}: `READY` patches the same instance with the application's flags, and
|
|
17906
|
+
* {@link ClientApplication.fetch} with the rest. It is kept on the client, not in the cache: it is a single small
|
|
17907
|
+
* object, and every process gets the same `READY`.
|
|
17908
|
+
*/
|
|
17909
|
+
application;
|
|
17435
17910
|
users;
|
|
17436
17911
|
guilds;
|
|
17437
17912
|
channels;
|
|
@@ -17511,6 +17986,7 @@ var GatewayClient = class extends Client {
|
|
|
17511
17986
|
this.#shardCount = options.shardCount ?? null;
|
|
17512
17987
|
this.#intents = Number(options.intents);
|
|
17513
17988
|
this.#token = options.discordToken ?? process.env.DISCORD_TOKEN;
|
|
17989
|
+
this.application = bindClient(new ClientApplication({ id: this.id }), this);
|
|
17514
17990
|
this.users = new UserManager(this);
|
|
17515
17991
|
this.guilds = new GuildManager(this);
|
|
17516
17992
|
this.channels = new ChannelManager(this);
|
|
@@ -18334,5 +18810,5 @@ const DefaultSweeperSettings = Object.freeze({
|
|
|
18334
18810
|
});
|
|
18335
18811
|
|
|
18336
18812
|
//#endregion
|
|
18337
|
-
export { Action, ActionRow, ActionsManager, Activity, ActivityFlagsBitField, AnnouncementChannel, AnnouncementThreadChannel, AnonymousGuild, ApplicationFlagsBitField, AppliedTagsMixin, Attachment, AttachmentBuilder, AttachmentFlagsBitField, AutoModerationActionExecution, AutoModerationRule, AutoModerationRuleManager, BaseChannel, BaseChannelMixin, BaseInvite, BaseManager, BitField, CachedManager, CategoryChannel, CategoryChannelChildManager, Channel, ChannelFlagsBitField, ChannelManager, ChannelMessageManager, ChannelOwnerMixin, ChannelParentMixin, ChannelPermissionMixin, ChannelSelectMenuComponent, ChannelSlowmodeMixin, ChannelThreadManager, ChannelThreadsMixin, ChannelTopicMixin, ChannelWebhooksMixin, CheckboxComponent, CheckboxGroupComponent, ClientUser, CollectionCache, Colors, Component, ComponentMixin, ContainerComponent, DMChannel, DMChannelMixin, DataManager, DefaultSweeperSettings, DispatchAction, DispatchHandlers, DispatchQueue, DispatchStateCodecs, DispatchTimeoutError, Embed, Emoji, EntityStoreCache, EventGatewayListener, FileComponent, FileUploadComponent, ForumChannel, GatewayClient, GatewayError, GatewayErrorCodes, GatewayErrorMessages, GatewayEvents, GatewayRangeError, GatewaySessionStoreError, GatewayTypeError, GroupDMChannel, GroupDMInvite, GroupDMMixin, Guild, GuildAuditLogsEntry, GuildBan, GuildBanManager, GuildChannelFields, GuildChannelInfoTimeoutError, GuildChannelManager, GuildChannelMixin, GuildEmoji, GuildEmojiManager, GuildEmojiRoleManager, GuildIntegrationManager, GuildInvite, GuildInviteManager, GuildManager, GuildMember, GuildMemberFlagsBitField, GuildMemberManager, GuildMemberRoleManager, GuildMembersRateLimitError, GuildMembersTimeoutError, GuildOnboarding, GuildOnboardingPrompt, GuildOnboardingPromptOption, GuildPreview, GuildScheduledEvent, GuildScheduledEventManager, GuildSoundboardSoundManager, GuildSoundboardSoundsTimeoutError, GuildStickerManager, GuildTemplate, GuildTemplateManager, GuildTemplatesPattern, Integration, IntentsBitField, InteractiveButtonComponent, InviteGuild, InvitesPattern, LabelComponent, LinkButtonComponent, MediaChannel, MediaGalleryComponent, MediaGalleryItem, MentionableSelectMenuComponent, Message, MessageFlagsBitField, MessageManager, MessageMentions, MessagePayload, MessageReaction, Mixin, MultiDispatchAction, MultiDispatchHandlers, NullCache, NumberFlagsBitField, Partials, PermissionOverwriteManager, PermissionOverwrites, PermissionsBitField, Poll, PollAnswer, PollAnswerVoterManager, PremiumButtonComponent, Presence, PresenceManager, PrivateThreadChannel, PublicThreadChannel, RadioGroupComponent, ReactionEmoji, ReactionManager, ReactionUserManager, RegisterAsGatewayListener, RichPresenceAssets, Role, RoleFlagsBitField, RoleManager, RoleSelectMenuComponent, SectionComponent, SeparatorComponent, SoundboardSound, StageChannel, StageInstance, StageInstanceManager, Sticker, StickerPack, StringSelectMenuComponent, Structure, StructureMixin, SweepableEntityNames, Sweepers, SystemChannelFlagsBitField, TextChannel, TextChannelMixin, TextDisplayComponent, TextGuildChannelMixin, TextInputComponent, ThreadChannelMemberManager, ThreadChannelMixin, ThreadManager, ThreadMember, ThreadMemberManager, ThreadOnlyChannelMixin, ThumbnailComponent, Typing, UnfurledMediaItem, User, UserFlagsBitField, UserManager, UserSelectMenuComponent, VoiceChannel, VoiceChannelMixin, VoiceState, VoiceStateManager, Webhook, WebhookManager, WebhookMixin, WelcomeScreen, Widget, WidgetMember, basename, bindClient, cacheWithLimits, cleanCodeBlockContent, cleanContent, compareRolePositions, computeCachedPermissionsIn, computeCachedTargetPermissions, computeChannelPermissions, computeGuildPermissions, computePermissionsIn, computePositions, computeTargetPermissions, createChannel, createComponent, createInvite, discordSort, dispatchPartition, fillGuildId, findComponentByCustomId, findName, flatten, getGatewayClient, getSortableGroupTypes, initStructure, isDeepEqual, isThreadChannelType, kClient, kClone, kData, kPatch, kPatchRelations, kRelations, lazyRelation, makeError, makePlainError, moveElementInArray, parseEmoji, parseWebhookURL, requireGuild, requireMe, resolveBase64, resolveCode, resolveColor, resolveFile, resolveGuildTemplateCode, resolveId, resolveImage, resolveImageOption, resolveInviteCode, resolveOverwriteOptions, resolvePartialEmoji, resolveSKUId, sameOverwrites, snakeCase, snowflakeTimestamp, toAPIOverwrite, toChannelBody, toSnakeCase, transformAPIAuditLogChange, transformAPIAutoModerationAction, transformAPIAutoModerationRuleTriggerMetadata, transformAPIAvatarDecorationData, transformAPIChannelMention, transformAPIEmbedAsset, transformAPIEmbedAuthor, transformAPIEmbedFooter, transformAPIGuildDefaultReaction, transformAPIGuildForumTag, transformAPIGuildScheduledEventEntityMetadata, transformAPIGuildScheduledEventRecurrenceRule, transformAPIIncidentsData, transformAPIMessageActivity, transformAPIMessageCall, transformAPIMessageInteractionMetadata, transformAPIMessageReference, transformAPIMessageSharedClientTheme, transformAPIRoleSubscriptionData, transformAPIRoleTags, transformAPIUserPrimaryGuild, transformAutoModerationAction, transformAutoModerationRuleTriggerMetadata, transformCollectibles, transformGuildDefaultReaction, transformGuildForumTag, transformGuildScheduledEventRecurrenceRule, transformResolved, verifyString, withGuildId };
|
|
18813
|
+
export { Action, ActionRow, ActionsManager, Activity, ActivityFlagsBitField, AnnouncementChannel, AnnouncementThreadChannel, AnonymousGuild, Application, ApplicationFlagsBitField, AppliedTagsMixin, Attachment, AttachmentBuilder, AttachmentFlagsBitField, AutoModerationActionExecution, AutoModerationRule, AutoModerationRuleManager, BaseChannel, BaseChannelMixin, BaseInvite, BaseManager, BitField, CachedManager, CategoryChannel, CategoryChannelChildManager, Channel, ChannelFlagsBitField, ChannelManager, ChannelMessageManager, ChannelOwnerMixin, ChannelParentMixin, ChannelPermissionMixin, ChannelSelectMenuComponent, ChannelSlowmodeMixin, ChannelThreadManager, ChannelThreadsMixin, ChannelTopicMixin, ChannelWebhooksMixin, CheckboxComponent, CheckboxGroupComponent, ClientApplication, ClientUser, CollectionCache, Colors, Component, ComponentMixin, ContainerComponent, DMChannel, DMChannelMixin, DataManager, DefaultSweeperSettings, DispatchAction, DispatchHandlers, DispatchQueue, DispatchStateCodecs, DispatchTimeoutError, Embed, Emoji, EntityStoreCache, EventGatewayListener, FileComponent, FileUploadComponent, ForumChannel, GatewayClient, GatewayError, GatewayErrorCodes, GatewayErrorMessages, GatewayEvents, GatewayRangeError, GatewaySessionStoreError, GatewayTypeError, GroupDMChannel, GroupDMInvite, GroupDMMixin, Guild, GuildAuditLogsEntry, GuildBan, GuildBanManager, GuildChannelFields, GuildChannelInfoTimeoutError, GuildChannelManager, GuildChannelMixin, GuildEmoji, GuildEmojiManager, GuildEmojiRoleManager, GuildIntegrationManager, GuildInvite, GuildInviteManager, GuildManager, GuildMember, GuildMemberFlagsBitField, GuildMemberManager, GuildMemberRoleManager, GuildMembersRateLimitError, GuildMembersTimeoutError, GuildOnboarding, GuildOnboardingPrompt, GuildOnboardingPromptOption, GuildPreview, GuildScheduledEvent, GuildScheduledEventManager, GuildSoundboardSoundManager, GuildSoundboardSoundsTimeoutError, GuildStickerManager, GuildTemplate, GuildTemplateManager, GuildTemplatesPattern, Integration, IntentsBitField, InteractiveButtonComponent, InviteGuild, InvitesPattern, LabelComponent, LinkButtonComponent, MediaChannel, MediaGalleryComponent, MediaGalleryItem, MentionableSelectMenuComponent, Message, MessageFlagsBitField, MessageManager, MessageMentions, MessagePayload, MessageReaction, Mixin, MultiDispatchAction, MultiDispatchHandlers, NullCache, NumberFlagsBitField, Partials, PermissionOverwriteManager, PermissionOverwrites, PermissionsBitField, Poll, PollAnswer, PollAnswerVoterManager, PremiumButtonComponent, Presence, PresenceManager, PrivateThreadChannel, PublicThreadChannel, RadioGroupComponent, ReactionEmoji, ReactionManager, ReactionUserManager, RegisterAsGatewayListener, RichPresenceAssets, Role, RoleFlagsBitField, RoleManager, RoleSelectMenuComponent, SectionComponent, SeparatorComponent, SoundboardSound, StageChannel, StageInstance, StageInstanceManager, Sticker, StickerPack, StringSelectMenuComponent, Structure, StructureMixin, SweepableEntityNames, Sweepers, SystemChannelFlagsBitField, Team, TeamMember, TextChannel, TextChannelMixin, TextDisplayComponent, TextGuildChannelMixin, TextInputComponent, ThreadChannelMemberManager, ThreadChannelMixin, ThreadManager, ThreadMember, ThreadMemberManager, ThreadOnlyChannelMixin, ThumbnailComponent, Typing, UnfurledMediaItem, User, UserFlagsBitField, UserManager, UserSelectMenuComponent, VoiceChannel, VoiceChannelMixin, VoiceState, VoiceStateManager, Webhook, WebhookManager, WebhookMixin, WelcomeScreen, Widget, WidgetMember, basename, bindClient, cacheWithLimits, cleanCodeBlockContent, cleanContent, compareRolePositions, computeCachedPermissionsIn, computeCachedTargetPermissions, computeChannelPermissions, computeGuildPermissions, computePermissionsIn, computePositions, computeTargetPermissions, createChannel, createComponent, createInvite, discordSort, dispatchPartition, fillGuildId, findComponentByCustomId, findName, flatten, getGatewayClient, getSortableGroupTypes, initStructure, isDeepEqual, isThreadChannelType, kClient, kClone, kData, kPatch, kPatchRelations, kRelations, lazyRelation, makeError, makePlainError, moveElementInArray, parseEmoji, parseWebhookURL, requireGuild, requireMe, resolveBase64, resolveCode, resolveColor, resolveFile, resolveGuildEmoji, resolveGuildTemplateCode, resolveId, resolveImage, resolveImageOption, resolveInviteCode, resolveOverwriteOptions, resolvePartialEmoji, resolveSKUId, sameOverwrites, snakeCase, snowflakeTimestamp, toAPIOverwrite, toChannelBody, toSnakeCase, transformAPIAuditLogChange, transformAPIAutoModerationAction, transformAPIAutoModerationRuleTriggerMetadata, transformAPIAvatarDecorationData, transformAPIChannelMention, transformAPIEmbedAsset, transformAPIEmbedAuthor, transformAPIEmbedFooter, transformAPIGuildDefaultReaction, transformAPIGuildForumTag, transformAPIGuildScheduledEventEntityMetadata, transformAPIGuildScheduledEventRecurrenceRule, transformAPIIncidentsData, transformAPIMessageActivity, transformAPIMessageCall, transformAPIMessageInteractionMetadata, transformAPIMessageReference, transformAPIMessageSharedClientTheme, transformAPIRoleSubscriptionData, transformAPIRoleTags, transformAPIUserPrimaryGuild, transformAutoModerationAction, transformAutoModerationRuleTriggerMetadata, transformCollectibles, transformGuildDefaultReaction, transformGuildForumTag, transformGuildScheduledEventRecurrenceRule, transformResolved, verifyString, withGuildId };
|
|
18338
18814
|
//# sourceMappingURL=index.js.map
|