@fluxerjs/core 1.0.9 → 1.1.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/LICENSE +203 -0
- package/dist/{Channel-ICWNKXBR.mjs → Channel-4WVFDOCG.mjs} +4 -1
- package/dist/{ClientUser-WWXUMO5O.mjs → ClientUser-PXAAKR2P.mjs} +1 -1
- package/dist/Guild-FMBCTAV4.mjs +12 -0
- package/dist/{GuildBan-M4PA3HAA.mjs → GuildBan-7CXLTPKY.mjs} +1 -1
- package/dist/GuildMember-43B5E5CH.mjs +9 -0
- package/dist/Message-OFIVTTAZ.mjs +9 -0
- package/dist/{MessageReaction-XRPYZDSC.mjs → MessageReaction-AYSOCOMX.mjs} +2 -1
- package/dist/{Role-SVLWIAMN.mjs → Role-5MWSGL66.mjs} +1 -1
- package/dist/Webhook-RWDDYW2Q.mjs +10 -0
- package/dist/{chunk-GCIJYVRC.mjs → chunk-4F765HVV.mjs} +54 -3
- package/dist/chunk-AH7KYH2Z.mjs +50 -0
- package/dist/{chunk-53Y37KRG.mjs → chunk-CJVQNARM.mjs} +44 -10
- package/dist/chunk-DQ4TNBPG.mjs +63 -0
- package/dist/chunk-DUQAD7F6.mjs +173 -0
- package/dist/chunk-FRVZ7D6D.mjs +293 -0
- package/dist/{chunk-HBF5QEDH.mjs → chunk-K6NLD6SB.mjs} +23 -1
- package/dist/chunk-PM2IUGNR.mjs +29 -0
- package/dist/chunk-RWFKZ3DF.mjs +413 -0
- package/dist/{chunk-RCP27MRC.mjs → chunk-UXIF75BV.mjs} +3 -0
- package/dist/chunk-V6T5VMWD.mjs +26 -0
- package/dist/{chunk-DSPSRPHF.mjs → chunk-V7LPVPGH.mjs} +123 -18
- package/dist/chunk-X6K3ZD62.mjs +53 -0
- package/dist/index.d.mts +603 -113
- package/dist/index.d.ts +603 -113
- package/dist/index.js +1335 -426
- package/dist/index.mjs +189 -125
- package/package.json +8 -8
- package/dist/Guild-TM6YGJWB.mjs +0 -10
- package/dist/GuildMember-RZWZ3OCG.mjs +0 -7
- package/dist/Message-6IYEYSV6.mjs +0 -7
- package/dist/Webhook-32VJD4AL.mjs +0 -7
- package/dist/chunk-FJS5FBXO.mjs +0 -233
- package/dist/chunk-GFUJVQ7L.mjs +0 -64
- package/dist/chunk-SQVCCSNN.mjs +0 -41
- package/dist/chunk-X77DFNE3.mjs +0 -136
package/dist/index.mjs
CHANGED
|
@@ -1,44 +1,64 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
Guild
|
|
3
|
+
} from "./chunk-FRVZ7D6D.mjs";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
} from "./chunk-
|
|
5
|
+
MessageReaction
|
|
6
|
+
} from "./chunk-K6NLD6SB.mjs";
|
|
7
7
|
import {
|
|
8
8
|
ClientUser,
|
|
9
9
|
User
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-4F765HVV.mjs";
|
|
11
|
+
import {
|
|
12
|
+
Message,
|
|
13
|
+
ReactionCollector
|
|
14
|
+
} from "./chunk-V7LPVPGH.mjs";
|
|
11
15
|
import {
|
|
12
16
|
Webhook
|
|
13
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-CJVQNARM.mjs";
|
|
14
18
|
import {
|
|
15
|
-
|
|
16
|
-
} from "./chunk-
|
|
19
|
+
Invite
|
|
20
|
+
} from "./chunk-QEXIYXXU.mjs";
|
|
17
21
|
import {
|
|
18
22
|
CategoryChannel,
|
|
19
23
|
Channel,
|
|
20
24
|
DMChannel,
|
|
21
25
|
GuildChannel,
|
|
22
26
|
LinkChannel,
|
|
27
|
+
MessageCollector,
|
|
23
28
|
MessageManager,
|
|
24
29
|
TextChannel,
|
|
25
30
|
VoiceChannel
|
|
26
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-RWFKZ3DF.mjs";
|
|
27
32
|
import {
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
ErrorCodes,
|
|
34
|
+
FluxerError
|
|
35
|
+
} from "./chunk-V6T5VMWD.mjs";
|
|
30
36
|
import {
|
|
31
|
-
|
|
32
|
-
} from "./chunk-
|
|
37
|
+
Events
|
|
38
|
+
} from "./chunk-AH7KYH2Z.mjs";
|
|
39
|
+
import {
|
|
40
|
+
buildSendBody
|
|
41
|
+
} from "./chunk-PM2IUGNR.mjs";
|
|
33
42
|
import {
|
|
34
43
|
GuildMember
|
|
35
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-DUQAD7F6.mjs";
|
|
45
|
+
import {
|
|
46
|
+
cdnAvatarURL,
|
|
47
|
+
cdnBannerURL,
|
|
48
|
+
cdnDefaultAvatarURL,
|
|
49
|
+
cdnDisplayAvatarURL,
|
|
50
|
+
cdnMemberAvatarURL,
|
|
51
|
+
cdnMemberBannerURL
|
|
52
|
+
} from "./chunk-X6K3ZD62.mjs";
|
|
53
|
+
import {
|
|
54
|
+
CDN_URL
|
|
55
|
+
} from "./chunk-HQMYRYMY.mjs";
|
|
36
56
|
import {
|
|
37
57
|
Role
|
|
38
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-DQ4TNBPG.mjs";
|
|
39
59
|
import {
|
|
40
|
-
|
|
41
|
-
} from "./chunk-
|
|
60
|
+
GuildBan
|
|
61
|
+
} from "./chunk-UXIF75BV.mjs";
|
|
42
62
|
import {
|
|
43
63
|
Base
|
|
44
64
|
} from "./chunk-XNS4O6QJ.mjs";
|
|
@@ -53,6 +73,8 @@ import { Collection as Collection3 } from "@fluxerjs/collection";
|
|
|
53
73
|
// src/client/ChannelManager.ts
|
|
54
74
|
import { Collection } from "@fluxerjs/collection";
|
|
55
75
|
import { Routes } from "@fluxerjs/types";
|
|
76
|
+
import { emitDeprecationWarning } from "@fluxerjs/util";
|
|
77
|
+
import { FluxerAPIError, RateLimitError } from "@fluxerjs/rest";
|
|
56
78
|
var ChannelManager = class extends Collection {
|
|
57
79
|
constructor(client) {
|
|
58
80
|
super();
|
|
@@ -61,7 +83,8 @@ var ChannelManager = class extends Collection {
|
|
|
61
83
|
/**
|
|
62
84
|
* Fetch a channel by ID from the API (or return from cache if present).
|
|
63
85
|
* @param channelId - Snowflake of the channel
|
|
64
|
-
* @returns The channel
|
|
86
|
+
* @returns The channel
|
|
87
|
+
* @throws FluxerError with CHANNEL_NOT_FOUND if the channel does not exist
|
|
65
88
|
* @example
|
|
66
89
|
* const channel = await client.channels.fetch(channelId);
|
|
67
90
|
* if (channel?.isSendable()) await channel.send('Hello!');
|
|
@@ -70,52 +93,79 @@ var ChannelManager = class extends Collection {
|
|
|
70
93
|
const cached = this.get(channelId);
|
|
71
94
|
if (cached) return cached;
|
|
72
95
|
try {
|
|
73
|
-
const { Channel: Channel2 } = await import("./Channel-
|
|
96
|
+
const { Channel: Channel2 } = await import("./Channel-4WVFDOCG.mjs");
|
|
74
97
|
const data = await this.client.rest.get(
|
|
75
98
|
Routes.channel(channelId)
|
|
76
99
|
);
|
|
77
100
|
const channel = Channel2.fromOrCreate(this.client, data);
|
|
78
|
-
if (channel)
|
|
101
|
+
if (!channel) {
|
|
102
|
+
throw new FluxerError("Channel data invalid or unsupported type", {
|
|
103
|
+
code: ErrorCodes.ChannelNotFound
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
this.set(channel.id, channel);
|
|
79
107
|
return channel;
|
|
80
|
-
} catch {
|
|
81
|
-
|
|
108
|
+
} catch (err) {
|
|
109
|
+
if (err instanceof RateLimitError) throw err;
|
|
110
|
+
if (err instanceof FluxerAPIError && err.statusCode === 404) {
|
|
111
|
+
throw new FluxerError(`Channel ${channelId} not found`, {
|
|
112
|
+
code: ErrorCodes.ChannelNotFound,
|
|
113
|
+
cause: err
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
|
|
82
117
|
}
|
|
83
118
|
}
|
|
84
119
|
/**
|
|
85
120
|
* Fetch a message by ID from the API.
|
|
86
121
|
* @param channelId - Snowflake of the channel
|
|
87
122
|
* @param messageId - Snowflake of the message
|
|
88
|
-
* @returns The message
|
|
123
|
+
* @returns The message
|
|
124
|
+
* @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
|
|
89
125
|
* @deprecated Use channel.messages.fetch(messageId). Prefer (await client.channels.fetch(channelId))?.messages?.fetch(messageId).
|
|
90
126
|
* @example
|
|
91
127
|
* const channel = await client.channels.fetch(channelId);
|
|
92
128
|
* const message = await channel?.messages?.fetch(messageId);
|
|
93
129
|
*/
|
|
94
130
|
async fetchMessage(channelId, messageId) {
|
|
131
|
+
emitDeprecationWarning(
|
|
132
|
+
"ChannelManager.fetchMessage()",
|
|
133
|
+
"Use channel.messages.fetch(messageId). Prefer (await client.channels.fetch(channelId))?.messages?.fetch(messageId)."
|
|
134
|
+
);
|
|
95
135
|
try {
|
|
96
|
-
const { Message: Message2 } = await import("./Message-
|
|
136
|
+
const { Message: Message2 } = await import("./Message-OFIVTTAZ.mjs");
|
|
97
137
|
const data = await this.client.rest.get(
|
|
98
138
|
Routes.channelMessage(channelId, messageId)
|
|
99
139
|
);
|
|
100
140
|
return new Message2(this.client, data);
|
|
101
|
-
} catch {
|
|
102
|
-
|
|
141
|
+
} catch (err) {
|
|
142
|
+
if (err instanceof RateLimitError) throw err;
|
|
143
|
+
if (err instanceof FluxerAPIError && err.statusCode === 404) {
|
|
144
|
+
throw new FluxerError(`Message ${messageId} not found in channel ${channelId}`, {
|
|
145
|
+
code: ErrorCodes.MessageNotFound,
|
|
146
|
+
cause: err
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
|
|
103
150
|
}
|
|
104
151
|
}
|
|
105
152
|
/**
|
|
106
153
|
* Send a message to a channel by ID. Works even when the channel is not cached.
|
|
107
154
|
* Skips the fetch when you only need to send.
|
|
108
155
|
* @param channelId - Snowflake of the channel (text channel or DM)
|
|
109
|
-
* @param payload - Text content or object with content and/or
|
|
156
|
+
* @param payload - Text content or object with content, embeds, and/or files
|
|
110
157
|
* @returns The created message
|
|
111
158
|
* @example
|
|
112
159
|
* await client.channels.send(logChannelId, 'User joined!');
|
|
113
160
|
* await client.channels.send(channelId, { embeds: [embed.toJSON()] });
|
|
161
|
+
* await client.channels.send(channelId, { content: 'Report', files: [{ name: 'log.txt', data }] });
|
|
114
162
|
*/
|
|
115
163
|
async send(channelId, payload) {
|
|
116
|
-
const
|
|
117
|
-
const
|
|
118
|
-
const
|
|
164
|
+
const opts = typeof payload === "string" ? { content: payload } : payload;
|
|
165
|
+
const body = buildSendBody(payload);
|
|
166
|
+
const { Message: Message2 } = await import("./Message-OFIVTTAZ.mjs");
|
|
167
|
+
const postOptions = opts.files?.length ? { body, files: opts.files } : { body };
|
|
168
|
+
const data = await this.client.rest.post(Routes.channelMessages(channelId), postOptions);
|
|
119
169
|
return new Message2(this.client, data);
|
|
120
170
|
}
|
|
121
171
|
};
|
|
@@ -140,7 +190,7 @@ var GuildManager = class extends Collection2 {
|
|
|
140
190
|
const cached = this.get(guildId);
|
|
141
191
|
if (cached) return cached;
|
|
142
192
|
try {
|
|
143
|
-
const { Guild: Guild2 } = await import("./Guild-
|
|
193
|
+
const { Guild: Guild2 } = await import("./Guild-FMBCTAV4.mjs");
|
|
144
194
|
const data = await this.client.rest.get(
|
|
145
195
|
Routes2.guild(guildId)
|
|
146
196
|
);
|
|
@@ -153,73 +203,27 @@ var GuildManager = class extends Collection2 {
|
|
|
153
203
|
}
|
|
154
204
|
};
|
|
155
205
|
|
|
156
|
-
// src/errors/FluxerError.ts
|
|
157
|
-
var FluxerError = class _FluxerError extends Error {
|
|
158
|
-
constructor(message) {
|
|
159
|
-
super(message);
|
|
160
|
-
this.name = "FluxerError";
|
|
161
|
-
Object.setPrototypeOf(this, _FluxerError.prototype);
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
// src/util/Events.ts
|
|
166
|
-
var Events = {
|
|
167
|
-
Ready: "ready",
|
|
168
|
-
MessageCreate: "messageCreate",
|
|
169
|
-
MessageUpdate: "messageUpdate",
|
|
170
|
-
MessageDelete: "messageDelete",
|
|
171
|
-
MessageDeleteBulk: "messageDeleteBulk",
|
|
172
|
-
MessageReactionAdd: "messageReactionAdd",
|
|
173
|
-
MessageReactionRemove: "messageReactionRemove",
|
|
174
|
-
MessageReactionRemoveAll: "messageReactionRemoveAll",
|
|
175
|
-
MessageReactionRemoveEmoji: "messageReactionRemoveEmoji",
|
|
176
|
-
InteractionCreate: "interactionCreate",
|
|
177
|
-
GuildCreate: "guildCreate",
|
|
178
|
-
GuildUpdate: "guildUpdate",
|
|
179
|
-
GuildDelete: "guildDelete",
|
|
180
|
-
GuildBanAdd: "guildBanAdd",
|
|
181
|
-
GuildBanRemove: "guildBanRemove",
|
|
182
|
-
GuildEmojisUpdate: "guildEmojisUpdate",
|
|
183
|
-
GuildStickersUpdate: "guildStickersUpdate",
|
|
184
|
-
GuildIntegrationsUpdate: "guildIntegrationsUpdate",
|
|
185
|
-
GuildMemberAdd: "guildMemberAdd",
|
|
186
|
-
GuildMemberUpdate: "guildMemberUpdate",
|
|
187
|
-
GuildMemberRemove: "guildMemberRemove",
|
|
188
|
-
GuildRoleCreate: "guildRoleCreate",
|
|
189
|
-
GuildRoleUpdate: "guildRoleUpdate",
|
|
190
|
-
GuildRoleDelete: "guildRoleDelete",
|
|
191
|
-
GuildScheduledEventCreate: "guildScheduledEventCreate",
|
|
192
|
-
GuildScheduledEventUpdate: "guildScheduledEventUpdate",
|
|
193
|
-
GuildScheduledEventDelete: "guildScheduledEventDelete",
|
|
194
|
-
ChannelCreate: "channelCreate",
|
|
195
|
-
ChannelUpdate: "channelUpdate",
|
|
196
|
-
ChannelDelete: "channelDelete",
|
|
197
|
-
ChannelPinsUpdate: "channelPinsUpdate",
|
|
198
|
-
InviteCreate: "inviteCreate",
|
|
199
|
-
InviteDelete: "inviteDelete",
|
|
200
|
-
TypingStart: "typingStart",
|
|
201
|
-
UserUpdate: "userUpdate",
|
|
202
|
-
PresenceUpdate: "presenceUpdate",
|
|
203
|
-
VoiceStateUpdate: "voiceStateUpdate",
|
|
204
|
-
VoiceServerUpdate: "voiceServerUpdate",
|
|
205
|
-
VoiceStatesSync: "voiceStatesSync",
|
|
206
|
-
WebhooksUpdate: "webhooksUpdate",
|
|
207
|
-
Resumed: "resumed",
|
|
208
|
-
Error: "error",
|
|
209
|
-
Debug: "debug"
|
|
210
|
-
};
|
|
211
|
-
|
|
212
206
|
// src/client/Client.ts
|
|
213
|
-
import { formatEmoji, parseEmoji } from "@fluxerjs/util";
|
|
207
|
+
import { emitDeprecationWarning as emitDeprecationWarning2, formatEmoji, parseEmoji } from "@fluxerjs/util";
|
|
214
208
|
|
|
215
209
|
// src/client/EventHandlerRegistry.ts
|
|
216
210
|
var handlers = /* @__PURE__ */ new Map();
|
|
217
211
|
handlers.set("MESSAGE_CREATE", async (client, d) => {
|
|
218
|
-
const { Message: Message2 } = await import("./Message-
|
|
219
|
-
|
|
212
|
+
const { Message: Message2 } = await import("./Message-OFIVTTAZ.mjs");
|
|
213
|
+
const { GuildMember: GuildMember2 } = await import("./GuildMember-43B5E5CH.mjs");
|
|
214
|
+
const data = d;
|
|
215
|
+
if (data.guild_id && data.member && data.author) {
|
|
216
|
+
const guild = client.guilds.get(data.guild_id);
|
|
217
|
+
if (guild) {
|
|
218
|
+
const memberData = { ...data.member, user: data.author, guild_id: data.guild_id };
|
|
219
|
+
const member = new GuildMember2(client, memberData, guild);
|
|
220
|
+
guild.members.set(member.id, member);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
client.emit(Events.MessageCreate, new Message2(client, data));
|
|
220
224
|
});
|
|
221
225
|
handlers.set("MESSAGE_UPDATE", async (client, d) => {
|
|
222
|
-
const { Message: Message2 } = await import("./Message-
|
|
226
|
+
const { Message: Message2 } = await import("./Message-OFIVTTAZ.mjs");
|
|
223
227
|
client.emit(Events.MessageUpdate, null, new Message2(client, d));
|
|
224
228
|
});
|
|
225
229
|
handlers.set("MESSAGE_DELETE", async (client, d) => {
|
|
@@ -233,25 +237,41 @@ handlers.set("MESSAGE_DELETE", async (client, d) => {
|
|
|
233
237
|
});
|
|
234
238
|
handlers.set("MESSAGE_REACTION_ADD", async (client, d) => {
|
|
235
239
|
const data = d;
|
|
236
|
-
const { MessageReaction: MessageReaction2 } = await import("./MessageReaction-
|
|
240
|
+
const { MessageReaction: MessageReaction2 } = await import("./MessageReaction-AYSOCOMX.mjs");
|
|
237
241
|
const reaction = new MessageReaction2(client, data);
|
|
238
242
|
const user = client.getOrCreateUser({
|
|
239
243
|
id: data.user_id,
|
|
240
244
|
username: "Unknown",
|
|
241
245
|
discriminator: "0"
|
|
242
246
|
});
|
|
243
|
-
client.emit(
|
|
247
|
+
client.emit(
|
|
248
|
+
Events.MessageReactionAdd,
|
|
249
|
+
reaction,
|
|
250
|
+
user,
|
|
251
|
+
reaction.messageId,
|
|
252
|
+
reaction.channelId,
|
|
253
|
+
reaction.emoji,
|
|
254
|
+
user.id
|
|
255
|
+
);
|
|
244
256
|
});
|
|
245
257
|
handlers.set("MESSAGE_REACTION_REMOVE", async (client, d) => {
|
|
246
258
|
const data = d;
|
|
247
|
-
const { MessageReaction: MessageReaction2 } = await import("./MessageReaction-
|
|
259
|
+
const { MessageReaction: MessageReaction2 } = await import("./MessageReaction-AYSOCOMX.mjs");
|
|
248
260
|
const reaction = new MessageReaction2(client, data);
|
|
249
261
|
const user = client.getOrCreateUser({
|
|
250
262
|
id: data.user_id,
|
|
251
263
|
username: "Unknown",
|
|
252
264
|
discriminator: "0"
|
|
253
265
|
});
|
|
254
|
-
client.emit(
|
|
266
|
+
client.emit(
|
|
267
|
+
Events.MessageReactionRemove,
|
|
268
|
+
reaction,
|
|
269
|
+
user,
|
|
270
|
+
reaction.messageId,
|
|
271
|
+
reaction.channelId,
|
|
272
|
+
reaction.emoji,
|
|
273
|
+
user.id
|
|
274
|
+
);
|
|
255
275
|
});
|
|
256
276
|
handlers.set("MESSAGE_REACTION_REMOVE_ALL", async (client, d) => {
|
|
257
277
|
client.emit(Events.MessageReactionRemoveAll, d);
|
|
@@ -263,9 +283,11 @@ handlers.set("MESSAGE_REACTION_REMOVE_EMOJI", async (client, d) => {
|
|
|
263
283
|
);
|
|
264
284
|
});
|
|
265
285
|
handlers.set("GUILD_CREATE", async (client, d) => {
|
|
266
|
-
const { Guild: Guild2 } = await import("./Guild-
|
|
267
|
-
const { Channel: Channel2 } = await import("./Channel-
|
|
268
|
-
const
|
|
286
|
+
const { Guild: Guild2 } = await import("./Guild-FMBCTAV4.mjs");
|
|
287
|
+
const { Channel: Channel2 } = await import("./Channel-4WVFDOCG.mjs");
|
|
288
|
+
const raw = d;
|
|
289
|
+
const guildData = raw?.properties != null ? { ...raw.properties, roles: raw.roles } : raw;
|
|
290
|
+
const guild = new Guild2(client, guildData);
|
|
269
291
|
client.guilds.set(guild.id, guild);
|
|
270
292
|
const g = d;
|
|
271
293
|
for (const ch of g.channels ?? []) {
|
|
@@ -278,10 +300,11 @@ handlers.set("GUILD_CREATE", async (client, d) => {
|
|
|
278
300
|
}
|
|
279
301
|
});
|
|
280
302
|
handlers.set("GUILD_UPDATE", async (client, d) => {
|
|
281
|
-
const { Guild: Guild2 } = await import("./Guild-
|
|
282
|
-
const
|
|
283
|
-
const
|
|
284
|
-
const
|
|
303
|
+
const { Guild: Guild2 } = await import("./Guild-FMBCTAV4.mjs");
|
|
304
|
+
const raw = d;
|
|
305
|
+
const guildData = raw?.properties != null ? { ...raw.properties, roles: raw.roles } : raw;
|
|
306
|
+
const old = client.guilds.get(guildData.id);
|
|
307
|
+
const updated = new Guild2(client, guildData);
|
|
285
308
|
client.guilds.set(updated.id, updated);
|
|
286
309
|
client.emit(Events.GuildUpdate, old ?? updated, updated);
|
|
287
310
|
});
|
|
@@ -294,7 +317,7 @@ handlers.set("GUILD_DELETE", async (client, d) => {
|
|
|
294
317
|
}
|
|
295
318
|
});
|
|
296
319
|
handlers.set("CHANNEL_CREATE", async (client, d) => {
|
|
297
|
-
const { Channel: Channel2 } = await import("./Channel-
|
|
320
|
+
const { Channel: Channel2 } = await import("./Channel-4WVFDOCG.mjs");
|
|
298
321
|
const ch = Channel2.from(client, d);
|
|
299
322
|
if (ch) {
|
|
300
323
|
client.channels.set(ch.id, ch);
|
|
@@ -302,7 +325,7 @@ handlers.set("CHANNEL_CREATE", async (client, d) => {
|
|
|
302
325
|
}
|
|
303
326
|
});
|
|
304
327
|
handlers.set("CHANNEL_UPDATE", async (client, d) => {
|
|
305
|
-
const { Channel: Channel2 } = await import("./Channel-
|
|
328
|
+
const { Channel: Channel2 } = await import("./Channel-4WVFDOCG.mjs");
|
|
306
329
|
const ch = d;
|
|
307
330
|
const oldCh = client.channels.get(ch.id);
|
|
308
331
|
const newCh = Channel2.from(client, ch);
|
|
@@ -320,7 +343,7 @@ handlers.set("CHANNEL_DELETE", async (client, d) => {
|
|
|
320
343
|
}
|
|
321
344
|
});
|
|
322
345
|
handlers.set("GUILD_MEMBER_ADD", async (client, d) => {
|
|
323
|
-
const { GuildMember: GuildMember2 } = await import("./GuildMember-
|
|
346
|
+
const { GuildMember: GuildMember2 } = await import("./GuildMember-43B5E5CH.mjs");
|
|
324
347
|
const data = d;
|
|
325
348
|
const guild = client.guilds.get(data.guild_id);
|
|
326
349
|
if (guild) {
|
|
@@ -330,7 +353,7 @@ handlers.set("GUILD_MEMBER_ADD", async (client, d) => {
|
|
|
330
353
|
}
|
|
331
354
|
});
|
|
332
355
|
handlers.set("GUILD_MEMBER_UPDATE", async (client, d) => {
|
|
333
|
-
const { GuildMember: GuildMember2 } = await import("./GuildMember-
|
|
356
|
+
const { GuildMember: GuildMember2 } = await import("./GuildMember-43B5E5CH.mjs");
|
|
334
357
|
const data = d;
|
|
335
358
|
const guild = client.guilds.get(data.guild_id);
|
|
336
359
|
if (guild) {
|
|
@@ -365,13 +388,13 @@ handlers.set("MESSAGE_DELETE_BULK", async (client, d) => {
|
|
|
365
388
|
});
|
|
366
389
|
handlers.set("GUILD_BAN_ADD", async (client, d) => {
|
|
367
390
|
const data = d;
|
|
368
|
-
const { GuildBan: GuildBan2 } = await import("./GuildBan-
|
|
391
|
+
const { GuildBan: GuildBan2 } = await import("./GuildBan-7CXLTPKY.mjs");
|
|
369
392
|
const ban = new GuildBan2(client, data, data.guild_id);
|
|
370
393
|
client.emit(Events.GuildBanAdd, ban);
|
|
371
394
|
});
|
|
372
395
|
handlers.set("GUILD_BAN_REMOVE", async (client, d) => {
|
|
373
396
|
const data = d;
|
|
374
|
-
const { GuildBan: GuildBan2 } = await import("./GuildBan-
|
|
397
|
+
const { GuildBan: GuildBan2 } = await import("./GuildBan-7CXLTPKY.mjs");
|
|
375
398
|
const ban = new GuildBan2(client, { ...data, reason: null }, data.guild_id);
|
|
376
399
|
client.emit(Events.GuildBanRemove, ban);
|
|
377
400
|
});
|
|
@@ -388,7 +411,7 @@ handlers.set("GUILD_ROLE_CREATE", async (client, d) => {
|
|
|
388
411
|
const data = d;
|
|
389
412
|
const guild = client.guilds.get(data.guild_id);
|
|
390
413
|
if (guild) {
|
|
391
|
-
const { Role: Role2 } = await import("./Role-
|
|
414
|
+
const { Role: Role2 } = await import("./Role-5MWSGL66.mjs");
|
|
392
415
|
guild.roles.set(data.role.id, new Role2(client, data.role, guild.id));
|
|
393
416
|
}
|
|
394
417
|
client.emit(Events.GuildRoleCreate, data);
|
|
@@ -397,7 +420,7 @@ handlers.set("GUILD_ROLE_UPDATE", async (client, d) => {
|
|
|
397
420
|
const data = d;
|
|
398
421
|
const guild = client.guilds.get(data.guild_id);
|
|
399
422
|
if (guild) {
|
|
400
|
-
const { Role: Role2 } = await import("./Role-
|
|
423
|
+
const { Role: Role2 } = await import("./Role-5MWSGL66.mjs");
|
|
401
424
|
guild.roles.set(data.role.id, new Role2(client, data.role, guild.id));
|
|
402
425
|
}
|
|
403
426
|
client.emit(Events.GuildRoleUpdate, data);
|
|
@@ -450,11 +473,23 @@ handlers.set("RESUMED", async (client) => {
|
|
|
450
473
|
var eventHandlers = handlers;
|
|
451
474
|
|
|
452
475
|
// src/client/Client.ts
|
|
476
|
+
function createEventMethods(client) {
|
|
477
|
+
const result = {};
|
|
478
|
+
for (const key of Object.keys(Events)) {
|
|
479
|
+
const eventName = Events[key];
|
|
480
|
+
result[key] = (cb) => {
|
|
481
|
+
client.on(eventName, cb);
|
|
482
|
+
return client;
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
return result;
|
|
486
|
+
}
|
|
453
487
|
var Client = class extends EventEmitter {
|
|
454
488
|
/** @param options - Token, REST config, WebSocket, presence, etc. */
|
|
455
489
|
constructor(options = {}) {
|
|
456
490
|
super();
|
|
457
491
|
this.options = options;
|
|
492
|
+
this.events = createEventMethods(this);
|
|
458
493
|
Object.defineProperty(this.channels, "cache", {
|
|
459
494
|
get: () => this.channels,
|
|
460
495
|
configurable: true
|
|
@@ -473,7 +508,11 @@ var Client = class extends EventEmitter {
|
|
|
473
508
|
guilds = new GuildManager(this);
|
|
474
509
|
channels = new ChannelManager(this);
|
|
475
510
|
users = new Collection3();
|
|
511
|
+
/** Typed event handlers. Use client.events.MessageReactionAdd((reaction, user, messageId, channelId, emoji, userId) => {...}) or client.on(Events.MessageReactionAdd, ...). */
|
|
512
|
+
events;
|
|
513
|
+
/** The authenticated bot user. Null until READY is received. */
|
|
476
514
|
user = null;
|
|
515
|
+
/** Timestamp when the client became ready. Null until READY is received. */
|
|
477
516
|
readyAt = null;
|
|
478
517
|
_ws = null;
|
|
479
518
|
/**
|
|
@@ -488,9 +527,12 @@ var Client = class extends EventEmitter {
|
|
|
488
527
|
if (typeof emoji === "object" && emoji.id) {
|
|
489
528
|
return formatEmoji({ name: emoji.name, id: emoji.id, animated: emoji.animated });
|
|
490
529
|
}
|
|
491
|
-
const parsed = parseEmoji(
|
|
530
|
+
const parsed = parseEmoji(
|
|
531
|
+
typeof emoji === "string" ? emoji : emoji.id ? `:${emoji.name}:` : emoji.name
|
|
532
|
+
);
|
|
492
533
|
if (!parsed) throw new Error("Invalid emoji");
|
|
493
534
|
if (parsed.id) return formatEmoji(parsed);
|
|
535
|
+
if (!/^\w+$/.test(parsed.name)) return encodeURIComponent(parsed.name);
|
|
494
536
|
if (guildId) {
|
|
495
537
|
const emojis = await this.rest.get(Routes3.guildEmojis(guildId));
|
|
496
538
|
const list = Array.isArray(emojis) ? emojis : Object.values(emojis ?? {});
|
|
@@ -511,13 +553,18 @@ var Client = class extends EventEmitter {
|
|
|
511
553
|
* Fetch a message by channel and message ID. Use when you have IDs (e.g. from a DB).
|
|
512
554
|
* @param channelId - Snowflake of the channel
|
|
513
555
|
* @param messageId - Snowflake of the message
|
|
514
|
-
* @returns The message
|
|
556
|
+
* @returns The message
|
|
557
|
+
* @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
|
|
515
558
|
* @deprecated Use channel.messages.fetch(messageId). For IDs-only: (await client.channels.fetch(channelId))?.messages?.fetch(messageId)
|
|
516
559
|
* @example
|
|
517
560
|
* const channel = await client.channels.fetch(channelId);
|
|
518
561
|
* const message = await channel?.messages?.fetch(messageId);
|
|
519
562
|
*/
|
|
520
563
|
async fetchMessage(channelId, messageId) {
|
|
564
|
+
emitDeprecationWarning2(
|
|
565
|
+
"Client.fetchMessage()",
|
|
566
|
+
"Use channel.messages.fetch(messageId). For IDs-only: (await client.channels.fetch(channelId))?.messages?.fetch(messageId)"
|
|
567
|
+
);
|
|
521
568
|
return this.channels.fetchMessage(channelId, messageId);
|
|
522
569
|
}
|
|
523
570
|
/**
|
|
@@ -570,7 +617,9 @@ var Client = class extends EventEmitter {
|
|
|
570
617
|
*/
|
|
571
618
|
async login(token) {
|
|
572
619
|
if (this._ws) {
|
|
573
|
-
throw new FluxerError("Client is already logged in. Call destroy() first."
|
|
620
|
+
throw new FluxerError("Client is already logged in. Call destroy() first.", {
|
|
621
|
+
code: ErrorCodes.AlreadyLoggedIn
|
|
622
|
+
});
|
|
574
623
|
}
|
|
575
624
|
this.rest.setToken(token);
|
|
576
625
|
let intents = this.options.intents ?? 0;
|
|
@@ -602,12 +651,16 @@ var Client = class extends EventEmitter {
|
|
|
602
651
|
async ({
|
|
603
652
|
data
|
|
604
653
|
}) => {
|
|
605
|
-
const { ClientUser: ClientUser2 } = await import("./ClientUser-
|
|
606
|
-
const { Guild: Guild2 } = await import("./Guild-
|
|
607
|
-
const { Channel: Channel2 } = await import("./Channel-
|
|
654
|
+
const { ClientUser: ClientUser2 } = await import("./ClientUser-PXAAKR2P.mjs");
|
|
655
|
+
const { Guild: Guild2 } = await import("./Guild-FMBCTAV4.mjs");
|
|
656
|
+
const { Channel: Channel2 } = await import("./Channel-4WVFDOCG.mjs");
|
|
608
657
|
this.user = new ClientUser2(this, data.user);
|
|
609
658
|
for (const g of data.guilds ?? []) {
|
|
610
|
-
const
|
|
659
|
+
const guildData = g && typeof g === "object" && "properties" in g && g.properties ? {
|
|
660
|
+
...g.properties,
|
|
661
|
+
roles: g.roles
|
|
662
|
+
} : g;
|
|
663
|
+
const guild = new Guild2(this, guildData);
|
|
611
664
|
this.guilds.set(guild.id, guild);
|
|
612
665
|
const withCh = g;
|
|
613
666
|
for (const ch of withCh.channels ?? []) {
|
|
@@ -746,15 +799,14 @@ var GuildSticker = class extends Base {
|
|
|
746
799
|
}
|
|
747
800
|
};
|
|
748
801
|
|
|
749
|
-
// src/errors/ErrorCodes.ts
|
|
750
|
-
var ErrorCodes = {
|
|
751
|
-
ClientNotReady: "CLIENT_NOT_READY",
|
|
752
|
-
InvalidToken: "INVALID_TOKEN"
|
|
753
|
-
};
|
|
754
|
-
|
|
755
802
|
// src/index.ts
|
|
756
803
|
import { EmbedBuilder, MessagePayload, AttachmentBuilder } from "@fluxerjs/builders";
|
|
757
|
-
import { Routes as Routes6, GatewayOpcodes } from "@fluxerjs/types";
|
|
804
|
+
import { Routes as Routes6, GatewayOpcodes, MessageAttachmentFlags } from "@fluxerjs/types";
|
|
805
|
+
import { resolveTenorToImageUrl } from "@fluxerjs/util";
|
|
806
|
+
import {
|
|
807
|
+
PermissionsBitField,
|
|
808
|
+
PermissionFlags
|
|
809
|
+
} from "@fluxerjs/util";
|
|
758
810
|
export {
|
|
759
811
|
AttachmentBuilder,
|
|
760
812
|
Base,
|
|
@@ -778,13 +830,25 @@ export {
|
|
|
778
830
|
Invite,
|
|
779
831
|
LinkChannel,
|
|
780
832
|
Message,
|
|
833
|
+
MessageAttachmentFlags,
|
|
834
|
+
MessageCollector,
|
|
781
835
|
MessageManager,
|
|
782
836
|
MessagePayload,
|
|
783
837
|
MessageReaction,
|
|
838
|
+
PermissionFlags,
|
|
839
|
+
PermissionsBitField,
|
|
840
|
+
ReactionCollector,
|
|
784
841
|
Role,
|
|
785
842
|
Routes6 as Routes,
|
|
786
843
|
TextChannel,
|
|
787
844
|
User,
|
|
788
845
|
VoiceChannel,
|
|
789
|
-
Webhook
|
|
846
|
+
Webhook,
|
|
847
|
+
cdnAvatarURL,
|
|
848
|
+
cdnBannerURL,
|
|
849
|
+
cdnDefaultAvatarURL,
|
|
850
|
+
cdnDisplayAvatarURL,
|
|
851
|
+
cdnMemberAvatarURL,
|
|
852
|
+
cdnMemberBannerURL,
|
|
853
|
+
resolveTenorToImageUrl
|
|
790
854
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.1.1",
|
|
7
7
|
"description": "A fully-featured SDK for Fluxer bots",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"bot",
|
|
20
20
|
"api"
|
|
21
21
|
],
|
|
22
|
-
"license": "
|
|
22
|
+
"license": "Apache-2.0",
|
|
23
23
|
"main": "./dist/index.js",
|
|
24
24
|
"module": "./dist/index.mjs",
|
|
25
25
|
"types": "./dist/index.d.ts",
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
"dist"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@fluxerjs/rest": "1.
|
|
38
|
-
"@fluxerjs/
|
|
39
|
-
"@fluxerjs/
|
|
40
|
-
"@fluxerjs/
|
|
41
|
-
"@fluxerjs/
|
|
42
|
-
"@fluxerjs/
|
|
37
|
+
"@fluxerjs/rest": "1.1.1",
|
|
38
|
+
"@fluxerjs/ws": "1.1.1",
|
|
39
|
+
"@fluxerjs/collection": "1.1.1",
|
|
40
|
+
"@fluxerjs/builders": "1.1.1",
|
|
41
|
+
"@fluxerjs/util": "1.1.1",
|
|
42
|
+
"@fluxerjs/types": "1.1.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/node": "^20.0.0",
|
package/dist/Guild-TM6YGJWB.mjs
DELETED