@fluxerjs/core 1.2.0 → 1.2.1
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/index.d.mts +1095 -1016
- package/dist/index.d.ts +1095 -1016
- package/dist/index.js +2500 -2674
- package/dist/index.mjs +2630 -268
- package/package.json +8 -8
- package/dist/Channel-4YUSB2MM.mjs +0 -22
- package/dist/ClientUser-ET7FW3XL.mjs +0 -9
- package/dist/Guild-4U4U422Z.mjs +0 -12
- package/dist/GuildBan-7CXLTPKY.mjs +0 -7
- package/dist/GuildEmoji-OCXBPS6I.mjs +0 -8
- package/dist/GuildMember-FSGDPKUU.mjs +0 -9
- package/dist/GuildSticker-B7AZADJR.mjs +0 -8
- package/dist/Invite-UM5BU5A6.mjs +0 -7
- package/dist/Message-R7KSI5YU.mjs +0 -9
- package/dist/MessageReaction-EYO7AJTL.mjs +0 -8
- package/dist/Role-SERSJFJC.mjs +0 -7
- package/dist/Webhook-LWYP2BMI.mjs +0 -10
- package/dist/chunk-24E6OQID.mjs +0 -193
- package/dist/chunk-2ZSMLDEI.mjs +0 -114
- package/dist/chunk-3JVE6RW7.mjs +0 -147
- package/dist/chunk-6S3BDHBI.mjs +0 -28
- package/dist/chunk-75ODDXY3.mjs +0 -64
- package/dist/chunk-AH7KYH2Z.mjs +0 -50
- package/dist/chunk-BKPVGBOT.mjs +0 -8
- package/dist/chunk-G6F6VL4O.mjs +0 -54
- package/dist/chunk-HVCL7QLT.mjs +0 -337
- package/dist/chunk-IHXSHE2Z.mjs +0 -56
- package/dist/chunk-IRDYSGQO.mjs +0 -496
- package/dist/chunk-KR26CBFE.mjs +0 -58
- package/dist/chunk-QEXIYXXU.mjs +0 -62
- package/dist/chunk-U33GNMEZ.mjs +0 -140
- package/dist/chunk-UXIF75BV.mjs +0 -36
- package/dist/chunk-VJDH54HJ.mjs +0 -56
- package/dist/chunk-XNS4O6QJ.mjs +0 -7
- package/dist/chunk-YGXCMETR.mjs +0 -592
- package/dist/guildUtils-FTEGCNNJ.mjs +0 -17
package/dist/chunk-75ODDXY3.mjs
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ErrorCodes,
|
|
3
|
-
FluxerError
|
|
4
|
-
} from "./chunk-6S3BDHBI.mjs";
|
|
5
|
-
import {
|
|
6
|
-
Base
|
|
7
|
-
} from "./chunk-XNS4O6QJ.mjs";
|
|
8
|
-
|
|
9
|
-
// src/structures/MessageReaction.ts
|
|
10
|
-
import { Routes } from "@fluxerjs/types";
|
|
11
|
-
import { FluxerAPIError, RateLimitError } from "@fluxerjs/rest";
|
|
12
|
-
var MessageReaction = class extends Base {
|
|
13
|
-
client;
|
|
14
|
-
messageId;
|
|
15
|
-
channelId;
|
|
16
|
-
guildId;
|
|
17
|
-
emoji;
|
|
18
|
-
/** Raw gateway payload for low-level access. */
|
|
19
|
-
_data;
|
|
20
|
-
constructor(client, data) {
|
|
21
|
-
super();
|
|
22
|
-
this.client = client;
|
|
23
|
-
this._data = data;
|
|
24
|
-
this.messageId = data.message_id;
|
|
25
|
-
this.channelId = data.channel_id;
|
|
26
|
-
this.guildId = data.guild_id ?? null;
|
|
27
|
-
this.emoji = data.emoji;
|
|
28
|
-
}
|
|
29
|
-
/** Emoji as a string: unicode or "name:id" for custom. */
|
|
30
|
-
get emojiIdentifier() {
|
|
31
|
-
return this.emoji.id ? `${this.emoji.name}:${this.emoji.id}` : this.emoji.name;
|
|
32
|
-
}
|
|
33
|
-
/** Guild where this reaction was added. Resolved from cache; null for DMs or if not cached. */
|
|
34
|
-
get guild() {
|
|
35
|
-
return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Fetch the message this reaction belongs to.
|
|
39
|
-
* Use when you need to edit, delete, or otherwise interact with the message.
|
|
40
|
-
* @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
|
|
41
|
-
*/
|
|
42
|
-
async fetchMessage() {
|
|
43
|
-
try {
|
|
44
|
-
const { Message } = await import("./Message-R7KSI5YU.mjs");
|
|
45
|
-
const data = await this.client.rest.get(
|
|
46
|
-
Routes.channelMessage(this.channelId, this.messageId)
|
|
47
|
-
);
|
|
48
|
-
return new Message(this.client, data);
|
|
49
|
-
} catch (err) {
|
|
50
|
-
if (err instanceof RateLimitError) throw err;
|
|
51
|
-
if (err instanceof FluxerAPIError && err.statusCode === 404) {
|
|
52
|
-
throw new FluxerError(`Message ${this.messageId} not found in channel ${this.channelId}`, {
|
|
53
|
-
code: ErrorCodes.MessageNotFound,
|
|
54
|
-
cause: err
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export {
|
|
63
|
-
MessageReaction
|
|
64
|
-
};
|
package/dist/chunk-AH7KYH2Z.mjs
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// src/util/Events.ts
|
|
2
|
-
var Events = {
|
|
3
|
-
Ready: "ready",
|
|
4
|
-
MessageCreate: "messageCreate",
|
|
5
|
-
MessageUpdate: "messageUpdate",
|
|
6
|
-
MessageDelete: "messageDelete",
|
|
7
|
-
MessageDeleteBulk: "messageDeleteBulk",
|
|
8
|
-
MessageReactionAdd: "messageReactionAdd",
|
|
9
|
-
MessageReactionRemove: "messageReactionRemove",
|
|
10
|
-
MessageReactionRemoveAll: "messageReactionRemoveAll",
|
|
11
|
-
MessageReactionRemoveEmoji: "messageReactionRemoveEmoji",
|
|
12
|
-
InteractionCreate: "interactionCreate",
|
|
13
|
-
GuildCreate: "guildCreate",
|
|
14
|
-
GuildUpdate: "guildUpdate",
|
|
15
|
-
GuildDelete: "guildDelete",
|
|
16
|
-
GuildBanAdd: "guildBanAdd",
|
|
17
|
-
GuildBanRemove: "guildBanRemove",
|
|
18
|
-
GuildEmojisUpdate: "guildEmojisUpdate",
|
|
19
|
-
GuildStickersUpdate: "guildStickersUpdate",
|
|
20
|
-
GuildIntegrationsUpdate: "guildIntegrationsUpdate",
|
|
21
|
-
GuildMemberAdd: "guildMemberAdd",
|
|
22
|
-
GuildMemberUpdate: "guildMemberUpdate",
|
|
23
|
-
GuildMemberRemove: "guildMemberRemove",
|
|
24
|
-
GuildRoleCreate: "guildRoleCreate",
|
|
25
|
-
GuildRoleUpdate: "guildRoleUpdate",
|
|
26
|
-
GuildRoleDelete: "guildRoleDelete",
|
|
27
|
-
GuildScheduledEventCreate: "guildScheduledEventCreate",
|
|
28
|
-
GuildScheduledEventUpdate: "guildScheduledEventUpdate",
|
|
29
|
-
GuildScheduledEventDelete: "guildScheduledEventDelete",
|
|
30
|
-
ChannelCreate: "channelCreate",
|
|
31
|
-
ChannelUpdate: "channelUpdate",
|
|
32
|
-
ChannelDelete: "channelDelete",
|
|
33
|
-
ChannelPinsUpdate: "channelPinsUpdate",
|
|
34
|
-
InviteCreate: "inviteCreate",
|
|
35
|
-
InviteDelete: "inviteDelete",
|
|
36
|
-
TypingStart: "typingStart",
|
|
37
|
-
UserUpdate: "userUpdate",
|
|
38
|
-
PresenceUpdate: "presenceUpdate",
|
|
39
|
-
VoiceStateUpdate: "voiceStateUpdate",
|
|
40
|
-
VoiceServerUpdate: "voiceServerUpdate",
|
|
41
|
-
VoiceStatesSync: "voiceStatesSync",
|
|
42
|
-
WebhooksUpdate: "webhooksUpdate",
|
|
43
|
-
Resumed: "resumed",
|
|
44
|
-
Error: "error",
|
|
45
|
-
Debug: "debug"
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export {
|
|
49
|
-
Events
|
|
50
|
-
};
|
package/dist/chunk-BKPVGBOT.mjs
DELETED
package/dist/chunk-G6F6VL4O.mjs
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CDN_URL,
|
|
3
|
-
STATIC_CDN_URL
|
|
4
|
-
} from "./chunk-BKPVGBOT.mjs";
|
|
5
|
-
|
|
6
|
-
// src/util/cdn.ts
|
|
7
|
-
function getExtension(hash, options) {
|
|
8
|
-
const ext = options?.extension ?? "png";
|
|
9
|
-
if (hash?.startsWith("a_")) return "gif";
|
|
10
|
-
return ext;
|
|
11
|
-
}
|
|
12
|
-
function appendSize(options) {
|
|
13
|
-
return options?.size ? `?size=${options.size}` : "";
|
|
14
|
-
}
|
|
15
|
-
function cdnAvatarURL(userId, avatarHash, options) {
|
|
16
|
-
if (!avatarHash) return null;
|
|
17
|
-
const ext = getExtension(avatarHash, options);
|
|
18
|
-
const size = appendSize(options);
|
|
19
|
-
return `${CDN_URL}/avatars/${userId}/${avatarHash}.${ext}${size}`;
|
|
20
|
-
}
|
|
21
|
-
function cdnDisplayAvatarURL(userId, avatarHash, options) {
|
|
22
|
-
return cdnAvatarURL(userId, avatarHash, options) ?? cdnDefaultAvatarURL(userId);
|
|
23
|
-
}
|
|
24
|
-
function cdnBannerURL(resourceId, bannerHash, options) {
|
|
25
|
-
if (!bannerHash) return null;
|
|
26
|
-
const ext = getExtension(bannerHash, options);
|
|
27
|
-
const size = appendSize(options);
|
|
28
|
-
return `${CDN_URL}/banners/${resourceId}/${bannerHash}.${ext}${size}`;
|
|
29
|
-
}
|
|
30
|
-
function cdnMemberAvatarURL(guildId, userId, avatarHash, options) {
|
|
31
|
-
if (!avatarHash) return null;
|
|
32
|
-
const ext = getExtension(avatarHash, options);
|
|
33
|
-
const size = appendSize(options);
|
|
34
|
-
return `${CDN_URL}/guilds/${guildId}/users/${userId}/avatars/${avatarHash}.${ext}${size}`;
|
|
35
|
-
}
|
|
36
|
-
function cdnMemberBannerURL(guildId, userId, bannerHash, options) {
|
|
37
|
-
if (!bannerHash) return null;
|
|
38
|
-
const ext = getExtension(bannerHash, options);
|
|
39
|
-
const size = appendSize(options);
|
|
40
|
-
return `${CDN_URL}/guilds/${guildId}/users/${userId}/banners/${bannerHash}.${ext}${size}`;
|
|
41
|
-
}
|
|
42
|
-
function cdnDefaultAvatarURL(userIdOrIndex) {
|
|
43
|
-
const index = typeof userIdOrIndex === "string" ? Number(BigInt(userIdOrIndex) % 6n) : Math.abs(Math.floor(userIdOrIndex) % 6);
|
|
44
|
-
return `${STATIC_CDN_URL}/avatars/${index}.png`;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export {
|
|
48
|
-
cdnAvatarURL,
|
|
49
|
-
cdnDisplayAvatarURL,
|
|
50
|
-
cdnBannerURL,
|
|
51
|
-
cdnMemberAvatarURL,
|
|
52
|
-
cdnMemberBannerURL,
|
|
53
|
-
cdnDefaultAvatarURL
|
|
54
|
-
};
|
package/dist/chunk-HVCL7QLT.mjs
DELETED
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Events
|
|
3
|
-
} from "./chunk-AH7KYH2Z.mjs";
|
|
4
|
-
import {
|
|
5
|
-
buildSendBody,
|
|
6
|
-
resolveMessageFiles
|
|
7
|
-
} from "./chunk-VJDH54HJ.mjs";
|
|
8
|
-
import {
|
|
9
|
-
Base
|
|
10
|
-
} from "./chunk-XNS4O6QJ.mjs";
|
|
11
|
-
|
|
12
|
-
// src/structures/Message.ts
|
|
13
|
-
import { Collection as Collection2 } from "@fluxerjs/collection";
|
|
14
|
-
import { MessageType, Routes } from "@fluxerjs/types";
|
|
15
|
-
import { EmbedBuilder } from "@fluxerjs/builders";
|
|
16
|
-
|
|
17
|
-
// src/util/ReactionCollector.ts
|
|
18
|
-
import { EventEmitter } from "events";
|
|
19
|
-
import { Collection } from "@fluxerjs/collection";
|
|
20
|
-
var ReactionCollector = class extends EventEmitter {
|
|
21
|
-
client;
|
|
22
|
-
messageId;
|
|
23
|
-
channelId;
|
|
24
|
-
options;
|
|
25
|
-
collected = new Collection();
|
|
26
|
-
_timeout = null;
|
|
27
|
-
_ended = false;
|
|
28
|
-
_listener;
|
|
29
|
-
constructor(client, messageId, channelId, options = {}) {
|
|
30
|
-
super();
|
|
31
|
-
this.client = client;
|
|
32
|
-
this.messageId = messageId;
|
|
33
|
-
this.channelId = channelId;
|
|
34
|
-
this.options = {
|
|
35
|
-
filter: options.filter ?? (() => true),
|
|
36
|
-
time: options.time ?? 0,
|
|
37
|
-
max: options.max ?? 0
|
|
38
|
-
};
|
|
39
|
-
this._listener = (reaction, user, _msgId, chId, _emoji, userId) => {
|
|
40
|
-
if (this._ended || reaction.messageId !== this.messageId || chId !== this.channelId) return;
|
|
41
|
-
if (!this.options.filter(reaction, user)) return;
|
|
42
|
-
const key = `${userId}:${reaction.emoji.id ?? reaction.emoji.name}`;
|
|
43
|
-
this.collected.set(key, { reaction, user });
|
|
44
|
-
this.emit("collect", reaction, user);
|
|
45
|
-
if (this.options.max > 0 && this.collected.size >= this.options.max) {
|
|
46
|
-
this.stop("limit");
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
this.client.on(Events.MessageReactionAdd, this._listener);
|
|
50
|
-
if (this.options.time > 0) {
|
|
51
|
-
this._timeout = setTimeout(() => this.stop("time"), this.options.time);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
stop(reason = "user") {
|
|
55
|
-
if (this._ended) return;
|
|
56
|
-
this._ended = true;
|
|
57
|
-
this.client.off(Events.MessageReactionAdd, this._listener);
|
|
58
|
-
if (this._timeout) {
|
|
59
|
-
clearTimeout(this._timeout);
|
|
60
|
-
this._timeout = null;
|
|
61
|
-
}
|
|
62
|
-
this.emit("end", this.collected, reason);
|
|
63
|
-
}
|
|
64
|
-
on(event, listener) {
|
|
65
|
-
return super.on(event, listener);
|
|
66
|
-
}
|
|
67
|
-
emit(event, ...args) {
|
|
68
|
-
return super.emit(event, ...args);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
// src/structures/Message.ts
|
|
73
|
-
var Message = class _Message extends Base {
|
|
74
|
-
client;
|
|
75
|
-
id;
|
|
76
|
-
channelId;
|
|
77
|
-
guildId;
|
|
78
|
-
author;
|
|
79
|
-
content;
|
|
80
|
-
createdAt;
|
|
81
|
-
editedAt;
|
|
82
|
-
pinned;
|
|
83
|
-
attachments;
|
|
84
|
-
type;
|
|
85
|
-
flags;
|
|
86
|
-
mentionEveryone;
|
|
87
|
-
tts;
|
|
88
|
-
embeds;
|
|
89
|
-
stickers;
|
|
90
|
-
reactions;
|
|
91
|
-
messageReference;
|
|
92
|
-
messageSnapshots;
|
|
93
|
-
call;
|
|
94
|
-
referencedMessage;
|
|
95
|
-
/** Webhook ID if this message was sent via webhook. Null otherwise. */
|
|
96
|
-
webhookId;
|
|
97
|
-
/** Users mentioned in this message. */
|
|
98
|
-
mentions;
|
|
99
|
-
/** Role IDs mentioned in this message. */
|
|
100
|
-
mentionRoles;
|
|
101
|
-
/** Client-side nonce for acknowledgment. Null if not provided. */
|
|
102
|
-
nonce;
|
|
103
|
-
/** Channel where this message was sent. Resolved from cache; null if not cached (e.g. DM channel not in cache). */
|
|
104
|
-
get channel() {
|
|
105
|
-
return this.client.channels.get(this.channelId) ?? null;
|
|
106
|
-
}
|
|
107
|
-
/** Guild where this message was sent. Resolved from cache; null for DMs or if not cached. */
|
|
108
|
-
get guild() {
|
|
109
|
-
return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Resolve the channel (from cache or API). Use when you need the channel and it may not be cached.
|
|
113
|
-
* @returns The channel
|
|
114
|
-
* @throws FluxerError with CHANNEL_NOT_FOUND if the channel does not exist
|
|
115
|
-
*/
|
|
116
|
-
async resolveChannel() {
|
|
117
|
-
return this.client.channels.resolve(this.channelId);
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Resolve the guild (from cache or API). Returns null for DMs.
|
|
121
|
-
* @returns The guild, or null if this is a DM or guild not found
|
|
122
|
-
*/
|
|
123
|
-
async resolveGuild() {
|
|
124
|
-
return this.guildId ? this.client.guilds.resolve(this.guildId) : null;
|
|
125
|
-
}
|
|
126
|
-
/** @param data - API message from POST/PATCH /channels/{id}/messages or gateway MESSAGE_CREATE */
|
|
127
|
-
constructor(client, data) {
|
|
128
|
-
super();
|
|
129
|
-
this.client = client;
|
|
130
|
-
this.id = data.id;
|
|
131
|
-
this.channelId = data.channel_id;
|
|
132
|
-
this.guildId = data.guild_id ?? null;
|
|
133
|
-
this.author = client.getOrCreateUser(data.author);
|
|
134
|
-
this.content = data.content;
|
|
135
|
-
this.createdAt = new Date(data.timestamp);
|
|
136
|
-
this.editedAt = data.edited_timestamp ? new Date(data.edited_timestamp) : null;
|
|
137
|
-
this.pinned = data.pinned;
|
|
138
|
-
this.attachments = new Collection2();
|
|
139
|
-
for (const a of data.attachments ?? []) this.attachments.set(a.id, a);
|
|
140
|
-
this.type = data.type ?? MessageType.Default;
|
|
141
|
-
this.flags = data.flags ?? 0;
|
|
142
|
-
this.mentionEveryone = data.mention_everyone ?? false;
|
|
143
|
-
this.tts = data.tts ?? false;
|
|
144
|
-
this.embeds = data.embeds ?? [];
|
|
145
|
-
this.stickers = data.stickers ?? [];
|
|
146
|
-
this.reactions = data.reactions ?? [];
|
|
147
|
-
this.messageReference = data.message_reference ?? null;
|
|
148
|
-
this.messageSnapshots = data.message_snapshots ?? [];
|
|
149
|
-
this.call = data.call ?? null;
|
|
150
|
-
this.referencedMessage = data.referenced_message ? new _Message(client, data.referenced_message) : null;
|
|
151
|
-
this.webhookId = data.webhook_id ?? null;
|
|
152
|
-
this.mentions = (data.mentions ?? []).map((u) => client.getOrCreateUser(u));
|
|
153
|
-
this.mentionRoles = data.mention_roles ?? [];
|
|
154
|
-
this.nonce = data.nonce ?? null;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Send a message to this channel without replying. Use when you want a standalone message.
|
|
158
|
-
* @param options - Text content or object with content, embeds, and/or files
|
|
159
|
-
* @example
|
|
160
|
-
* await message.send('Pong!');
|
|
161
|
-
* await message.send({ embeds: [embed] }); // EmbedBuilder auto-converted
|
|
162
|
-
* await message.send({ content: 'File', files: [{ name: 'data.txt', data }] });
|
|
163
|
-
*/
|
|
164
|
-
async send(options) {
|
|
165
|
-
const opts = typeof options === "string" ? { content: options } : options;
|
|
166
|
-
const body = buildSendBody(options);
|
|
167
|
-
const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
|
|
168
|
-
const postOptions = files?.length ? { body, files } : { body };
|
|
169
|
-
const data = await this.client.rest.post(Routes.channelMessages(this.channelId), postOptions);
|
|
170
|
-
return new _Message(this.client, data);
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Send a message to a specific channel. Use for logging, forwarding, or sending to another channel in the guild.
|
|
174
|
-
* @param channelId - Snowflake of the target channel (e.g. log channel ID)
|
|
175
|
-
* @param options - Text content or object with content and/or embeds
|
|
176
|
-
* @example
|
|
177
|
-
* await message.sendTo(logChannelId, 'User ' + message.author.username + ' said: ' + message.content);
|
|
178
|
-
* await message.sendTo(announceChannelId, { embeds: [embed] });
|
|
179
|
-
*/
|
|
180
|
-
async sendTo(channelId, options) {
|
|
181
|
-
return this.client.channels.send(channelId, options);
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Reply to this message (shows as a reply in the client).
|
|
185
|
-
* @param options - Text content or object with content, embeds, and/or files
|
|
186
|
-
* @example
|
|
187
|
-
* await message.reply('Pong!');
|
|
188
|
-
* await message.reply({ embeds: [embed] });
|
|
189
|
-
*/
|
|
190
|
-
async reply(options) {
|
|
191
|
-
const opts = typeof options === "string" ? { content: options } : options;
|
|
192
|
-
const base = buildSendBody(options);
|
|
193
|
-
const body = {
|
|
194
|
-
...base,
|
|
195
|
-
message_reference: {
|
|
196
|
-
channel_id: this.channelId,
|
|
197
|
-
message_id: this.id,
|
|
198
|
-
guild_id: this.guildId ?? void 0
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
|
|
202
|
-
const postOptions = files?.length ? { body, files } : { body };
|
|
203
|
-
const data = await this.client.rest.post(Routes.channelMessages(this.channelId), postOptions);
|
|
204
|
-
return new _Message(this.client, data);
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Edit this message. Only the author (or admins) can edit.
|
|
208
|
-
* @param options - New content and/or embeds
|
|
209
|
-
*/
|
|
210
|
-
async edit(options) {
|
|
211
|
-
const body = {};
|
|
212
|
-
if (options.content !== void 0) body.content = options.content;
|
|
213
|
-
if (options.embeds?.length) {
|
|
214
|
-
body.embeds = options.embeds.map((e) => e instanceof EmbedBuilder ? e.toJSON() : e);
|
|
215
|
-
}
|
|
216
|
-
const data = await this.client.rest.patch(Routes.channelMessage(this.channelId, this.id), {
|
|
217
|
-
body
|
|
218
|
-
});
|
|
219
|
-
return new _Message(this.client, data);
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Create a reaction collector for this message.
|
|
223
|
-
* Collects reactions matching the filter until time expires or max is reached.
|
|
224
|
-
* @param options - Filter, time (ms), and max count
|
|
225
|
-
* @example
|
|
226
|
-
* const collector = message.createReactionCollector({ filter: (r, u) => u.id === userId, time: 10000 });
|
|
227
|
-
* collector.on('collect', (reaction, user) => console.log(user.username, 'reacted with', reaction.emoji.name));
|
|
228
|
-
* collector.on('end', (collected, reason) => { ... });
|
|
229
|
-
*/
|
|
230
|
-
createReactionCollector(options) {
|
|
231
|
-
return new ReactionCollector(this.client, this.id, this.channelId, options);
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Re-fetch this message from the API to get the latest content, embeds, reactions, etc.
|
|
235
|
-
* Use when you have a stale Message (e.g. from an old event or cache) and need fresh data.
|
|
236
|
-
* @returns The updated message
|
|
237
|
-
* @throws FluxerError with MESSAGE_NOT_FOUND if the message was deleted or does not exist
|
|
238
|
-
* @example
|
|
239
|
-
* const updated = await message.fetch();
|
|
240
|
-
* console.log('Latest content:', updated.content);
|
|
241
|
-
*/
|
|
242
|
-
async fetch() {
|
|
243
|
-
return this.client.channels.fetchMessage(this.channelId, this.id);
|
|
244
|
-
}
|
|
245
|
-
/** Delete this message. */
|
|
246
|
-
async delete() {
|
|
247
|
-
await this.client.rest.delete(Routes.channelMessage(this.channelId, this.id));
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Delete a specific attachment from this message.
|
|
251
|
-
* DELETE /channels/{id}/messages/{id}/attachments/{attachmentId}.
|
|
252
|
-
*/
|
|
253
|
-
async deleteAttachment(attachmentId) {
|
|
254
|
-
await this.client.rest.delete(
|
|
255
|
-
Routes.channelMessageAttachment(this.channelId, this.id, attachmentId),
|
|
256
|
-
{ auth: true }
|
|
257
|
-
);
|
|
258
|
-
this.attachments.delete(attachmentId);
|
|
259
|
-
}
|
|
260
|
-
/** Pin this message to the channel. Requires Manage Messages permission. */
|
|
261
|
-
async pin() {
|
|
262
|
-
await this.client.rest.put(Routes.channelPinMessage(this.channelId, this.id));
|
|
263
|
-
this.pinned = true;
|
|
264
|
-
}
|
|
265
|
-
/** Unpin this message from the channel. Requires Manage Messages permission. */
|
|
266
|
-
async unpin() {
|
|
267
|
-
await this.client.rest.delete(Routes.channelPinMessage(this.channelId, this.id));
|
|
268
|
-
this.pinned = false;
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Format emoji for reaction API: unicode string or "name:id" for custom.
|
|
272
|
-
* For string resolution (e.g. :name:), use client.resolveEmoji; Message methods resolve automatically when guildId is available.
|
|
273
|
-
*/
|
|
274
|
-
static formatEmoji(emoji) {
|
|
275
|
-
if (typeof emoji === "string") return emoji;
|
|
276
|
-
return `${emoji.name}:${emoji.id}`;
|
|
277
|
-
}
|
|
278
|
-
resolveEmojiForReaction(emoji) {
|
|
279
|
-
return this.client.resolveEmoji(emoji, this.guildId);
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Add a reaction to this message (as the bot).
|
|
283
|
-
* @param emoji - Unicode emoji, custom `{ name, id }`, `:name:`, `name:id`, or `<:name:id>`
|
|
284
|
-
*/
|
|
285
|
-
async react(emoji) {
|
|
286
|
-
const emojiStr = await this.resolveEmojiForReaction(emoji);
|
|
287
|
-
const route = `${Routes.channelMessageReaction(this.channelId, this.id, emojiStr)}/@me`;
|
|
288
|
-
await this.client.rest.put(route);
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Remove the bot's reaction, or a specific user's reaction if userId is provided.
|
|
292
|
-
* @param emoji - Unicode emoji, custom `{ name, id }`, `:name:`, `name:id`, or `<:name:id>`
|
|
293
|
-
* @param userId - If provided, removes that user's reaction (requires moderator permissions)
|
|
294
|
-
*/
|
|
295
|
-
async removeReaction(emoji, userId) {
|
|
296
|
-
const emojiStr = await this.resolveEmojiForReaction(emoji);
|
|
297
|
-
const route = `${Routes.channelMessageReaction(this.channelId, this.id, emojiStr)}/${userId ?? "@me"}`;
|
|
298
|
-
await this.client.rest.delete(route);
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* Remove all reactions from this message.
|
|
302
|
-
* Requires moderator permissions.
|
|
303
|
-
*/
|
|
304
|
-
async removeAllReactions() {
|
|
305
|
-
await this.client.rest.delete(Routes.channelMessageReactions(this.channelId, this.id));
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Remove all reactions of a specific emoji from this message.
|
|
309
|
-
* @param emoji - Unicode emoji, custom `{ name, id }`, `:name:`, `name:id`, or `<:name:id>`. Requires moderator permissions.
|
|
310
|
-
*/
|
|
311
|
-
async removeReactionEmoji(emoji) {
|
|
312
|
-
const emojiStr = await this.resolveEmojiForReaction(emoji);
|
|
313
|
-
await this.client.rest.delete(Routes.channelMessageReaction(this.channelId, this.id, emojiStr));
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Fetch users who reacted with the given emoji.
|
|
317
|
-
* @param emoji - Unicode emoji or custom `{ name, id }`
|
|
318
|
-
* @param options - limit (1–100), after (user ID for pagination)
|
|
319
|
-
* @returns Array of User objects
|
|
320
|
-
*/
|
|
321
|
-
async fetchReactionUsers(emoji, options) {
|
|
322
|
-
const emojiStr = await this.resolveEmojiForReaction(emoji);
|
|
323
|
-
const params = new URLSearchParams();
|
|
324
|
-
if (options?.limit != null) params.set("limit", String(options.limit));
|
|
325
|
-
if (options?.after) params.set("after", options.after);
|
|
326
|
-
const qs = params.toString();
|
|
327
|
-
const route = Routes.channelMessageReaction(this.channelId, this.id, emojiStr) + (qs ? `?${qs}` : "");
|
|
328
|
-
const data = await this.client.rest.get(route);
|
|
329
|
-
const list = Array.isArray(data) ? data : data?.users ?? [];
|
|
330
|
-
return list.map((u) => this.client.getOrCreateUser(u));
|
|
331
|
-
}
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
export {
|
|
335
|
-
ReactionCollector,
|
|
336
|
-
Message
|
|
337
|
-
};
|
package/dist/chunk-IHXSHE2Z.mjs
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CDN_URL
|
|
3
|
-
} from "./chunk-BKPVGBOT.mjs";
|
|
4
|
-
import {
|
|
5
|
-
Base
|
|
6
|
-
} from "./chunk-XNS4O6QJ.mjs";
|
|
7
|
-
|
|
8
|
-
// src/structures/GuildEmoji.ts
|
|
9
|
-
import { Routes } from "@fluxerjs/types";
|
|
10
|
-
var GuildEmoji = class extends Base {
|
|
11
|
-
client;
|
|
12
|
-
id;
|
|
13
|
-
guildId;
|
|
14
|
-
name;
|
|
15
|
-
animated;
|
|
16
|
-
/** @param data - API emoji from GET /guilds/{id}/emojis or guild emoji events */
|
|
17
|
-
constructor(client, data, guildId) {
|
|
18
|
-
super();
|
|
19
|
-
this.client = client;
|
|
20
|
-
this.id = data.id;
|
|
21
|
-
this.guildId = data.guild_id ?? guildId;
|
|
22
|
-
this.name = data.name;
|
|
23
|
-
this.animated = data.animated ?? false;
|
|
24
|
-
}
|
|
25
|
-
/** CDN URL for this emoji image. */
|
|
26
|
-
get url() {
|
|
27
|
-
const ext = this.animated ? "gif" : "png";
|
|
28
|
-
return `${CDN_URL}/emojis/${this.id}.${ext}`;
|
|
29
|
-
}
|
|
30
|
-
/** Emoji identifier for use in reactions: `name:id` */
|
|
31
|
-
get identifier() {
|
|
32
|
-
return `${this.name}:${this.id}`;
|
|
33
|
-
}
|
|
34
|
-
/** Delete this emoji. Requires Manage Emojis and Stickers permission. */
|
|
35
|
-
async delete() {
|
|
36
|
-
await this.client.rest.delete(Routes.guildEmoji(this.guildId, this.id), {
|
|
37
|
-
auth: true
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Edit this emoji's name.
|
|
42
|
-
* Requires Manage Emojis and Stickers permission.
|
|
43
|
-
*/
|
|
44
|
-
async edit(options) {
|
|
45
|
-
const data = await this.client.rest.patch(Routes.guildEmoji(this.guildId, this.id), {
|
|
46
|
-
body: options,
|
|
47
|
-
auth: true
|
|
48
|
-
});
|
|
49
|
-
this.name = data.name;
|
|
50
|
-
return this;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export {
|
|
55
|
-
GuildEmoji
|
|
56
|
-
};
|