@fluxerjs/core 1.0.7 → 1.0.8
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/dist/{Channel-OSOB6ELO.mjs → Channel-TWPDKW2P.mjs} +1 -1
- package/dist/{ClientUser-RNDKHQ3Z.mjs → ClientUser-2K2BACK7.mjs} +1 -2
- package/dist/{Guild-GOQZ7XP4.mjs → Guild-CMZGA6DW.mjs} +3 -1
- package/dist/{GuildMember-BJJNCL6W.mjs → GuildMember-DW2N6ITI.mjs} +1 -2
- package/dist/{Message-QXPHQOVC.mjs → Message-G2QIKZQK.mjs} +1 -2
- package/dist/MessageReaction-XRPYZDSC.mjs +7 -0
- package/dist/{Webhook-AG6QFM2I.mjs → Role-SVLWIAMN.mjs} +3 -3
- package/dist/{Webhook-2RHBXH7R.mjs → Webhook-2MQESB7Z.mjs} +1 -1
- package/dist/{chunk-J3EIGOXQ.mjs → chunk-4GCZFOS5.mjs} +20 -6
- package/dist/{chunk-PO5JZQVN.mjs → chunk-CO5EL5LH.mjs} +71 -14
- package/dist/{chunk-WYSHH4LR.mjs → chunk-CZIO2D7F.mjs} +72 -6
- package/dist/chunk-HBF5QEDH.mjs +42 -0
- package/dist/{chunk-NISGA2YZ.mjs → chunk-JVEOQFUX.mjs} +1 -4
- package/dist/chunk-SQVCCSNN.mjs +41 -0
- package/dist/chunk-TJVZEILY.mjs +120 -0
- package/dist/{chunk-T2NSVWBH.mjs → chunk-ZGMM6IPQ.mjs} +3 -1
- package/dist/index.d.mts +374 -61
- package/dist/index.d.ts +374 -61
- package/dist/index.js +1001 -409
- package/dist/index.mjs +505 -192
- package/package.json +27 -8
- package/dist/Channel-2WNJ445K.mjs +0 -17
- package/dist/Channel-BEZOW4VC.mjs +0 -17
- package/dist/Channel-DPLLHL7Y.mjs +0 -19
- package/dist/Channel-HM2UY4DN.mjs +0 -17
- package/dist/Channel-IKL3SJXN.mjs +0 -17
- package/dist/Channel-KILNV5V3.mjs +0 -17
- package/dist/Channel-KOTARBSF.mjs +0 -17
- package/dist/Channel-ON7O3D3M.mjs +0 -17
- package/dist/Channel-TOAQGSRX.mjs +0 -17
- package/dist/Channel-VENHOL7S.mjs +0 -17
- package/dist/Channel-YVGPVOVB.mjs +0 -17
- package/dist/ClientUser-6HBAPU6H.mjs +0 -8
- package/dist/ClientUser-ALGC4FNY.mjs +0 -8
- package/dist/ClientUser-J6HQVSDJ.mjs +0 -9
- package/dist/ClientUser-LLL6WX35.mjs +0 -8
- package/dist/ClientUser-N7ZXYAQ3.mjs +0 -8
- package/dist/Guild-36EGAAEW.mjs +0 -8
- package/dist/Guild-5UBZNIGD.mjs +0 -9
- package/dist/Guild-CA3W6DOD.mjs +0 -8
- package/dist/Guild-GIXJJBFM.mjs +0 -9
- package/dist/Guild-NHNQ5TIA.mjs +0 -8
- package/dist/Guild-S436SLOP.mjs +0 -9
- package/dist/Guild-WAFXK2EX.mjs +0 -9
- package/dist/Guild-XPOMHZZG.mjs +0 -9
- package/dist/Guild-ZOFF5LFR.mjs +0 -8
- package/dist/GuildMember-FX2JAWES.mjs +0 -8
- package/dist/GuildMember-K5FLBNHV.mjs +0 -8
- package/dist/GuildMember-RGVPVUAG.mjs +0 -9
- package/dist/GuildMember-UBNHZBCO.mjs +0 -8
- package/dist/GuildMember-UU26WJGN.mjs +0 -8
- package/dist/GuildMember-XF7K2R45.mjs +0 -9
- package/dist/Message-23Z3RPCZ.mjs +0 -9
- package/dist/Message-33APPS76.mjs +0 -9
- package/dist/Message-6RSAGIRP.mjs +0 -8
- package/dist/Message-OXTQHFCF.mjs +0 -8
- package/dist/Message-PZUU7ZFR.mjs +0 -9
- package/dist/Message-R7GZYIQQ.mjs +0 -8
- package/dist/Message-W624MHJF.mjs +0 -8
- package/dist/Message-XB5WNMHL.mjs +0 -9
- package/dist/Message-ZCS7IGJX.mjs +0 -8
- package/dist/Webhook-NUQCJAWZ.mjs +0 -7
- package/dist/Webhook-TGAZZRQQ.mjs +0 -7
- package/dist/chunk-2FIZRRSO.mjs +0 -88
- package/dist/chunk-3CNUPFDI.mjs +0 -59
- package/dist/chunk-4DBGMFOQ.mjs +0 -14
- package/dist/chunk-5HQRX3KJ.mjs +0 -70
- package/dist/chunk-62S4AB2S.mjs +0 -54
- package/dist/chunk-6CEMF2LO.mjs +0 -14
- package/dist/chunk-6EBNOON4.mjs +0 -86
- package/dist/chunk-72OY7B3D.mjs +0 -72
- package/dist/chunk-7FYM4D2E.mjs +0 -50
- package/dist/chunk-7GZN6JXT.mjs +0 -50
- package/dist/chunk-7H3TKJUT.mjs +0 -53
- package/dist/chunk-7SIS5CUA.mjs +0 -14
- package/dist/chunk-BGJSL6JI.mjs +0 -14
- package/dist/chunk-BUEXP5SZ.mjs +0 -70
- package/dist/chunk-BYTAODAO.mjs +0 -70
- package/dist/chunk-CQ5ZVTLX.mjs +0 -71
- package/dist/chunk-DJBCSVZX.mjs +0 -102
- package/dist/chunk-DLROMCIJ.mjs +0 -50
- package/dist/chunk-DPZHAYCK.mjs +0 -71
- package/dist/chunk-E75ZVY3I.mjs +0 -14
- package/dist/chunk-EF32ILJL.mjs +0 -102
- package/dist/chunk-F2EEQP5O.mjs +0 -86
- package/dist/chunk-FK5X6HFL.mjs +0 -111
- package/dist/chunk-FNFID6QB.mjs +0 -45
- package/dist/chunk-G4L7WAJS.mjs +0 -64
- package/dist/chunk-GUNWHOQO.mjs +0 -42
- package/dist/chunk-IPHFDI2L.mjs +0 -68
- package/dist/chunk-JJHZBWZM.mjs +0 -118
- package/dist/chunk-L25ON7WB.mjs +0 -52
- package/dist/chunk-LBBIQOSH.mjs +0 -53
- package/dist/chunk-LVMFPATK.mjs +0 -54
- package/dist/chunk-NOLYW3V4.mjs +0 -140
- package/dist/chunk-OHIHIQAS.mjs +0 -102
- package/dist/chunk-P4IRDGB4.mjs +0 -43
- package/dist/chunk-PYYXC7US.mjs +0 -76
- package/dist/chunk-QDCFQF6J.mjs +0 -36
- package/dist/chunk-QDNFJVVE.mjs +0 -70
- package/dist/chunk-QXJNV5EJ.mjs +0 -110
- package/dist/chunk-RXHJYGSJ.mjs +0 -53
- package/dist/chunk-SW6KNICI.mjs +0 -52
- package/dist/chunk-TE5IC7IP.mjs +0 -36
- package/dist/chunk-TMDZALIN.mjs +0 -110
- package/dist/chunk-WFONGZGK.mjs +0 -42
- package/dist/chunk-WZVY7DA6.mjs +0 -44
- package/dist/chunk-XTDZQD4A.mjs +0 -110
- package/dist/chunk-XXCBJJZE.mjs +0 -88
- package/dist/chunk-YKP7JHV2.mjs +0 -102
- package/dist/chunk-YSKZR66G.mjs +0 -102
- package/dist/chunk-ZHRQQZ4X.mjs +0 -102
- package/dist/chunk-ZMIMAMO2.mjs +0 -14
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CDN_URL
|
|
3
|
+
} from "./chunk-HQMYRYMY.mjs";
|
|
1
4
|
import {
|
|
2
5
|
Base
|
|
3
6
|
} from "./chunk-XNS4O6QJ.mjs";
|
|
4
7
|
|
|
5
|
-
// src/util/Constants.ts
|
|
6
|
-
var CDN_URL = "https://fluxerusercontent.com";
|
|
7
|
-
|
|
8
8
|
// src/structures/User.ts
|
|
9
9
|
import { Routes } from "@fluxerjs/types";
|
|
10
10
|
var User = class extends Base {
|
|
@@ -26,6 +26,13 @@ var User = class extends Base {
|
|
|
26
26
|
this.avatar = data.avatar ?? null;
|
|
27
27
|
this.bot = !!data.bot;
|
|
28
28
|
}
|
|
29
|
+
/** Update mutable fields from fresh API data. Used by getOrCreateUser cache. */
|
|
30
|
+
_patch(data) {
|
|
31
|
+
this.username = data.username;
|
|
32
|
+
this.discriminator = data.discriminator;
|
|
33
|
+
this.globalName = data.global_name ?? null;
|
|
34
|
+
this.avatar = data.avatar ?? null;
|
|
35
|
+
}
|
|
29
36
|
/**
|
|
30
37
|
* Get the URL for this user's avatar.
|
|
31
38
|
* @param options - Optional `size` and `extension` (default: `png`)
|
|
@@ -49,7 +56,7 @@ var User = class extends Base {
|
|
|
49
56
|
* Returns the DM channel; use {@link DMChannel.send} to send messages.
|
|
50
57
|
*/
|
|
51
58
|
async createDM() {
|
|
52
|
-
const { DMChannel: DMChannelClass } = await import("./Channel-
|
|
59
|
+
const { DMChannel: DMChannelClass } = await import("./Channel-TWPDKW2P.mjs");
|
|
53
60
|
const data = await this.client.rest.post(Routes.userMeChannels(), {
|
|
54
61
|
body: { recipient_id: this.id },
|
|
55
62
|
auth: true
|
|
@@ -66,7 +73,14 @@ var User = class extends Base {
|
|
|
66
73
|
}
|
|
67
74
|
};
|
|
68
75
|
|
|
76
|
+
// src/client/ClientUser.ts
|
|
77
|
+
var ClientUser = class extends User {
|
|
78
|
+
constructor(client, data) {
|
|
79
|
+
super(client, { ...data });
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
69
83
|
export {
|
|
70
|
-
|
|
71
|
-
|
|
84
|
+
User,
|
|
85
|
+
ClientUser
|
|
72
86
|
};
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
User
|
|
3
|
-
} from "./chunk-J3EIGOXQ.mjs";
|
|
4
1
|
import {
|
|
5
2
|
Base
|
|
6
3
|
} from "./chunk-XNS4O6QJ.mjs";
|
|
@@ -20,7 +17,14 @@ var Message = class _Message extends Base {
|
|
|
20
17
|
editedAt;
|
|
21
18
|
pinned;
|
|
22
19
|
attachments;
|
|
23
|
-
channel
|
|
20
|
+
/** Channel where this message was sent. Resolved from cache; null if not cached (e.g. DM channel not in cache). */
|
|
21
|
+
get channel() {
|
|
22
|
+
return this.client.channels.get(this.channelId) ?? null;
|
|
23
|
+
}
|
|
24
|
+
/** Guild where this message was sent. Resolved from cache; null for DMs or if not cached. */
|
|
25
|
+
get guild() {
|
|
26
|
+
return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
|
|
27
|
+
}
|
|
24
28
|
/** @param data - API message from POST/PATCH /channels/{id}/messages or gateway MESSAGE_CREATE */
|
|
25
29
|
constructor(client, data) {
|
|
26
30
|
super();
|
|
@@ -28,7 +32,7 @@ var Message = class _Message extends Base {
|
|
|
28
32
|
this.id = data.id;
|
|
29
33
|
this.channelId = data.channel_id;
|
|
30
34
|
this.guildId = data.guild_id ?? null;
|
|
31
|
-
this.author =
|
|
35
|
+
this.author = client.getOrCreateUser(data.author);
|
|
32
36
|
this.content = data.content;
|
|
33
37
|
this.createdAt = new Date(data.timestamp);
|
|
34
38
|
this.editedAt = data.edited_timestamp ? new Date(data.edited_timestamp) : null;
|
|
@@ -36,12 +40,49 @@ var Message = class _Message extends Base {
|
|
|
36
40
|
this.attachments = new Collection();
|
|
37
41
|
for (const a of data.attachments ?? []) this.attachments.set(a.id, a);
|
|
38
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Send a message to this channel without replying. Use when you want a standalone message.
|
|
45
|
+
* @param options - Text content or object with content and/or embeds
|
|
46
|
+
* @example
|
|
47
|
+
* await message.send('Pong!');
|
|
48
|
+
* await message.send({ embeds: [embed.toJSON()] });
|
|
49
|
+
*/
|
|
50
|
+
async send(options) {
|
|
51
|
+
const body = typeof options === "string" ? { content: options } : options;
|
|
52
|
+
const data = await this.client.rest.post(Routes.channelMessages(this.channelId), { body });
|
|
53
|
+
return new _Message(this.client, data);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Send a message to a specific channel. Use for logging, forwarding, or sending to another channel in the guild.
|
|
57
|
+
* @param channelId - Snowflake of the target channel (e.g. log channel ID)
|
|
58
|
+
* @param options - Text content or object with content and/or embeds
|
|
59
|
+
* @example
|
|
60
|
+
* await message.sendTo(logChannelId, 'User ' + message.author.username + ' said: ' + message.content);
|
|
61
|
+
* await message.sendTo(announceChannelId, { embeds: [embed.toJSON()] });
|
|
62
|
+
*/
|
|
63
|
+
async sendTo(channelId, options) {
|
|
64
|
+
return this.client.channels.send(channelId, options);
|
|
65
|
+
}
|
|
39
66
|
/**
|
|
40
67
|
* Reply to this message.
|
|
41
68
|
* @param options - Text content or object with content and/or embeds
|
|
42
69
|
*/
|
|
43
70
|
async reply(options) {
|
|
44
|
-
const body = typeof options === "string" ? {
|
|
71
|
+
const body = typeof options === "string" ? {
|
|
72
|
+
content: options,
|
|
73
|
+
message_reference: {
|
|
74
|
+
channel_id: this.channelId,
|
|
75
|
+
message_id: this.id,
|
|
76
|
+
guild_id: this.guildId ?? void 0
|
|
77
|
+
}
|
|
78
|
+
} : {
|
|
79
|
+
...options,
|
|
80
|
+
message_reference: {
|
|
81
|
+
channel_id: this.channelId,
|
|
82
|
+
message_id: this.id,
|
|
83
|
+
guild_id: this.guildId ?? void 0
|
|
84
|
+
}
|
|
85
|
+
};
|
|
45
86
|
const data = await this.client.rest.post(Routes.channelMessages(this.channelId), { body });
|
|
46
87
|
return new _Message(this.client, data);
|
|
47
88
|
}
|
|
@@ -55,37 +96,53 @@ var Message = class _Message extends Base {
|
|
|
55
96
|
if (options.embeds?.length) {
|
|
56
97
|
body.embeds = options.embeds.map((e) => e instanceof EmbedBuilder ? e.toJSON() : e);
|
|
57
98
|
}
|
|
58
|
-
const data = await this.client.rest.patch(Routes.channelMessage(this.channelId, this.id), {
|
|
99
|
+
const data = await this.client.rest.patch(Routes.channelMessage(this.channelId, this.id), {
|
|
100
|
+
body
|
|
101
|
+
});
|
|
59
102
|
return new _Message(this.client, data);
|
|
60
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Re-fetch this message from the API to get the latest content, embeds, reactions, etc.
|
|
106
|
+
* Use when you have a stale Message (e.g. from an old event or cache) and need fresh data.
|
|
107
|
+
* @returns The updated message, or null if deleted or not found
|
|
108
|
+
* @example
|
|
109
|
+
* const updated = await message.fetch();
|
|
110
|
+
* if (updated) console.log('Latest content:', updated.content);
|
|
111
|
+
*/
|
|
112
|
+
async fetch() {
|
|
113
|
+
return this.client.channels.fetchMessage(this.channelId, this.id);
|
|
114
|
+
}
|
|
61
115
|
/** Delete this message. */
|
|
62
116
|
async delete() {
|
|
63
117
|
await this.client.rest.delete(Routes.channelMessage(this.channelId, this.id));
|
|
64
118
|
}
|
|
65
119
|
/**
|
|
66
120
|
* Format emoji for reaction API: unicode string or "name:id" for custom.
|
|
67
|
-
*
|
|
121
|
+
* For string resolution (e.g. :name:), use client.resolveEmoji; Message methods resolve automatically when guildId is available.
|
|
68
122
|
*/
|
|
69
123
|
static formatEmoji(emoji) {
|
|
70
124
|
if (typeof emoji === "string") return emoji;
|
|
71
125
|
return `${emoji.name}:${emoji.id}`;
|
|
72
126
|
}
|
|
127
|
+
resolveEmojiForReaction(emoji) {
|
|
128
|
+
return this.client.resolveEmoji(emoji, this.guildId);
|
|
129
|
+
}
|
|
73
130
|
/**
|
|
74
131
|
* Add a reaction to this message (as the bot).
|
|
75
|
-
* @param emoji - Unicode emoji
|
|
132
|
+
* @param emoji - Unicode emoji, custom `{ name, id }`, `:name:`, `name:id`, or `<:name:id>`
|
|
76
133
|
*/
|
|
77
134
|
async react(emoji) {
|
|
78
|
-
const emojiStr =
|
|
135
|
+
const emojiStr = await this.resolveEmojiForReaction(emoji);
|
|
79
136
|
const route = `${Routes.channelMessageReaction(this.channelId, this.id, emojiStr)}/@me`;
|
|
80
137
|
await this.client.rest.put(route);
|
|
81
138
|
}
|
|
82
139
|
/**
|
|
83
140
|
* Remove the bot's reaction, or a specific user's reaction if userId is provided.
|
|
84
|
-
* @param emoji - Unicode emoji
|
|
141
|
+
* @param emoji - Unicode emoji, custom `{ name, id }`, `:name:`, `name:id`, or `<:name:id>`
|
|
85
142
|
* @param userId - If provided, removes that user's reaction (requires moderator permissions)
|
|
86
143
|
*/
|
|
87
144
|
async removeReaction(emoji, userId) {
|
|
88
|
-
const emojiStr =
|
|
145
|
+
const emojiStr = await this.resolveEmojiForReaction(emoji);
|
|
89
146
|
const route = `${Routes.channelMessageReaction(this.channelId, this.id, emojiStr)}/${userId ?? "@me"}`;
|
|
90
147
|
await this.client.rest.delete(route);
|
|
91
148
|
}
|
|
@@ -98,10 +155,10 @@ var Message = class _Message extends Base {
|
|
|
98
155
|
}
|
|
99
156
|
/**
|
|
100
157
|
* Remove all reactions of a specific emoji from this message.
|
|
101
|
-
* @param emoji - Unicode emoji
|
|
158
|
+
* @param emoji - Unicode emoji, custom `{ name, id }`, `:name:`, `name:id`, or `<:name:id>`. Requires moderator permissions.
|
|
102
159
|
*/
|
|
103
160
|
async removeReactionEmoji(emoji) {
|
|
104
|
-
const emojiStr =
|
|
161
|
+
const emojiStr = await this.resolveEmojiForReaction(emoji);
|
|
105
162
|
await this.client.rest.delete(Routes.channelMessageReaction(this.channelId, this.id, emojiStr));
|
|
106
163
|
}
|
|
107
164
|
};
|
|
@@ -2,9 +2,37 @@ import {
|
|
|
2
2
|
Base
|
|
3
3
|
} from "./chunk-XNS4O6QJ.mjs";
|
|
4
4
|
|
|
5
|
+
// src/client/MessageManager.ts
|
|
6
|
+
var MessageManager = class {
|
|
7
|
+
constructor(client, channelId) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
this.channelId = channelId;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Fetch a message by ID from this channel.
|
|
13
|
+
* @param messageId - Snowflake of the message
|
|
14
|
+
* @returns The message, or null if not found
|
|
15
|
+
*/
|
|
16
|
+
async fetch(messageId) {
|
|
17
|
+
return this.client.channels.fetchMessage(this.channelId, messageId);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
5
21
|
// src/structures/Channel.ts
|
|
6
22
|
import { ChannelType, Routes } from "@fluxerjs/types";
|
|
7
|
-
var Channel = class extends Base {
|
|
23
|
+
var Channel = class _Channel extends Base {
|
|
24
|
+
/** Whether this channel has a send method (TextChannel, DMChannel). */
|
|
25
|
+
isSendable() {
|
|
26
|
+
return "send" in this;
|
|
27
|
+
}
|
|
28
|
+
/** Whether this channel is a DM or Group DM. */
|
|
29
|
+
isDM() {
|
|
30
|
+
return this.type === ChannelType.DM || this.type === ChannelType.GroupDM;
|
|
31
|
+
}
|
|
32
|
+
/** Whether this channel is voice-based (VoiceChannel). */
|
|
33
|
+
isVoice() {
|
|
34
|
+
return "bitrate" in this;
|
|
35
|
+
}
|
|
8
36
|
/** Create a DM channel from API data (type DM or GroupDM). */
|
|
9
37
|
static createDM(client, data) {
|
|
10
38
|
return new DMChannel(client, data);
|
|
@@ -29,9 +57,20 @@ var Channel = class extends Base {
|
|
|
29
57
|
if (type === ChannelType.GuildText) return new TextChannel(client, data);
|
|
30
58
|
if (type === ChannelType.GuildCategory) return new CategoryChannel(client, data);
|
|
31
59
|
if (type === ChannelType.GuildVoice) return new VoiceChannel(client, data);
|
|
32
|
-
if (type === ChannelType.GuildLink || type === ChannelType.GuildLinkExtended)
|
|
60
|
+
if (type === ChannelType.GuildLink || type === ChannelType.GuildLinkExtended)
|
|
61
|
+
return new LinkChannel(client, data);
|
|
33
62
|
return new GuildChannel(client, data);
|
|
34
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Create a channel from API data, including DM and GroupDM.
|
|
66
|
+
* Used by ChannelManager.fetch() for GET /channels/{id}.
|
|
67
|
+
*/
|
|
68
|
+
static fromOrCreate(client, data) {
|
|
69
|
+
const type = data.type ?? 0;
|
|
70
|
+
if (type === ChannelType.DM || type === ChannelType.GroupDM)
|
|
71
|
+
return _Channel.createDM(client, data);
|
|
72
|
+
return _Channel.from(client, data);
|
|
73
|
+
}
|
|
35
74
|
};
|
|
36
75
|
var GuildChannel = class extends Channel {
|
|
37
76
|
guildId;
|
|
@@ -51,7 +90,7 @@ var GuildChannel = class extends Channel {
|
|
|
51
90
|
* @returns The webhook with token (required for send()). Requires Manage Webhooks permission.
|
|
52
91
|
*/
|
|
53
92
|
async createWebhook(options) {
|
|
54
|
-
const { Webhook } = await import("./Webhook-
|
|
93
|
+
const { Webhook } = await import("./Webhook-2MQESB7Z.mjs");
|
|
55
94
|
const data = await this.client.rest.post(Routes.channelWebhooks(this.id), {
|
|
56
95
|
body: options,
|
|
57
96
|
auth: true
|
|
@@ -63,7 +102,7 @@ var GuildChannel = class extends Channel {
|
|
|
63
102
|
* @returns Webhooks (includes token when listing from channel; can send via send())
|
|
64
103
|
*/
|
|
65
104
|
async fetchWebhooks() {
|
|
66
|
-
const { Webhook } = await import("./Webhook-
|
|
105
|
+
const { Webhook } = await import("./Webhook-2MQESB7Z.mjs");
|
|
67
106
|
const data = await this.client.rest.get(Routes.channelWebhooks(this.id));
|
|
68
107
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
69
108
|
return list.map((w) => new Webhook(this.client, w));
|
|
@@ -87,10 +126,23 @@ var TextChannel = class extends GuildChannel {
|
|
|
87
126
|
*/
|
|
88
127
|
async send(options) {
|
|
89
128
|
const body = typeof options === "string" ? { content: options } : options;
|
|
90
|
-
const { Message } = await import("./Message-
|
|
129
|
+
const { Message } = await import("./Message-G2QIKZQK.mjs");
|
|
91
130
|
const data = await this.client.rest.post(Routes.channelMessages(this.id), { body });
|
|
92
131
|
return new Message(this.client, data);
|
|
93
132
|
}
|
|
133
|
+
/** Message manager for this channel. Use channel.messages.fetch(messageId). */
|
|
134
|
+
get messages() {
|
|
135
|
+
return new MessageManager(this.client, this.id);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Fetch a message by ID from this channel.
|
|
139
|
+
* @param messageId - Snowflake of the message
|
|
140
|
+
* @returns The message, or null if not found
|
|
141
|
+
* @deprecated Use channel.messages.fetch(messageId) instead.
|
|
142
|
+
*/
|
|
143
|
+
async fetchMessage(messageId) {
|
|
144
|
+
return this.client.channels.fetchMessage(this.id, messageId);
|
|
145
|
+
}
|
|
94
146
|
};
|
|
95
147
|
var CategoryChannel = class extends GuildChannel {
|
|
96
148
|
};
|
|
@@ -124,13 +176,27 @@ var DMChannel = class extends Channel {
|
|
|
124
176
|
*/
|
|
125
177
|
async send(options) {
|
|
126
178
|
const body = typeof options === "string" ? { content: options } : options;
|
|
127
|
-
const { Message } = await import("./Message-
|
|
179
|
+
const { Message } = await import("./Message-G2QIKZQK.mjs");
|
|
128
180
|
const data = await this.client.rest.post(Routes.channelMessages(this.id), { body });
|
|
129
181
|
return new Message(this.client, data);
|
|
130
182
|
}
|
|
183
|
+
/** Message manager for this channel. Use channel.messages.fetch(messageId). */
|
|
184
|
+
get messages() {
|
|
185
|
+
return new MessageManager(this.client, this.id);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Fetch a message by ID from this DM channel.
|
|
189
|
+
* @param messageId - Snowflake of the message
|
|
190
|
+
* @returns The message, or null if not found
|
|
191
|
+
* @deprecated Use channel.messages.fetch(messageId) instead.
|
|
192
|
+
*/
|
|
193
|
+
async fetchMessage(messageId) {
|
|
194
|
+
return this.client.channels.fetchMessage(this.id, messageId);
|
|
195
|
+
}
|
|
131
196
|
};
|
|
132
197
|
|
|
133
198
|
export {
|
|
199
|
+
MessageManager,
|
|
134
200
|
Channel,
|
|
135
201
|
GuildChannel,
|
|
136
202
|
TextChannel,
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Base
|
|
3
|
+
} from "./chunk-XNS4O6QJ.mjs";
|
|
4
|
+
|
|
5
|
+
// src/structures/MessageReaction.ts
|
|
6
|
+
var MessageReaction = class extends Base {
|
|
7
|
+
client;
|
|
8
|
+
messageId;
|
|
9
|
+
channelId;
|
|
10
|
+
guildId;
|
|
11
|
+
emoji;
|
|
12
|
+
/** Raw gateway payload for low-level access. */
|
|
13
|
+
_data;
|
|
14
|
+
constructor(client, data) {
|
|
15
|
+
super();
|
|
16
|
+
this.client = client;
|
|
17
|
+
this._data = data;
|
|
18
|
+
this.messageId = data.message_id;
|
|
19
|
+
this.channelId = data.channel_id;
|
|
20
|
+
this.guildId = data.guild_id ?? null;
|
|
21
|
+
this.emoji = data.emoji;
|
|
22
|
+
}
|
|
23
|
+
/** Emoji as a string: unicode or "name:id" for custom. */
|
|
24
|
+
get emojiIdentifier() {
|
|
25
|
+
return this.emoji.id ? `${this.emoji.name}:${this.emoji.id}` : this.emoji.name;
|
|
26
|
+
}
|
|
27
|
+
/** Guild where this reaction was added. Resolved from cache; null for DMs or if not cached. */
|
|
28
|
+
get guild() {
|
|
29
|
+
return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Fetch the message this reaction belongs to.
|
|
33
|
+
* Use when you need to edit, delete, or otherwise interact with the message.
|
|
34
|
+
*/
|
|
35
|
+
async fetchMessage() {
|
|
36
|
+
return this.client.channels.fetchMessage(this.channelId, this.messageId);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
MessageReaction
|
|
42
|
+
};
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
User
|
|
3
|
-
} from "./chunk-J3EIGOXQ.mjs";
|
|
4
1
|
import {
|
|
5
2
|
Base
|
|
6
3
|
} from "./chunk-XNS4O6QJ.mjs";
|
|
@@ -20,7 +17,7 @@ var GuildMember = class extends Base {
|
|
|
20
17
|
constructor(client, data, guild) {
|
|
21
18
|
super();
|
|
22
19
|
this.client = client;
|
|
23
|
-
this.user =
|
|
20
|
+
this.user = client.getOrCreateUser(data.user);
|
|
24
21
|
this.id = data.user.id;
|
|
25
22
|
this.guild = guild;
|
|
26
23
|
this.nick = data.nick ?? null;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Base
|
|
3
|
+
} from "./chunk-XNS4O6QJ.mjs";
|
|
4
|
+
|
|
5
|
+
// src/structures/Role.ts
|
|
6
|
+
var Role = class extends Base {
|
|
7
|
+
client;
|
|
8
|
+
id;
|
|
9
|
+
guildId;
|
|
10
|
+
name;
|
|
11
|
+
color;
|
|
12
|
+
position;
|
|
13
|
+
permissions;
|
|
14
|
+
hoist;
|
|
15
|
+
mentionable;
|
|
16
|
+
unicodeEmoji;
|
|
17
|
+
/** @param client - The client instance */
|
|
18
|
+
/** @param data - API role from GET /guilds/{id}/roles or gateway role events */
|
|
19
|
+
/** @param guildId - The guild this role belongs to */
|
|
20
|
+
constructor(client, data, guildId) {
|
|
21
|
+
super();
|
|
22
|
+
this.client = client;
|
|
23
|
+
this.id = data.id;
|
|
24
|
+
this.guildId = guildId;
|
|
25
|
+
this.name = data.name;
|
|
26
|
+
this.color = data.color;
|
|
27
|
+
this.position = data.position;
|
|
28
|
+
this.permissions = data.permissions;
|
|
29
|
+
this.hoist = !!data.hoist;
|
|
30
|
+
this.mentionable = !!data.mentionable;
|
|
31
|
+
this.unicodeEmoji = data.unicode_emoji ?? null;
|
|
32
|
+
}
|
|
33
|
+
/** Returns a mention string (e.g. `<@&123456>`). */
|
|
34
|
+
toString() {
|
|
35
|
+
return `<@&${this.id}>`;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
Role
|
|
41
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CDN_URL
|
|
3
|
+
} from "./chunk-HQMYRYMY.mjs";
|
|
4
|
+
import {
|
|
5
|
+
GuildMember
|
|
6
|
+
} from "./chunk-JVEOQFUX.mjs";
|
|
7
|
+
import {
|
|
8
|
+
Role
|
|
9
|
+
} from "./chunk-SQVCCSNN.mjs";
|
|
10
|
+
import {
|
|
11
|
+
Base
|
|
12
|
+
} from "./chunk-XNS4O6QJ.mjs";
|
|
13
|
+
|
|
14
|
+
// src/structures/Guild.ts
|
|
15
|
+
import { parseRoleMention } from "@fluxerjs/util";
|
|
16
|
+
import { Collection } from "@fluxerjs/collection";
|
|
17
|
+
import { Routes } from "@fluxerjs/types";
|
|
18
|
+
var Guild = class extends Base {
|
|
19
|
+
client;
|
|
20
|
+
id;
|
|
21
|
+
name;
|
|
22
|
+
icon;
|
|
23
|
+
banner;
|
|
24
|
+
ownerId;
|
|
25
|
+
members = new Collection();
|
|
26
|
+
channels = new Collection();
|
|
27
|
+
roles = new Collection();
|
|
28
|
+
/** @param data - API guild from GET /guilds/{id} or gateway GUILD_CREATE */
|
|
29
|
+
constructor(client, data) {
|
|
30
|
+
super();
|
|
31
|
+
this.client = client;
|
|
32
|
+
this.id = data.id;
|
|
33
|
+
this.name = data.name;
|
|
34
|
+
this.icon = data.icon ?? null;
|
|
35
|
+
this.banner = data.banner ?? null;
|
|
36
|
+
this.ownerId = data.owner_id;
|
|
37
|
+
for (const r of data.roles ?? []) {
|
|
38
|
+
this.roles.set(r.id, new Role(client, r, this.id));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** Get the guild icon URL, or null if no icon. */
|
|
42
|
+
iconURL(options) {
|
|
43
|
+
if (!this.icon) return null;
|
|
44
|
+
const size = options?.size ? `?size=${options.size}` : "";
|
|
45
|
+
return `${CDN_URL}/icons/${this.id}/${this.icon}.png${size}`;
|
|
46
|
+
}
|
|
47
|
+
/** Get the guild banner URL, or null if no banner. */
|
|
48
|
+
bannerURL(options) {
|
|
49
|
+
if (!this.banner) return null;
|
|
50
|
+
const size = options?.size ? `?size=${options.size}` : "";
|
|
51
|
+
return `${CDN_URL}/banners/${this.id}/${this.banner}.png${size}`;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Add a role to a member by user ID. Does not require fetching the member first.
|
|
55
|
+
* @param userId - The user ID of the member
|
|
56
|
+
* @param roleId - The role ID to add (or use guild.resolveRoleId for mention/name resolution)
|
|
57
|
+
* Requires Manage Roles permission.
|
|
58
|
+
*/
|
|
59
|
+
async addRoleToMember(userId, roleId) {
|
|
60
|
+
await this.client.rest.put(Routes.guildMemberRole(this.id, userId, roleId));
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Remove a role from a member by user ID. Does not require fetching the member first.
|
|
64
|
+
* @param userId - The user ID of the member
|
|
65
|
+
* @param roleId - The role ID to remove
|
|
66
|
+
* Requires Manage Roles permission.
|
|
67
|
+
*/
|
|
68
|
+
async removeRoleFromMember(userId, roleId) {
|
|
69
|
+
await this.client.rest.delete(Routes.guildMemberRole(this.id, userId, roleId));
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Resolve a role ID from an argument (role mention, raw ID, or name).
|
|
73
|
+
* Fetches guild roles if name is provided.
|
|
74
|
+
* @param arg - Role mention (@role), role ID, or role name
|
|
75
|
+
* @returns The role ID, or null if not found
|
|
76
|
+
*/
|
|
77
|
+
async resolveRoleId(arg) {
|
|
78
|
+
const parsed = parseRoleMention(arg);
|
|
79
|
+
if (parsed) return parsed;
|
|
80
|
+
if (/^\d{17,19}$/.test(arg.trim())) return arg.trim();
|
|
81
|
+
const cached = this.roles.find(
|
|
82
|
+
(r) => !!(r.name && r.name.toLowerCase() === arg.trim().toLowerCase())
|
|
83
|
+
);
|
|
84
|
+
if (cached) return cached.id;
|
|
85
|
+
const roles = await this.client.rest.get(Routes.guildRoles(this.id));
|
|
86
|
+
const list = Array.isArray(roles) ? roles : Object.values(roles ?? {});
|
|
87
|
+
const role = list.find((r) => !!(r.name && r.name.toLowerCase() === arg.trim().toLowerCase()));
|
|
88
|
+
if (role) {
|
|
89
|
+
this.roles.set(role.id, new Role(this.client, role, this.id));
|
|
90
|
+
return role.id;
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Fetch a guild member by user ID.
|
|
96
|
+
* @param userId - The user ID of the member to fetch
|
|
97
|
+
* @returns The guild member, or null if not found
|
|
98
|
+
*/
|
|
99
|
+
async fetchMember(userId) {
|
|
100
|
+
try {
|
|
101
|
+
const data = await this.client.rest.get(
|
|
102
|
+
Routes.guildMember(this.id, userId)
|
|
103
|
+
);
|
|
104
|
+
return new GuildMember(this.client, { ...data, guild_id: this.id }, this);
|
|
105
|
+
} catch {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/** Fetch all webhooks in this guild. Returned webhooks do not include the token (cannot send). */
|
|
110
|
+
async fetchWebhooks() {
|
|
111
|
+
const { Webhook } = await import("./Webhook-2MQESB7Z.mjs");
|
|
112
|
+
const data = await this.client.rest.get(Routes.guildWebhooks(this.id));
|
|
113
|
+
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
114
|
+
return list.map((w) => new Webhook(this.client, w));
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export {
|
|
119
|
+
Guild
|
|
120
|
+
};
|
|
@@ -34,7 +34,9 @@ var Webhook = class _Webhook extends Base {
|
|
|
34
34
|
*/
|
|
35
35
|
async send(options) {
|
|
36
36
|
if (!this.token) {
|
|
37
|
-
throw new Error(
|
|
37
|
+
throw new Error(
|
|
38
|
+
"Webhook token is required to send. The token is only returned when creating a webhook; fetched webhooks cannot send."
|
|
39
|
+
);
|
|
38
40
|
}
|
|
39
41
|
const body = typeof options === "string" ? { content: options } : options;
|
|
40
42
|
await this.client.rest.post(Routes.webhookExecute(this.id, this.token), {
|