@fluxerjs/core 1.1.0 → 1.1.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/LICENSE +203 -0
- package/dist/{Channel-WJZZSNML.mjs → Channel-YB3LWDHZ.mjs} +2 -1
- package/dist/{ClientUser-DJO2FS7P.mjs → ClientUser-QQXLZ5WP.mjs} +1 -1
- package/dist/{Guild-2P77HBQM.mjs → Guild-MDW7KF33.mjs} +3 -2
- package/dist/{MessageReaction-V4UZ7OXE.mjs → MessageReaction-GYQNJ6GX.mjs} +2 -1
- package/dist/{Role-5MWSGL66.mjs → Role-N2ZEMRUQ.mjs} +1 -1
- package/dist/chunk-5I54OXBG.mjs +111 -0
- package/dist/{chunk-JHNKZIHY.mjs → chunk-G2YVDCRB.mjs} +2 -2
- package/dist/{chunk-4XJIM6SC.mjs → chunk-KOTF4TTZ.mjs} +117 -29
- package/dist/chunk-PU73YRKJ.mjs +27 -0
- package/dist/{chunk-CEABHTAF.mjs → chunk-YL5S4W6R.mjs} +22 -1
- package/dist/{chunk-LU2SNC5G.mjs → chunk-ZKKBIQBA.mjs} +33 -12
- package/dist/index.d.mts +134 -6
- package/dist/index.d.ts +134 -6
- package/dist/index.js +548 -254
- package/dist/index.mjs +130 -38
- package/package.json +8 -8
- package/dist/chunk-DQ4TNBPG.mjs +0 -63
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ErrorCodes,
|
|
3
|
+
FluxerError
|
|
4
|
+
} from "./chunk-PU73YRKJ.mjs";
|
|
1
5
|
import {
|
|
2
6
|
Events
|
|
3
7
|
} from "./chunk-AH7KYH2Z.mjs";
|
|
@@ -9,6 +13,8 @@ import {
|
|
|
9
13
|
} from "./chunk-XNS4O6QJ.mjs";
|
|
10
14
|
|
|
11
15
|
// src/client/MessageManager.ts
|
|
16
|
+
import { Routes } from "@fluxerjs/types";
|
|
17
|
+
import { FluxerAPIError, RateLimitError } from "@fluxerjs/rest";
|
|
12
18
|
var MessageManager = class {
|
|
13
19
|
constructor(client, channelId) {
|
|
14
20
|
this.client = client;
|
|
@@ -21,7 +27,22 @@ var MessageManager = class {
|
|
|
21
27
|
* @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
|
|
22
28
|
*/
|
|
23
29
|
async fetch(messageId) {
|
|
24
|
-
|
|
30
|
+
try {
|
|
31
|
+
const { Message } = await import("./Message-OFIVTTAZ.mjs");
|
|
32
|
+
const data = await this.client.rest.get(
|
|
33
|
+
Routes.channelMessage(this.channelId, messageId)
|
|
34
|
+
);
|
|
35
|
+
return new Message(this.client, data);
|
|
36
|
+
} catch (err) {
|
|
37
|
+
if (err instanceof RateLimitError) throw err;
|
|
38
|
+
if (err instanceof FluxerAPIError && err.statusCode === 404) {
|
|
39
|
+
throw new FluxerError(`Message ${messageId} not found in channel ${this.channelId}`, {
|
|
40
|
+
code: ErrorCodes.MessageNotFound,
|
|
41
|
+
cause: err
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
|
|
45
|
+
}
|
|
25
46
|
}
|
|
26
47
|
};
|
|
27
48
|
|
|
@@ -78,7 +99,7 @@ var MessageCollector = class extends EventEmitter {
|
|
|
78
99
|
};
|
|
79
100
|
|
|
80
101
|
// src/structures/Channel.ts
|
|
81
|
-
import { ChannelType, Routes } from "@fluxerjs/types";
|
|
102
|
+
import { ChannelType, Routes as Routes2 } from "@fluxerjs/types";
|
|
82
103
|
import { emitDeprecationWarning } from "@fluxerjs/util";
|
|
83
104
|
var Channel = class _Channel extends Base {
|
|
84
105
|
/** Whether this channel has a send method (TextChannel, DMChannel). */
|
|
@@ -145,7 +166,7 @@ var Channel = class _Channel extends Base {
|
|
|
145
166
|
* @param messageIds - Array of message IDs to delete (2–100)
|
|
146
167
|
*/
|
|
147
168
|
async bulkDeleteMessages(messageIds) {
|
|
148
|
-
await this.client.rest.post(
|
|
169
|
+
await this.client.rest.post(Routes2.channelBulkDelete(this.id), {
|
|
149
170
|
body: { message_ids: messageIds },
|
|
150
171
|
auth: true
|
|
151
172
|
});
|
|
@@ -154,7 +175,7 @@ var Channel = class _Channel extends Base {
|
|
|
154
175
|
* Send a typing indicator to the channel. Lasts ~10 seconds.
|
|
155
176
|
*/
|
|
156
177
|
async sendTyping() {
|
|
157
|
-
await this.client.rest.post(
|
|
178
|
+
await this.client.rest.post(Routes2.channelTyping(this.id), { auth: true });
|
|
158
179
|
}
|
|
159
180
|
};
|
|
160
181
|
var GuildChannel = class extends Channel {
|
|
@@ -179,7 +200,7 @@ var GuildChannel = class extends Channel {
|
|
|
179
200
|
*/
|
|
180
201
|
async createWebhook(options) {
|
|
181
202
|
const { Webhook } = await import("./Webhook-RWDDYW2Q.mjs");
|
|
182
|
-
const data = await this.client.rest.post(
|
|
203
|
+
const data = await this.client.rest.post(Routes2.channelWebhooks(this.id), {
|
|
183
204
|
body: options,
|
|
184
205
|
auth: true
|
|
185
206
|
});
|
|
@@ -191,7 +212,7 @@ var GuildChannel = class extends Channel {
|
|
|
191
212
|
*/
|
|
192
213
|
async fetchWebhooks() {
|
|
193
214
|
const { Webhook } = await import("./Webhook-RWDDYW2Q.mjs");
|
|
194
|
-
const data = await this.client.rest.get(
|
|
215
|
+
const data = await this.client.rest.get(Routes2.channelWebhooks(this.id));
|
|
195
216
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
196
217
|
return list.map((w) => new Webhook(this.client, w));
|
|
197
218
|
}
|
|
@@ -207,7 +228,7 @@ var GuildChannel = class extends Channel {
|
|
|
207
228
|
if (options?.max_age != null) body.max_age = options.max_age;
|
|
208
229
|
if (options?.unique != null) body.unique = options.unique;
|
|
209
230
|
if (options?.temporary != null) body.temporary = options.temporary;
|
|
210
|
-
const data = await this.client.rest.post(
|
|
231
|
+
const data = await this.client.rest.post(Routes2.channelInvites(this.id), {
|
|
211
232
|
body: Object.keys(body).length ? body : void 0,
|
|
212
233
|
auth: true
|
|
213
234
|
});
|
|
@@ -219,7 +240,7 @@ var GuildChannel = class extends Channel {
|
|
|
219
240
|
*/
|
|
220
241
|
async fetchInvites() {
|
|
221
242
|
const { Invite } = await import("./Invite-UM5BU5A6.mjs");
|
|
222
|
-
const data = await this.client.rest.get(
|
|
243
|
+
const data = await this.client.rest.get(Routes2.channelInvites(this.id));
|
|
223
244
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
224
245
|
return list.map((i) => new Invite(this.client, i));
|
|
225
246
|
}
|
|
@@ -245,7 +266,7 @@ var TextChannel = class extends GuildChannel {
|
|
|
245
266
|
const body = buildSendBody(options);
|
|
246
267
|
const { Message } = await import("./Message-OFIVTTAZ.mjs");
|
|
247
268
|
const postOptions = opts.files?.length ? { body, files: opts.files } : { body };
|
|
248
|
-
const data = await this.client.rest.post(
|
|
269
|
+
const data = await this.client.rest.post(Routes2.channelMessages(this.id), postOptions);
|
|
249
270
|
return new Message(this.client, data);
|
|
250
271
|
}
|
|
251
272
|
/** Message manager for this channel. Use channel.messages.fetch(messageId). */
|
|
@@ -270,7 +291,7 @@ var TextChannel = class extends GuildChannel {
|
|
|
270
291
|
*/
|
|
271
292
|
async fetchPinnedMessages() {
|
|
272
293
|
const { Message } = await import("./Message-OFIVTTAZ.mjs");
|
|
273
|
-
const data = await this.client.rest.get(
|
|
294
|
+
const data = await this.client.rest.get(Routes2.channelPins(this.id));
|
|
274
295
|
const list = Array.isArray(data) ? data : data?.items ?? [];
|
|
275
296
|
return list.map((item) => {
|
|
276
297
|
const msg = typeof item === "object" && item && "message" in item ? item.message : item;
|
|
@@ -337,7 +358,7 @@ var DMChannel = class extends Channel {
|
|
|
337
358
|
const body = buildSendBody(options);
|
|
338
359
|
const { Message } = await import("./Message-OFIVTTAZ.mjs");
|
|
339
360
|
const postOptions = opts.files?.length ? { body, files: opts.files } : { body };
|
|
340
|
-
const data = await this.client.rest.post(
|
|
361
|
+
const data = await this.client.rest.post(Routes2.channelMessages(this.id), postOptions);
|
|
341
362
|
return new Message(this.client, data);
|
|
342
363
|
}
|
|
343
364
|
/** Message manager for this channel. Use channel.messages.fetch(messageId). */
|
|
@@ -357,7 +378,7 @@ var DMChannel = class extends Channel {
|
|
|
357
378
|
*/
|
|
358
379
|
async fetchPinnedMessages() {
|
|
359
380
|
const { Message } = await import("./Message-OFIVTTAZ.mjs");
|
|
360
|
-
const data = await this.client.rest.get(
|
|
381
|
+
const data = await this.client.rest.get(Routes2.channelPins(this.id));
|
|
361
382
|
const list = Array.isArray(data) ? data : data?.items ?? [];
|
|
362
383
|
return list.map((item) => {
|
|
363
384
|
const msg = typeof item === "object" && item && "message" in item ? item.message : item;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as _fluxerjs_types from '@fluxerjs/types';
|
|
2
|
-
import { APIEmbed, APIWebhook, APIWebhookUpdateRequest, APIWebhookTokenUpdateRequest, APIChannelOverwrite, APIChannel, APIChannelPartial, ChannelType, GatewayReactionEmoji, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveDispatchData, APIMessageAttachment, MessageType, APIMessageSticker, APIMessageReaction, APIMessageReference, APIMessageSnapshot, APIMessageCall, APIMessage, APIUserPartial, APIGuildMember, APIRole, APIBan, GuildFeature, GuildVerificationLevel, DefaultMessageNotifications, GuildExplicitContentFilter, GuildMFALevel, APIGuild, APIGuildAuditLog, APIGuildPartial, APIInvite, GatewayPresenceUpdateData, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayVoiceStateUpdateDispatchData, GatewayVoiceServerUpdateDispatchData, GatewayGuildEmojisUpdateDispatchData, GatewayGuildStickersUpdateDispatchData, GatewayGuildIntegrationsUpdateDispatchData, GatewayGuildScheduledEventCreateDispatchData, GatewayGuildScheduledEventUpdateDispatchData, GatewayGuildScheduledEventDeleteDispatchData, GatewayChannelPinsUpdateDispatchData, GatewayPresenceUpdateDispatchData, GatewayWebhooksUpdateDispatchData, GatewaySendPayload, Routes, APIEmoji, APISticker } from '@fluxerjs/types';
|
|
2
|
+
import { APIEmbed, APIWebhook, APIWebhookUpdateRequest, APIWebhookTokenUpdateRequest, APIChannelOverwrite, APIChannel, APIChannelPartial, ChannelType, GatewayReactionEmoji, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveDispatchData, APIMessageAttachment, MessageType, APIMessageSticker, APIMessageReaction, APIMessageReference, APIMessageSnapshot, APIMessageCall, APIMessage, APIUserPartial, APIGuildMember, APIRole, RESTUpdateRoleBody, APIBan, GuildFeature, GuildVerificationLevel, DefaultMessageNotifications, GuildExplicitContentFilter, GuildMFALevel, APIGuild, RESTCreateRoleBody, APIGuildAuditLog, APIGuildPartial, APIInvite, GatewayPresenceUpdateData, APIProfileResponse, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayVoiceStateUpdateDispatchData, GatewayVoiceServerUpdateDispatchData, GatewayGuildEmojisUpdateDispatchData, GatewayGuildStickersUpdateDispatchData, GatewayGuildIntegrationsUpdateDispatchData, GatewayGuildScheduledEventCreateDispatchData, GatewayGuildScheduledEventUpdateDispatchData, GatewayGuildScheduledEventDeleteDispatchData, GatewayChannelPinsUpdateDispatchData, GatewayPresenceUpdateDispatchData, GatewayWebhooksUpdateDispatchData, GatewaySendPayload, Routes, APIEmoji, APISticker } from '@fluxerjs/types';
|
|
3
3
|
export { GatewayOpcodes, MessageAttachmentFlags, Routes } from '@fluxerjs/types';
|
|
4
|
+
import { PermissionResolvable } from '@fluxerjs/util';
|
|
5
|
+
export { PermissionFlags, PermissionResolvable, PermissionString, PermissionsBitField, UserFlagsBitField, UserFlagsBits, UserFlagsResolvable, UserFlagsString, resolvePermissionsToBitfield, resolveTenorToImageUrl } from '@fluxerjs/util';
|
|
4
6
|
import { Collection } from '@fluxerjs/collection';
|
|
5
7
|
import { EmbedBuilder } from '@fluxerjs/builders';
|
|
6
8
|
export { AttachmentBuilder, EmbedBuilder, MessagePayload } from '@fluxerjs/builders';
|
|
7
9
|
import { EventEmitter } from 'events';
|
|
8
|
-
import { PermissionResolvable } from '@fluxerjs/util';
|
|
9
|
-
export { PermissionFlags, PermissionResolvable, PermissionString, PermissionsBitField, resolveTenorToImageUrl } from '@fluxerjs/util';
|
|
10
10
|
import { REST } from '@fluxerjs/rest';
|
|
11
11
|
import { WebSocketManager } from '@fluxerjs/ws';
|
|
12
12
|
|
|
@@ -715,6 +715,36 @@ declare class GuildMember extends Base {
|
|
|
715
715
|
private _computeBasePermissions;
|
|
716
716
|
}
|
|
717
717
|
|
|
718
|
+
/**
|
|
719
|
+
* Manages guild members with a Collection-like API.
|
|
720
|
+
* Extends Collection so you can use .get(), .set(), .filter(), etc.
|
|
721
|
+
* Provides guild.members.me for Discord.js parity.
|
|
722
|
+
*/
|
|
723
|
+
declare class GuildMemberManager extends Collection<string, GuildMember> {
|
|
724
|
+
private readonly guild;
|
|
725
|
+
constructor(guild: Guild);
|
|
726
|
+
/**
|
|
727
|
+
* The current bot user as a GuildMember in this guild.
|
|
728
|
+
* Returns null if the bot's member is not cached or client.user is null.
|
|
729
|
+
* Use fetchMe() to load the bot's member when not cached.
|
|
730
|
+
*
|
|
731
|
+
* @example
|
|
732
|
+
* const perms = guild.members.me?.permissions;
|
|
733
|
+
* if (perms?.has(PermissionFlags.BanMembers)) { ... }
|
|
734
|
+
*/
|
|
735
|
+
get me(): GuildMember | null;
|
|
736
|
+
/**
|
|
737
|
+
* Fetch the current bot user as a GuildMember in this guild.
|
|
738
|
+
* Caches the result in guild.members.
|
|
739
|
+
*
|
|
740
|
+
* @throws Error if client.user is null (client not ready)
|
|
741
|
+
* @example
|
|
742
|
+
* const me = await guild.members.fetchMe();
|
|
743
|
+
* console.log(me.displayName);
|
|
744
|
+
*/
|
|
745
|
+
fetchMe(): Promise<GuildMember>;
|
|
746
|
+
}
|
|
747
|
+
|
|
718
748
|
/** Represents a role in a guild. */
|
|
719
749
|
declare class Role extends Base {
|
|
720
750
|
readonly client: Client;
|
|
@@ -733,6 +763,8 @@ declare class Role extends Base {
|
|
|
733
763
|
/** @param data - API role from GET /guilds/{id}/roles or gateway role events */
|
|
734
764
|
/** @param guildId - The guild this role belongs to */
|
|
735
765
|
constructor(client: Client, data: APIRole, guildId: string);
|
|
766
|
+
/** Update mutable fields from fresh API data. Used by edit and gateway events. */
|
|
767
|
+
_patch(data: Partial<APIRole>): void;
|
|
736
768
|
/** Returns a mention string (e.g. `<@&123456>`). */
|
|
737
769
|
toString(): string;
|
|
738
770
|
/**
|
|
@@ -744,6 +776,22 @@ declare class Role extends Base {
|
|
|
744
776
|
* if (role.has('ManageChannels')) { ... }
|
|
745
777
|
*/
|
|
746
778
|
has(permission: PermissionResolvable): boolean;
|
|
779
|
+
/**
|
|
780
|
+
* Edit this role.
|
|
781
|
+
* Requires Manage Roles permission.
|
|
782
|
+
* @param options - Role updates (permissions accepts PermissionResolvable for convenience)
|
|
783
|
+
* @returns This role (updated in place)
|
|
784
|
+
* @example
|
|
785
|
+
* await role.edit({ name: 'Moderator', permissions: ['BanMembers', 'KickMembers'] });
|
|
786
|
+
*/
|
|
787
|
+
edit(options: RESTUpdateRoleBody & {
|
|
788
|
+
permissions?: string | PermissionResolvable;
|
|
789
|
+
}): Promise<Role>;
|
|
790
|
+
/**
|
|
791
|
+
* Delete this role.
|
|
792
|
+
* Requires Manage Roles permission.
|
|
793
|
+
*/
|
|
794
|
+
delete(): Promise<void>;
|
|
747
795
|
}
|
|
748
796
|
|
|
749
797
|
/** Represents a ban in a guild. */
|
|
@@ -800,7 +848,7 @@ declare class Guild extends Base {
|
|
|
800
848
|
splashWidth?: number | null;
|
|
801
849
|
/** Splash image height. Optional. */
|
|
802
850
|
splashHeight?: number | null;
|
|
803
|
-
members:
|
|
851
|
+
members: GuildMemberManager;
|
|
804
852
|
channels: Collection<string, GuildChannel>;
|
|
805
853
|
roles: Collection<string, Role>;
|
|
806
854
|
/** @param data - API guild from GET /guilds/{id} or gateway GUILD_CREATE */
|
|
@@ -834,6 +882,29 @@ declare class Guild extends Base {
|
|
|
834
882
|
* Requires Manage Roles permission.
|
|
835
883
|
*/
|
|
836
884
|
removeRoleFromMember(userId: string, roleId: string): Promise<void>;
|
|
885
|
+
/**
|
|
886
|
+
* Create a role in this guild.
|
|
887
|
+
* Requires Manage Roles permission.
|
|
888
|
+
* @param options - Role data (permissions accepts PermissionResolvable for convenience)
|
|
889
|
+
* @returns The created role
|
|
890
|
+
* @example
|
|
891
|
+
* const role = await guild.createRole({ name: 'Mod', permissions: ['KickMembers', 'BanMembers'] });
|
|
892
|
+
*/
|
|
893
|
+
createRole(options: RESTCreateRoleBody & {
|
|
894
|
+
permissions?: string | PermissionResolvable;
|
|
895
|
+
}): Promise<Role>;
|
|
896
|
+
/**
|
|
897
|
+
* Fetch all roles in this guild.
|
|
898
|
+
* @returns Array of Role objects (cached in guild.roles)
|
|
899
|
+
*/
|
|
900
|
+
fetchRoles(): Promise<Role[]>;
|
|
901
|
+
/**
|
|
902
|
+
* Fetch a role by ID.
|
|
903
|
+
* @param roleId - The role ID to fetch
|
|
904
|
+
* @returns The role
|
|
905
|
+
* @throws FluxerError with ROLE_NOT_FOUND if role does not exist (404)
|
|
906
|
+
*/
|
|
907
|
+
fetchRole(roleId: string): Promise<Role>;
|
|
837
908
|
/**
|
|
838
909
|
* Resolve a role ID from an argument (role mention, raw ID, or name).
|
|
839
910
|
* Fetches guild roles if name is provided.
|
|
@@ -1106,6 +1177,62 @@ declare const Events: {
|
|
|
1106
1177
|
readonly Debug: "debug";
|
|
1107
1178
|
};
|
|
1108
1179
|
|
|
1180
|
+
/** Result of {@link UsersManager.fetchWithProfile}. */
|
|
1181
|
+
interface FetchedUserWithProfile {
|
|
1182
|
+
/** The user (cached in client.users). */
|
|
1183
|
+
user: User;
|
|
1184
|
+
/** Raw user data from GET /users/{id}. */
|
|
1185
|
+
userData: APIUserPartial;
|
|
1186
|
+
/** Global profile (bio, pronouns, mutual guilds, etc.). Null if unavailable. */
|
|
1187
|
+
globalProfile: APIProfileResponse | null;
|
|
1188
|
+
/** Server-specific profile when guildId was provided. Null if unavailable. */
|
|
1189
|
+
serverProfile: APIProfileResponse | null;
|
|
1190
|
+
/** Guild member when guildId was provided and user is in the guild. Null otherwise. */
|
|
1191
|
+
member: GuildMember | null;
|
|
1192
|
+
/** Raw member data when member exists (for premium_since, etc.). */
|
|
1193
|
+
memberData: (APIGuildMember & {
|
|
1194
|
+
user: {
|
|
1195
|
+
id: string;
|
|
1196
|
+
};
|
|
1197
|
+
}) | null;
|
|
1198
|
+
}
|
|
1199
|
+
/**
|
|
1200
|
+
* Manages users with fetch and profile helpers.
|
|
1201
|
+
* Extends Collection so you can use .get(), .set(), .filter(), etc.
|
|
1202
|
+
*/
|
|
1203
|
+
declare class UsersManager extends Collection<string, User> {
|
|
1204
|
+
private readonly client;
|
|
1205
|
+
constructor(client: Client);
|
|
1206
|
+
/**
|
|
1207
|
+
* Fetch a user by ID from the API.
|
|
1208
|
+
* Updates cache if user already exists.
|
|
1209
|
+
* @param userId - Snowflake of the user
|
|
1210
|
+
* @returns The user
|
|
1211
|
+
* @throws FluxerError (or REST error) if user not found
|
|
1212
|
+
* @example
|
|
1213
|
+
* const user = await client.users.fetch(userId);
|
|
1214
|
+
* console.log(user.username);
|
|
1215
|
+
*/
|
|
1216
|
+
fetch(userId: string): Promise<User>;
|
|
1217
|
+
/**
|
|
1218
|
+
* Fetch a user with full profile and optional guild context.
|
|
1219
|
+
* Returns user, global profile, server profile (when guildId), and member (when guildId).
|
|
1220
|
+
* Ideal for userinfo commands.
|
|
1221
|
+
* @param userId - Snowflake of the user
|
|
1222
|
+
* @param options - Optional guildId for server profile and member data
|
|
1223
|
+
* @returns User, raw data, profiles, and member (when in guild)
|
|
1224
|
+
* @throws FluxerError (or REST error) if user not found
|
|
1225
|
+
* @example
|
|
1226
|
+
* const { user, globalProfile, serverProfile, member } = await client.users.fetchWithProfile(
|
|
1227
|
+
* userId,
|
|
1228
|
+
* { guildId: message.guildId ?? undefined },
|
|
1229
|
+
* );
|
|
1230
|
+
*/
|
|
1231
|
+
fetchWithProfile(userId: string, options?: {
|
|
1232
|
+
guildId?: string | null;
|
|
1233
|
+
}): Promise<FetchedUserWithProfile>;
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1109
1236
|
/**
|
|
1110
1237
|
* Callback parameter types for client events. Use with client.on(Events.X, handler).
|
|
1111
1238
|
* @see Events
|
|
@@ -1197,7 +1324,7 @@ declare class Client extends EventEmitter {
|
|
|
1197
1324
|
readonly rest: REST;
|
|
1198
1325
|
readonly guilds: GuildManager;
|
|
1199
1326
|
readonly channels: ChannelManager;
|
|
1200
|
-
readonly users:
|
|
1327
|
+
readonly users: UsersManager;
|
|
1201
1328
|
/** Typed event handlers. Use client.events.MessageReactionAdd((reaction, user, messageId, channelId, emoji, userId) => {...}) or client.on(Events.MessageReactionAdd, ...). */
|
|
1202
1329
|
readonly events: ClientEventMethods;
|
|
1203
1330
|
/** The authenticated bot user. Null until READY is received. */
|
|
@@ -1338,6 +1465,7 @@ declare const ErrorCodes: {
|
|
|
1338
1465
|
readonly MessageNotFound: "MESSAGE_NOT_FOUND";
|
|
1339
1466
|
readonly GuildNotFound: "GUILD_NOT_FOUND";
|
|
1340
1467
|
readonly MemberNotFound: "MEMBER_NOT_FOUND";
|
|
1468
|
+
readonly RoleNotFound: "ROLE_NOT_FOUND";
|
|
1341
1469
|
};
|
|
1342
1470
|
|
|
1343
1471
|
interface CdnUrlOptions {
|
|
@@ -1401,4 +1529,4 @@ declare function cdnMemberBannerURL(guildId: string, userId: string, bannerHash:
|
|
|
1401
1529
|
*/
|
|
1402
1530
|
declare function cdnDefaultAvatarURL(discriminatorIndex?: number): string;
|
|
1403
1531
|
|
|
1404
|
-
export { Base, CategoryChannel, type CdnUrlOptions, Channel, ChannelManager, Client, type ClientEventMethods, type ClientEvents, ClientUser, type CollectedReaction, DMChannel, ErrorCodes, Events, FluxerError, type FluxerErrorOptions, Guild, GuildBan, GuildChannel, GuildEmoji, GuildMember, GuildSticker, Invite, LinkChannel, Message, MessageCollector, type MessageCollectorEndReason, type MessageCollectorOptions, type MessageEditOptions, MessageManager, MessageReaction, type MessageSendOptions, type PartialMessage, ReactionCollector, type ReactionCollectorEndReason, type ReactionCollectorOptions, Role, TextChannel, User, VoiceChannel, Webhook, type WebhookSendOptions, cdnAvatarURL, cdnBannerURL, cdnDefaultAvatarURL, cdnDisplayAvatarURL, cdnMemberAvatarURL, cdnMemberBannerURL };
|
|
1532
|
+
export { Base, CategoryChannel, type CdnUrlOptions, Channel, ChannelManager, Client, type ClientEventMethods, type ClientEvents, ClientUser, type CollectedReaction, DMChannel, ErrorCodes, Events, type FetchedUserWithProfile, FluxerError, type FluxerErrorOptions, Guild, GuildBan, GuildChannel, GuildEmoji, GuildMember, GuildMemberManager, GuildSticker, Invite, LinkChannel, Message, MessageCollector, type MessageCollectorEndReason, type MessageCollectorOptions, type MessageEditOptions, MessageManager, MessageReaction, type MessageSendOptions, type PartialMessage, ReactionCollector, type ReactionCollectorEndReason, type ReactionCollectorOptions, Role, TextChannel, User, UsersManager, VoiceChannel, Webhook, type WebhookSendOptions, cdnAvatarURL, cdnBannerURL, cdnDefaultAvatarURL, cdnDisplayAvatarURL, cdnMemberAvatarURL, cdnMemberBannerURL };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as _fluxerjs_types from '@fluxerjs/types';
|
|
2
|
-
import { APIEmbed, APIWebhook, APIWebhookUpdateRequest, APIWebhookTokenUpdateRequest, APIChannelOverwrite, APIChannel, APIChannelPartial, ChannelType, GatewayReactionEmoji, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveDispatchData, APIMessageAttachment, MessageType, APIMessageSticker, APIMessageReaction, APIMessageReference, APIMessageSnapshot, APIMessageCall, APIMessage, APIUserPartial, APIGuildMember, APIRole, APIBan, GuildFeature, GuildVerificationLevel, DefaultMessageNotifications, GuildExplicitContentFilter, GuildMFALevel, APIGuild, APIGuildAuditLog, APIGuildPartial, APIInvite, GatewayPresenceUpdateData, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayVoiceStateUpdateDispatchData, GatewayVoiceServerUpdateDispatchData, GatewayGuildEmojisUpdateDispatchData, GatewayGuildStickersUpdateDispatchData, GatewayGuildIntegrationsUpdateDispatchData, GatewayGuildScheduledEventCreateDispatchData, GatewayGuildScheduledEventUpdateDispatchData, GatewayGuildScheduledEventDeleteDispatchData, GatewayChannelPinsUpdateDispatchData, GatewayPresenceUpdateDispatchData, GatewayWebhooksUpdateDispatchData, GatewaySendPayload, Routes, APIEmoji, APISticker } from '@fluxerjs/types';
|
|
2
|
+
import { APIEmbed, APIWebhook, APIWebhookUpdateRequest, APIWebhookTokenUpdateRequest, APIChannelOverwrite, APIChannel, APIChannelPartial, ChannelType, GatewayReactionEmoji, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveDispatchData, APIMessageAttachment, MessageType, APIMessageSticker, APIMessageReaction, APIMessageReference, APIMessageSnapshot, APIMessageCall, APIMessage, APIUserPartial, APIGuildMember, APIRole, RESTUpdateRoleBody, APIBan, GuildFeature, GuildVerificationLevel, DefaultMessageNotifications, GuildExplicitContentFilter, GuildMFALevel, APIGuild, RESTCreateRoleBody, APIGuildAuditLog, APIGuildPartial, APIInvite, GatewayPresenceUpdateData, APIProfileResponse, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayVoiceStateUpdateDispatchData, GatewayVoiceServerUpdateDispatchData, GatewayGuildEmojisUpdateDispatchData, GatewayGuildStickersUpdateDispatchData, GatewayGuildIntegrationsUpdateDispatchData, GatewayGuildScheduledEventCreateDispatchData, GatewayGuildScheduledEventUpdateDispatchData, GatewayGuildScheduledEventDeleteDispatchData, GatewayChannelPinsUpdateDispatchData, GatewayPresenceUpdateDispatchData, GatewayWebhooksUpdateDispatchData, GatewaySendPayload, Routes, APIEmoji, APISticker } from '@fluxerjs/types';
|
|
3
3
|
export { GatewayOpcodes, MessageAttachmentFlags, Routes } from '@fluxerjs/types';
|
|
4
|
+
import { PermissionResolvable } from '@fluxerjs/util';
|
|
5
|
+
export { PermissionFlags, PermissionResolvable, PermissionString, PermissionsBitField, UserFlagsBitField, UserFlagsBits, UserFlagsResolvable, UserFlagsString, resolvePermissionsToBitfield, resolveTenorToImageUrl } from '@fluxerjs/util';
|
|
4
6
|
import { Collection } from '@fluxerjs/collection';
|
|
5
7
|
import { EmbedBuilder } from '@fluxerjs/builders';
|
|
6
8
|
export { AttachmentBuilder, EmbedBuilder, MessagePayload } from '@fluxerjs/builders';
|
|
7
9
|
import { EventEmitter } from 'events';
|
|
8
|
-
import { PermissionResolvable } from '@fluxerjs/util';
|
|
9
|
-
export { PermissionFlags, PermissionResolvable, PermissionString, PermissionsBitField, resolveTenorToImageUrl } from '@fluxerjs/util';
|
|
10
10
|
import { REST } from '@fluxerjs/rest';
|
|
11
11
|
import { WebSocketManager } from '@fluxerjs/ws';
|
|
12
12
|
|
|
@@ -715,6 +715,36 @@ declare class GuildMember extends Base {
|
|
|
715
715
|
private _computeBasePermissions;
|
|
716
716
|
}
|
|
717
717
|
|
|
718
|
+
/**
|
|
719
|
+
* Manages guild members with a Collection-like API.
|
|
720
|
+
* Extends Collection so you can use .get(), .set(), .filter(), etc.
|
|
721
|
+
* Provides guild.members.me for Discord.js parity.
|
|
722
|
+
*/
|
|
723
|
+
declare class GuildMemberManager extends Collection<string, GuildMember> {
|
|
724
|
+
private readonly guild;
|
|
725
|
+
constructor(guild: Guild);
|
|
726
|
+
/**
|
|
727
|
+
* The current bot user as a GuildMember in this guild.
|
|
728
|
+
* Returns null if the bot's member is not cached or client.user is null.
|
|
729
|
+
* Use fetchMe() to load the bot's member when not cached.
|
|
730
|
+
*
|
|
731
|
+
* @example
|
|
732
|
+
* const perms = guild.members.me?.permissions;
|
|
733
|
+
* if (perms?.has(PermissionFlags.BanMembers)) { ... }
|
|
734
|
+
*/
|
|
735
|
+
get me(): GuildMember | null;
|
|
736
|
+
/**
|
|
737
|
+
* Fetch the current bot user as a GuildMember in this guild.
|
|
738
|
+
* Caches the result in guild.members.
|
|
739
|
+
*
|
|
740
|
+
* @throws Error if client.user is null (client not ready)
|
|
741
|
+
* @example
|
|
742
|
+
* const me = await guild.members.fetchMe();
|
|
743
|
+
* console.log(me.displayName);
|
|
744
|
+
*/
|
|
745
|
+
fetchMe(): Promise<GuildMember>;
|
|
746
|
+
}
|
|
747
|
+
|
|
718
748
|
/** Represents a role in a guild. */
|
|
719
749
|
declare class Role extends Base {
|
|
720
750
|
readonly client: Client;
|
|
@@ -733,6 +763,8 @@ declare class Role extends Base {
|
|
|
733
763
|
/** @param data - API role from GET /guilds/{id}/roles or gateway role events */
|
|
734
764
|
/** @param guildId - The guild this role belongs to */
|
|
735
765
|
constructor(client: Client, data: APIRole, guildId: string);
|
|
766
|
+
/** Update mutable fields from fresh API data. Used by edit and gateway events. */
|
|
767
|
+
_patch(data: Partial<APIRole>): void;
|
|
736
768
|
/** Returns a mention string (e.g. `<@&123456>`). */
|
|
737
769
|
toString(): string;
|
|
738
770
|
/**
|
|
@@ -744,6 +776,22 @@ declare class Role extends Base {
|
|
|
744
776
|
* if (role.has('ManageChannels')) { ... }
|
|
745
777
|
*/
|
|
746
778
|
has(permission: PermissionResolvable): boolean;
|
|
779
|
+
/**
|
|
780
|
+
* Edit this role.
|
|
781
|
+
* Requires Manage Roles permission.
|
|
782
|
+
* @param options - Role updates (permissions accepts PermissionResolvable for convenience)
|
|
783
|
+
* @returns This role (updated in place)
|
|
784
|
+
* @example
|
|
785
|
+
* await role.edit({ name: 'Moderator', permissions: ['BanMembers', 'KickMembers'] });
|
|
786
|
+
*/
|
|
787
|
+
edit(options: RESTUpdateRoleBody & {
|
|
788
|
+
permissions?: string | PermissionResolvable;
|
|
789
|
+
}): Promise<Role>;
|
|
790
|
+
/**
|
|
791
|
+
* Delete this role.
|
|
792
|
+
* Requires Manage Roles permission.
|
|
793
|
+
*/
|
|
794
|
+
delete(): Promise<void>;
|
|
747
795
|
}
|
|
748
796
|
|
|
749
797
|
/** Represents a ban in a guild. */
|
|
@@ -800,7 +848,7 @@ declare class Guild extends Base {
|
|
|
800
848
|
splashWidth?: number | null;
|
|
801
849
|
/** Splash image height. Optional. */
|
|
802
850
|
splashHeight?: number | null;
|
|
803
|
-
members:
|
|
851
|
+
members: GuildMemberManager;
|
|
804
852
|
channels: Collection<string, GuildChannel>;
|
|
805
853
|
roles: Collection<string, Role>;
|
|
806
854
|
/** @param data - API guild from GET /guilds/{id} or gateway GUILD_CREATE */
|
|
@@ -834,6 +882,29 @@ declare class Guild extends Base {
|
|
|
834
882
|
* Requires Manage Roles permission.
|
|
835
883
|
*/
|
|
836
884
|
removeRoleFromMember(userId: string, roleId: string): Promise<void>;
|
|
885
|
+
/**
|
|
886
|
+
* Create a role in this guild.
|
|
887
|
+
* Requires Manage Roles permission.
|
|
888
|
+
* @param options - Role data (permissions accepts PermissionResolvable for convenience)
|
|
889
|
+
* @returns The created role
|
|
890
|
+
* @example
|
|
891
|
+
* const role = await guild.createRole({ name: 'Mod', permissions: ['KickMembers', 'BanMembers'] });
|
|
892
|
+
*/
|
|
893
|
+
createRole(options: RESTCreateRoleBody & {
|
|
894
|
+
permissions?: string | PermissionResolvable;
|
|
895
|
+
}): Promise<Role>;
|
|
896
|
+
/**
|
|
897
|
+
* Fetch all roles in this guild.
|
|
898
|
+
* @returns Array of Role objects (cached in guild.roles)
|
|
899
|
+
*/
|
|
900
|
+
fetchRoles(): Promise<Role[]>;
|
|
901
|
+
/**
|
|
902
|
+
* Fetch a role by ID.
|
|
903
|
+
* @param roleId - The role ID to fetch
|
|
904
|
+
* @returns The role
|
|
905
|
+
* @throws FluxerError with ROLE_NOT_FOUND if role does not exist (404)
|
|
906
|
+
*/
|
|
907
|
+
fetchRole(roleId: string): Promise<Role>;
|
|
837
908
|
/**
|
|
838
909
|
* Resolve a role ID from an argument (role mention, raw ID, or name).
|
|
839
910
|
* Fetches guild roles if name is provided.
|
|
@@ -1106,6 +1177,62 @@ declare const Events: {
|
|
|
1106
1177
|
readonly Debug: "debug";
|
|
1107
1178
|
};
|
|
1108
1179
|
|
|
1180
|
+
/** Result of {@link UsersManager.fetchWithProfile}. */
|
|
1181
|
+
interface FetchedUserWithProfile {
|
|
1182
|
+
/** The user (cached in client.users). */
|
|
1183
|
+
user: User;
|
|
1184
|
+
/** Raw user data from GET /users/{id}. */
|
|
1185
|
+
userData: APIUserPartial;
|
|
1186
|
+
/** Global profile (bio, pronouns, mutual guilds, etc.). Null if unavailable. */
|
|
1187
|
+
globalProfile: APIProfileResponse | null;
|
|
1188
|
+
/** Server-specific profile when guildId was provided. Null if unavailable. */
|
|
1189
|
+
serverProfile: APIProfileResponse | null;
|
|
1190
|
+
/** Guild member when guildId was provided and user is in the guild. Null otherwise. */
|
|
1191
|
+
member: GuildMember | null;
|
|
1192
|
+
/** Raw member data when member exists (for premium_since, etc.). */
|
|
1193
|
+
memberData: (APIGuildMember & {
|
|
1194
|
+
user: {
|
|
1195
|
+
id: string;
|
|
1196
|
+
};
|
|
1197
|
+
}) | null;
|
|
1198
|
+
}
|
|
1199
|
+
/**
|
|
1200
|
+
* Manages users with fetch and profile helpers.
|
|
1201
|
+
* Extends Collection so you can use .get(), .set(), .filter(), etc.
|
|
1202
|
+
*/
|
|
1203
|
+
declare class UsersManager extends Collection<string, User> {
|
|
1204
|
+
private readonly client;
|
|
1205
|
+
constructor(client: Client);
|
|
1206
|
+
/**
|
|
1207
|
+
* Fetch a user by ID from the API.
|
|
1208
|
+
* Updates cache if user already exists.
|
|
1209
|
+
* @param userId - Snowflake of the user
|
|
1210
|
+
* @returns The user
|
|
1211
|
+
* @throws FluxerError (or REST error) if user not found
|
|
1212
|
+
* @example
|
|
1213
|
+
* const user = await client.users.fetch(userId);
|
|
1214
|
+
* console.log(user.username);
|
|
1215
|
+
*/
|
|
1216
|
+
fetch(userId: string): Promise<User>;
|
|
1217
|
+
/**
|
|
1218
|
+
* Fetch a user with full profile and optional guild context.
|
|
1219
|
+
* Returns user, global profile, server profile (when guildId), and member (when guildId).
|
|
1220
|
+
* Ideal for userinfo commands.
|
|
1221
|
+
* @param userId - Snowflake of the user
|
|
1222
|
+
* @param options - Optional guildId for server profile and member data
|
|
1223
|
+
* @returns User, raw data, profiles, and member (when in guild)
|
|
1224
|
+
* @throws FluxerError (or REST error) if user not found
|
|
1225
|
+
* @example
|
|
1226
|
+
* const { user, globalProfile, serverProfile, member } = await client.users.fetchWithProfile(
|
|
1227
|
+
* userId,
|
|
1228
|
+
* { guildId: message.guildId ?? undefined },
|
|
1229
|
+
* );
|
|
1230
|
+
*/
|
|
1231
|
+
fetchWithProfile(userId: string, options?: {
|
|
1232
|
+
guildId?: string | null;
|
|
1233
|
+
}): Promise<FetchedUserWithProfile>;
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1109
1236
|
/**
|
|
1110
1237
|
* Callback parameter types for client events. Use with client.on(Events.X, handler).
|
|
1111
1238
|
* @see Events
|
|
@@ -1197,7 +1324,7 @@ declare class Client extends EventEmitter {
|
|
|
1197
1324
|
readonly rest: REST;
|
|
1198
1325
|
readonly guilds: GuildManager;
|
|
1199
1326
|
readonly channels: ChannelManager;
|
|
1200
|
-
readonly users:
|
|
1327
|
+
readonly users: UsersManager;
|
|
1201
1328
|
/** Typed event handlers. Use client.events.MessageReactionAdd((reaction, user, messageId, channelId, emoji, userId) => {...}) or client.on(Events.MessageReactionAdd, ...). */
|
|
1202
1329
|
readonly events: ClientEventMethods;
|
|
1203
1330
|
/** The authenticated bot user. Null until READY is received. */
|
|
@@ -1338,6 +1465,7 @@ declare const ErrorCodes: {
|
|
|
1338
1465
|
readonly MessageNotFound: "MESSAGE_NOT_FOUND";
|
|
1339
1466
|
readonly GuildNotFound: "GUILD_NOT_FOUND";
|
|
1340
1467
|
readonly MemberNotFound: "MEMBER_NOT_FOUND";
|
|
1468
|
+
readonly RoleNotFound: "ROLE_NOT_FOUND";
|
|
1341
1469
|
};
|
|
1342
1470
|
|
|
1343
1471
|
interface CdnUrlOptions {
|
|
@@ -1401,4 +1529,4 @@ declare function cdnMemberBannerURL(guildId: string, userId: string, bannerHash:
|
|
|
1401
1529
|
*/
|
|
1402
1530
|
declare function cdnDefaultAvatarURL(discriminatorIndex?: number): string;
|
|
1403
1531
|
|
|
1404
|
-
export { Base, CategoryChannel, type CdnUrlOptions, Channel, ChannelManager, Client, type ClientEventMethods, type ClientEvents, ClientUser, type CollectedReaction, DMChannel, ErrorCodes, Events, FluxerError, type FluxerErrorOptions, Guild, GuildBan, GuildChannel, GuildEmoji, GuildMember, GuildSticker, Invite, LinkChannel, Message, MessageCollector, type MessageCollectorEndReason, type MessageCollectorOptions, type MessageEditOptions, MessageManager, MessageReaction, type MessageSendOptions, type PartialMessage, ReactionCollector, type ReactionCollectorEndReason, type ReactionCollectorOptions, Role, TextChannel, User, VoiceChannel, Webhook, type WebhookSendOptions, cdnAvatarURL, cdnBannerURL, cdnDefaultAvatarURL, cdnDisplayAvatarURL, cdnMemberAvatarURL, cdnMemberBannerURL };
|
|
1532
|
+
export { Base, CategoryChannel, type CdnUrlOptions, Channel, ChannelManager, Client, type ClientEventMethods, type ClientEvents, ClientUser, type CollectedReaction, DMChannel, ErrorCodes, Events, type FetchedUserWithProfile, FluxerError, type FluxerErrorOptions, Guild, GuildBan, GuildChannel, GuildEmoji, GuildMember, GuildMemberManager, GuildSticker, Invite, LinkChannel, Message, MessageCollector, type MessageCollectorEndReason, type MessageCollectorOptions, type MessageEditOptions, MessageManager, MessageReaction, type MessageSendOptions, type PartialMessage, ReactionCollector, type ReactionCollectorEndReason, type ReactionCollectorOptions, Role, TextChannel, User, UsersManager, VoiceChannel, Webhook, type WebhookSendOptions, cdnAvatarURL, cdnBannerURL, cdnDefaultAvatarURL, cdnDisplayAvatarURL, cdnMemberAvatarURL, cdnMemberBannerURL };
|