@fluxerjs/core 1.0.8 → 1.1.0
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-TWPDKW2P.mjs → Channel-WJZZSNML.mjs} +3 -1
- package/dist/{ClientUser-2K2BACK7.mjs → ClientUser-DJO2FS7P.mjs} +1 -1
- package/dist/Guild-2P77HBQM.mjs +11 -0
- package/dist/GuildBan-7CXLTPKY.mjs +7 -0
- package/dist/GuildMember-43B5E5CH.mjs +9 -0
- package/dist/{Message-G2QIKZQK.mjs → Invite-UM5BU5A6.mjs} +3 -3
- package/dist/Message-OFIVTTAZ.mjs +9 -0
- package/dist/{MessageReaction-XRPYZDSC.mjs → MessageReaction-V4UZ7OXE.mjs} +1 -1
- package/dist/{Role-SVLWIAMN.mjs → Role-5MWSGL66.mjs} +1 -1
- package/dist/Webhook-RWDDYW2Q.mjs +10 -0
- package/dist/chunk-4XJIM6SC.mjs +315 -0
- package/dist/chunk-AH7KYH2Z.mjs +50 -0
- package/dist/{chunk-HBF5QEDH.mjs → chunk-CEABHTAF.mjs} +1 -0
- package/dist/chunk-CJVQNARM.mjs +145 -0
- package/dist/chunk-DQ4TNBPG.mjs +63 -0
- package/dist/chunk-DUQAD7F6.mjs +173 -0
- package/dist/{chunk-4GCZFOS5.mjs → chunk-JHNKZIHY.mjs} +54 -3
- package/dist/chunk-LU2SNC5G.mjs +392 -0
- package/dist/chunk-PM2IUGNR.mjs +29 -0
- package/dist/chunk-QEXIYXXU.mjs +62 -0
- package/dist/chunk-UXIF75BV.mjs +36 -0
- package/dist/chunk-V7LPVPGH.mjs +305 -0
- package/dist/chunk-X6K3ZD62.mjs +53 -0
- package/dist/index.d.mts +802 -160
- package/dist/index.d.ts +802 -160
- package/dist/index.js +1467 -262
- package/dist/index.mjs +292 -119
- package/package.json +7 -7
- package/dist/Guild-CMZGA6DW.mjs +0 -10
- package/dist/GuildMember-DW2N6ITI.mjs +0 -7
- package/dist/Webhook-2MQESB7Z.mjs +0 -7
- package/dist/chunk-CO5EL5LH.mjs +0 -168
- package/dist/chunk-CZIO2D7F.mjs +0 -207
- package/dist/chunk-JVEOQFUX.mjs +0 -52
- package/dist/chunk-SQVCCSNN.mjs +0 -41
- package/dist/chunk-TJVZEILY.mjs +0 -120
- package/dist/chunk-ZGMM6IPQ.mjs +0 -79
package/dist/index.mjs
CHANGED
|
@@ -1,36 +1,62 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ErrorCodes,
|
|
3
|
+
FluxerError,
|
|
4
|
+
Guild
|
|
5
|
+
} from "./chunk-4XJIM6SC.mjs";
|
|
6
|
+
import {
|
|
7
|
+
MessageReaction
|
|
8
|
+
} from "./chunk-CEABHTAF.mjs";
|
|
1
9
|
import {
|
|
2
10
|
ClientUser,
|
|
3
11
|
User
|
|
4
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-JHNKZIHY.mjs";
|
|
13
|
+
import {
|
|
14
|
+
Message,
|
|
15
|
+
ReactionCollector
|
|
16
|
+
} from "./chunk-V7LPVPGH.mjs";
|
|
5
17
|
import {
|
|
6
18
|
Webhook
|
|
7
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-CJVQNARM.mjs";
|
|
8
20
|
import {
|
|
9
|
-
|
|
10
|
-
} from "./chunk-
|
|
21
|
+
Invite
|
|
22
|
+
} from "./chunk-QEXIYXXU.mjs";
|
|
11
23
|
import {
|
|
12
24
|
CategoryChannel,
|
|
13
25
|
Channel,
|
|
14
26
|
DMChannel,
|
|
15
27
|
GuildChannel,
|
|
16
28
|
LinkChannel,
|
|
29
|
+
MessageCollector,
|
|
17
30
|
MessageManager,
|
|
18
31
|
TextChannel,
|
|
19
32
|
VoiceChannel
|
|
20
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-LU2SNC5G.mjs";
|
|
21
34
|
import {
|
|
22
|
-
|
|
23
|
-
} from "./chunk-
|
|
24
|
-
import
|
|
35
|
+
Events
|
|
36
|
+
} from "./chunk-AH7KYH2Z.mjs";
|
|
37
|
+
import {
|
|
38
|
+
buildSendBody
|
|
39
|
+
} from "./chunk-PM2IUGNR.mjs";
|
|
25
40
|
import {
|
|
26
41
|
GuildMember
|
|
27
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-DUQAD7F6.mjs";
|
|
43
|
+
import {
|
|
44
|
+
cdnAvatarURL,
|
|
45
|
+
cdnBannerURL,
|
|
46
|
+
cdnDefaultAvatarURL,
|
|
47
|
+
cdnDisplayAvatarURL,
|
|
48
|
+
cdnMemberAvatarURL,
|
|
49
|
+
cdnMemberBannerURL
|
|
50
|
+
} from "./chunk-X6K3ZD62.mjs";
|
|
51
|
+
import {
|
|
52
|
+
CDN_URL
|
|
53
|
+
} from "./chunk-HQMYRYMY.mjs";
|
|
28
54
|
import {
|
|
29
55
|
Role
|
|
30
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-DQ4TNBPG.mjs";
|
|
31
57
|
import {
|
|
32
|
-
|
|
33
|
-
} from "./chunk-
|
|
58
|
+
GuildBan
|
|
59
|
+
} from "./chunk-UXIF75BV.mjs";
|
|
34
60
|
import {
|
|
35
61
|
Base
|
|
36
62
|
} from "./chunk-XNS4O6QJ.mjs";
|
|
@@ -45,6 +71,8 @@ import { Collection as Collection3 } from "@fluxerjs/collection";
|
|
|
45
71
|
// src/client/ChannelManager.ts
|
|
46
72
|
import { Collection } from "@fluxerjs/collection";
|
|
47
73
|
import { Routes } from "@fluxerjs/types";
|
|
74
|
+
import { emitDeprecationWarning } from "@fluxerjs/util";
|
|
75
|
+
import { FluxerAPIError, RateLimitError } from "@fluxerjs/rest";
|
|
48
76
|
var ChannelManager = class extends Collection {
|
|
49
77
|
constructor(client) {
|
|
50
78
|
super();
|
|
@@ -53,7 +81,8 @@ var ChannelManager = class extends Collection {
|
|
|
53
81
|
/**
|
|
54
82
|
* Fetch a channel by ID from the API (or return from cache if present).
|
|
55
83
|
* @param channelId - Snowflake of the channel
|
|
56
|
-
* @returns The channel
|
|
84
|
+
* @returns The channel
|
|
85
|
+
* @throws FluxerError with CHANNEL_NOT_FOUND if the channel does not exist
|
|
57
86
|
* @example
|
|
58
87
|
* const channel = await client.channels.fetch(channelId);
|
|
59
88
|
* if (channel?.isSendable()) await channel.send('Hello!');
|
|
@@ -62,52 +91,79 @@ var ChannelManager = class extends Collection {
|
|
|
62
91
|
const cached = this.get(channelId);
|
|
63
92
|
if (cached) return cached;
|
|
64
93
|
try {
|
|
65
|
-
const { Channel: Channel2 } = await import("./Channel-
|
|
94
|
+
const { Channel: Channel2 } = await import("./Channel-WJZZSNML.mjs");
|
|
66
95
|
const data = await this.client.rest.get(
|
|
67
96
|
Routes.channel(channelId)
|
|
68
97
|
);
|
|
69
98
|
const channel = Channel2.fromOrCreate(this.client, data);
|
|
70
|
-
if (channel)
|
|
99
|
+
if (!channel) {
|
|
100
|
+
throw new FluxerError("Channel data invalid or unsupported type", {
|
|
101
|
+
code: ErrorCodes.ChannelNotFound
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
this.set(channel.id, channel);
|
|
71
105
|
return channel;
|
|
72
|
-
} catch {
|
|
73
|
-
|
|
106
|
+
} catch (err) {
|
|
107
|
+
if (err instanceof RateLimitError) throw err;
|
|
108
|
+
if (err instanceof FluxerAPIError && err.statusCode === 404) {
|
|
109
|
+
throw new FluxerError(`Channel ${channelId} not found`, {
|
|
110
|
+
code: ErrorCodes.ChannelNotFound,
|
|
111
|
+
cause: err
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
|
|
74
115
|
}
|
|
75
116
|
}
|
|
76
117
|
/**
|
|
77
118
|
* Fetch a message by ID from the API.
|
|
78
119
|
* @param channelId - Snowflake of the channel
|
|
79
120
|
* @param messageId - Snowflake of the message
|
|
80
|
-
* @returns The message
|
|
121
|
+
* @returns The message
|
|
122
|
+
* @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
|
|
81
123
|
* @deprecated Use channel.messages.fetch(messageId). Prefer (await client.channels.fetch(channelId))?.messages?.fetch(messageId).
|
|
82
124
|
* @example
|
|
83
125
|
* const channel = await client.channels.fetch(channelId);
|
|
84
126
|
* const message = await channel?.messages?.fetch(messageId);
|
|
85
127
|
*/
|
|
86
128
|
async fetchMessage(channelId, messageId) {
|
|
129
|
+
emitDeprecationWarning(
|
|
130
|
+
"ChannelManager.fetchMessage()",
|
|
131
|
+
"Use channel.messages.fetch(messageId). Prefer (await client.channels.fetch(channelId))?.messages?.fetch(messageId)."
|
|
132
|
+
);
|
|
87
133
|
try {
|
|
88
|
-
const { Message: Message2 } = await import("./Message-
|
|
134
|
+
const { Message: Message2 } = await import("./Message-OFIVTTAZ.mjs");
|
|
89
135
|
const data = await this.client.rest.get(
|
|
90
136
|
Routes.channelMessage(channelId, messageId)
|
|
91
137
|
);
|
|
92
138
|
return new Message2(this.client, data);
|
|
93
|
-
} catch {
|
|
94
|
-
|
|
139
|
+
} catch (err) {
|
|
140
|
+
if (err instanceof RateLimitError) throw err;
|
|
141
|
+
if (err instanceof FluxerAPIError && err.statusCode === 404) {
|
|
142
|
+
throw new FluxerError(`Message ${messageId} not found in channel ${channelId}`, {
|
|
143
|
+
code: ErrorCodes.MessageNotFound,
|
|
144
|
+
cause: err
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
|
|
95
148
|
}
|
|
96
149
|
}
|
|
97
150
|
/**
|
|
98
151
|
* Send a message to a channel by ID. Works even when the channel is not cached.
|
|
99
152
|
* Skips the fetch when you only need to send.
|
|
100
153
|
* @param channelId - Snowflake of the channel (text channel or DM)
|
|
101
|
-
* @param payload - Text content or object with content and/or
|
|
154
|
+
* @param payload - Text content or object with content, embeds, and/or files
|
|
102
155
|
* @returns The created message
|
|
103
156
|
* @example
|
|
104
157
|
* await client.channels.send(logChannelId, 'User joined!');
|
|
105
158
|
* await client.channels.send(channelId, { embeds: [embed.toJSON()] });
|
|
159
|
+
* await client.channels.send(channelId, { content: 'Report', files: [{ name: 'log.txt', data }] });
|
|
106
160
|
*/
|
|
107
161
|
async send(channelId, payload) {
|
|
108
|
-
const
|
|
109
|
-
const
|
|
110
|
-
const
|
|
162
|
+
const opts = typeof payload === "string" ? { content: payload } : payload;
|
|
163
|
+
const body = buildSendBody(payload);
|
|
164
|
+
const { Message: Message2 } = await import("./Message-OFIVTTAZ.mjs");
|
|
165
|
+
const postOptions = opts.files?.length ? { body, files: opts.files } : { body };
|
|
166
|
+
const data = await this.client.rest.post(Routes.channelMessages(channelId), postOptions);
|
|
111
167
|
return new Message2(this.client, data);
|
|
112
168
|
}
|
|
113
169
|
};
|
|
@@ -132,7 +188,7 @@ var GuildManager = class extends Collection2 {
|
|
|
132
188
|
const cached = this.get(guildId);
|
|
133
189
|
if (cached) return cached;
|
|
134
190
|
try {
|
|
135
|
-
const { Guild: Guild2 } = await import("./Guild-
|
|
191
|
+
const { Guild: Guild2 } = await import("./Guild-2P77HBQM.mjs");
|
|
136
192
|
const data = await this.client.rest.get(
|
|
137
193
|
Routes2.guild(guildId)
|
|
138
194
|
);
|
|
@@ -145,73 +201,27 @@ var GuildManager = class extends Collection2 {
|
|
|
145
201
|
}
|
|
146
202
|
};
|
|
147
203
|
|
|
148
|
-
// src/errors/FluxerError.ts
|
|
149
|
-
var FluxerError = class _FluxerError extends Error {
|
|
150
|
-
constructor(message) {
|
|
151
|
-
super(message);
|
|
152
|
-
this.name = "FluxerError";
|
|
153
|
-
Object.setPrototypeOf(this, _FluxerError.prototype);
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
// src/util/Events.ts
|
|
158
|
-
var Events = {
|
|
159
|
-
Ready: "ready",
|
|
160
|
-
MessageCreate: "messageCreate",
|
|
161
|
-
MessageUpdate: "messageUpdate",
|
|
162
|
-
MessageDelete: "messageDelete",
|
|
163
|
-
MessageDeleteBulk: "messageDeleteBulk",
|
|
164
|
-
MessageReactionAdd: "messageReactionAdd",
|
|
165
|
-
MessageReactionRemove: "messageReactionRemove",
|
|
166
|
-
MessageReactionRemoveAll: "messageReactionRemoveAll",
|
|
167
|
-
MessageReactionRemoveEmoji: "messageReactionRemoveEmoji",
|
|
168
|
-
InteractionCreate: "interactionCreate",
|
|
169
|
-
GuildCreate: "guildCreate",
|
|
170
|
-
GuildUpdate: "guildUpdate",
|
|
171
|
-
GuildDelete: "guildDelete",
|
|
172
|
-
GuildBanAdd: "guildBanAdd",
|
|
173
|
-
GuildBanRemove: "guildBanRemove",
|
|
174
|
-
GuildEmojisUpdate: "guildEmojisUpdate",
|
|
175
|
-
GuildStickersUpdate: "guildStickersUpdate",
|
|
176
|
-
GuildIntegrationsUpdate: "guildIntegrationsUpdate",
|
|
177
|
-
GuildMemberAdd: "guildMemberAdd",
|
|
178
|
-
GuildMemberUpdate: "guildMemberUpdate",
|
|
179
|
-
GuildMemberRemove: "guildMemberRemove",
|
|
180
|
-
GuildRoleCreate: "guildRoleCreate",
|
|
181
|
-
GuildRoleUpdate: "guildRoleUpdate",
|
|
182
|
-
GuildRoleDelete: "guildRoleDelete",
|
|
183
|
-
GuildScheduledEventCreate: "guildScheduledEventCreate",
|
|
184
|
-
GuildScheduledEventUpdate: "guildScheduledEventUpdate",
|
|
185
|
-
GuildScheduledEventDelete: "guildScheduledEventDelete",
|
|
186
|
-
ChannelCreate: "channelCreate",
|
|
187
|
-
ChannelUpdate: "channelUpdate",
|
|
188
|
-
ChannelDelete: "channelDelete",
|
|
189
|
-
ChannelPinsUpdate: "channelPinsUpdate",
|
|
190
|
-
InviteCreate: "inviteCreate",
|
|
191
|
-
InviteDelete: "inviteDelete",
|
|
192
|
-
TypingStart: "typingStart",
|
|
193
|
-
UserUpdate: "userUpdate",
|
|
194
|
-
PresenceUpdate: "presenceUpdate",
|
|
195
|
-
VoiceStateUpdate: "voiceStateUpdate",
|
|
196
|
-
VoiceServerUpdate: "voiceServerUpdate",
|
|
197
|
-
VoiceStatesSync: "voiceStatesSync",
|
|
198
|
-
WebhooksUpdate: "webhooksUpdate",
|
|
199
|
-
Resumed: "resumed",
|
|
200
|
-
Error: "error",
|
|
201
|
-
Debug: "debug"
|
|
202
|
-
};
|
|
203
|
-
|
|
204
204
|
// src/client/Client.ts
|
|
205
|
-
import { formatEmoji, parseEmoji } from "@fluxerjs/util";
|
|
205
|
+
import { emitDeprecationWarning as emitDeprecationWarning2, formatEmoji, parseEmoji } from "@fluxerjs/util";
|
|
206
206
|
|
|
207
207
|
// src/client/EventHandlerRegistry.ts
|
|
208
208
|
var handlers = /* @__PURE__ */ new Map();
|
|
209
209
|
handlers.set("MESSAGE_CREATE", async (client, d) => {
|
|
210
|
-
const { Message: Message2 } = await import("./Message-
|
|
211
|
-
|
|
210
|
+
const { Message: Message2 } = await import("./Message-OFIVTTAZ.mjs");
|
|
211
|
+
const { GuildMember: GuildMember2 } = await import("./GuildMember-43B5E5CH.mjs");
|
|
212
|
+
const data = d;
|
|
213
|
+
if (data.guild_id && data.member && data.author) {
|
|
214
|
+
const guild = client.guilds.get(data.guild_id);
|
|
215
|
+
if (guild) {
|
|
216
|
+
const memberData = { ...data.member, user: data.author, guild_id: data.guild_id };
|
|
217
|
+
const member = new GuildMember2(client, memberData, guild);
|
|
218
|
+
guild.members.set(member.id, member);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
client.emit(Events.MessageCreate, new Message2(client, data));
|
|
212
222
|
});
|
|
213
223
|
handlers.set("MESSAGE_UPDATE", async (client, d) => {
|
|
214
|
-
const { Message: Message2 } = await import("./Message-
|
|
224
|
+
const { Message: Message2 } = await import("./Message-OFIVTTAZ.mjs");
|
|
215
225
|
client.emit(Events.MessageUpdate, null, new Message2(client, d));
|
|
216
226
|
});
|
|
217
227
|
handlers.set("MESSAGE_DELETE", async (client, d) => {
|
|
@@ -225,25 +235,41 @@ handlers.set("MESSAGE_DELETE", async (client, d) => {
|
|
|
225
235
|
});
|
|
226
236
|
handlers.set("MESSAGE_REACTION_ADD", async (client, d) => {
|
|
227
237
|
const data = d;
|
|
228
|
-
const { MessageReaction: MessageReaction2 } = await import("./MessageReaction-
|
|
238
|
+
const { MessageReaction: MessageReaction2 } = await import("./MessageReaction-V4UZ7OXE.mjs");
|
|
229
239
|
const reaction = new MessageReaction2(client, data);
|
|
230
240
|
const user = client.getOrCreateUser({
|
|
231
241
|
id: data.user_id,
|
|
232
242
|
username: "Unknown",
|
|
233
243
|
discriminator: "0"
|
|
234
244
|
});
|
|
235
|
-
client.emit(
|
|
245
|
+
client.emit(
|
|
246
|
+
Events.MessageReactionAdd,
|
|
247
|
+
reaction,
|
|
248
|
+
user,
|
|
249
|
+
reaction.messageId,
|
|
250
|
+
reaction.channelId,
|
|
251
|
+
reaction.emoji,
|
|
252
|
+
user.id
|
|
253
|
+
);
|
|
236
254
|
});
|
|
237
255
|
handlers.set("MESSAGE_REACTION_REMOVE", async (client, d) => {
|
|
238
256
|
const data = d;
|
|
239
|
-
const { MessageReaction: MessageReaction2 } = await import("./MessageReaction-
|
|
257
|
+
const { MessageReaction: MessageReaction2 } = await import("./MessageReaction-V4UZ7OXE.mjs");
|
|
240
258
|
const reaction = new MessageReaction2(client, data);
|
|
241
259
|
const user = client.getOrCreateUser({
|
|
242
260
|
id: data.user_id,
|
|
243
261
|
username: "Unknown",
|
|
244
262
|
discriminator: "0"
|
|
245
263
|
});
|
|
246
|
-
client.emit(
|
|
264
|
+
client.emit(
|
|
265
|
+
Events.MessageReactionRemove,
|
|
266
|
+
reaction,
|
|
267
|
+
user,
|
|
268
|
+
reaction.messageId,
|
|
269
|
+
reaction.channelId,
|
|
270
|
+
reaction.emoji,
|
|
271
|
+
user.id
|
|
272
|
+
);
|
|
247
273
|
});
|
|
248
274
|
handlers.set("MESSAGE_REACTION_REMOVE_ALL", async (client, d) => {
|
|
249
275
|
client.emit(Events.MessageReactionRemoveAll, d);
|
|
@@ -255,9 +281,11 @@ handlers.set("MESSAGE_REACTION_REMOVE_EMOJI", async (client, d) => {
|
|
|
255
281
|
);
|
|
256
282
|
});
|
|
257
283
|
handlers.set("GUILD_CREATE", async (client, d) => {
|
|
258
|
-
const { Guild: Guild2 } = await import("./Guild-
|
|
259
|
-
const { Channel: Channel2 } = await import("./Channel-
|
|
260
|
-
const
|
|
284
|
+
const { Guild: Guild2 } = await import("./Guild-2P77HBQM.mjs");
|
|
285
|
+
const { Channel: Channel2 } = await import("./Channel-WJZZSNML.mjs");
|
|
286
|
+
const raw = d;
|
|
287
|
+
const guildData = raw?.properties != null ? { ...raw.properties, roles: raw.roles } : raw;
|
|
288
|
+
const guild = new Guild2(client, guildData);
|
|
261
289
|
client.guilds.set(guild.id, guild);
|
|
262
290
|
const g = d;
|
|
263
291
|
for (const ch of g.channels ?? []) {
|
|
@@ -270,10 +298,11 @@ handlers.set("GUILD_CREATE", async (client, d) => {
|
|
|
270
298
|
}
|
|
271
299
|
});
|
|
272
300
|
handlers.set("GUILD_UPDATE", async (client, d) => {
|
|
273
|
-
const { Guild: Guild2 } = await import("./Guild-
|
|
274
|
-
const
|
|
275
|
-
const
|
|
276
|
-
const
|
|
301
|
+
const { Guild: Guild2 } = await import("./Guild-2P77HBQM.mjs");
|
|
302
|
+
const raw = d;
|
|
303
|
+
const guildData = raw?.properties != null ? { ...raw.properties, roles: raw.roles } : raw;
|
|
304
|
+
const old = client.guilds.get(guildData.id);
|
|
305
|
+
const updated = new Guild2(client, guildData);
|
|
277
306
|
client.guilds.set(updated.id, updated);
|
|
278
307
|
client.emit(Events.GuildUpdate, old ?? updated, updated);
|
|
279
308
|
});
|
|
@@ -286,7 +315,7 @@ handlers.set("GUILD_DELETE", async (client, d) => {
|
|
|
286
315
|
}
|
|
287
316
|
});
|
|
288
317
|
handlers.set("CHANNEL_CREATE", async (client, d) => {
|
|
289
|
-
const { Channel: Channel2 } = await import("./Channel-
|
|
318
|
+
const { Channel: Channel2 } = await import("./Channel-WJZZSNML.mjs");
|
|
290
319
|
const ch = Channel2.from(client, d);
|
|
291
320
|
if (ch) {
|
|
292
321
|
client.channels.set(ch.id, ch);
|
|
@@ -294,7 +323,7 @@ handlers.set("CHANNEL_CREATE", async (client, d) => {
|
|
|
294
323
|
}
|
|
295
324
|
});
|
|
296
325
|
handlers.set("CHANNEL_UPDATE", async (client, d) => {
|
|
297
|
-
const { Channel: Channel2 } = await import("./Channel-
|
|
326
|
+
const { Channel: Channel2 } = await import("./Channel-WJZZSNML.mjs");
|
|
298
327
|
const ch = d;
|
|
299
328
|
const oldCh = client.channels.get(ch.id);
|
|
300
329
|
const newCh = Channel2.from(client, ch);
|
|
@@ -312,7 +341,7 @@ handlers.set("CHANNEL_DELETE", async (client, d) => {
|
|
|
312
341
|
}
|
|
313
342
|
});
|
|
314
343
|
handlers.set("GUILD_MEMBER_ADD", async (client, d) => {
|
|
315
|
-
const { GuildMember: GuildMember2 } = await import("./GuildMember-
|
|
344
|
+
const { GuildMember: GuildMember2 } = await import("./GuildMember-43B5E5CH.mjs");
|
|
316
345
|
const data = d;
|
|
317
346
|
const guild = client.guilds.get(data.guild_id);
|
|
318
347
|
if (guild) {
|
|
@@ -322,7 +351,7 @@ handlers.set("GUILD_MEMBER_ADD", async (client, d) => {
|
|
|
322
351
|
}
|
|
323
352
|
});
|
|
324
353
|
handlers.set("GUILD_MEMBER_UPDATE", async (client, d) => {
|
|
325
|
-
const { GuildMember: GuildMember2 } = await import("./GuildMember-
|
|
354
|
+
const { GuildMember: GuildMember2 } = await import("./GuildMember-43B5E5CH.mjs");
|
|
326
355
|
const data = d;
|
|
327
356
|
const guild = client.guilds.get(data.guild_id);
|
|
328
357
|
if (guild) {
|
|
@@ -356,10 +385,16 @@ handlers.set("MESSAGE_DELETE_BULK", async (client, d) => {
|
|
|
356
385
|
client.emit(Events.MessageDeleteBulk, d);
|
|
357
386
|
});
|
|
358
387
|
handlers.set("GUILD_BAN_ADD", async (client, d) => {
|
|
359
|
-
|
|
388
|
+
const data = d;
|
|
389
|
+
const { GuildBan: GuildBan2 } = await import("./GuildBan-7CXLTPKY.mjs");
|
|
390
|
+
const ban = new GuildBan2(client, data, data.guild_id);
|
|
391
|
+
client.emit(Events.GuildBanAdd, ban);
|
|
360
392
|
});
|
|
361
393
|
handlers.set("GUILD_BAN_REMOVE", async (client, d) => {
|
|
362
|
-
|
|
394
|
+
const data = d;
|
|
395
|
+
const { GuildBan: GuildBan2 } = await import("./GuildBan-7CXLTPKY.mjs");
|
|
396
|
+
const ban = new GuildBan2(client, { ...data, reason: null }, data.guild_id);
|
|
397
|
+
client.emit(Events.GuildBanRemove, ban);
|
|
363
398
|
});
|
|
364
399
|
handlers.set("GUILD_EMOJIS_UPDATE", async (client, d) => {
|
|
365
400
|
client.emit(Events.GuildEmojisUpdate, d);
|
|
@@ -374,7 +409,7 @@ handlers.set("GUILD_ROLE_CREATE", async (client, d) => {
|
|
|
374
409
|
const data = d;
|
|
375
410
|
const guild = client.guilds.get(data.guild_id);
|
|
376
411
|
if (guild) {
|
|
377
|
-
const { Role: Role2 } = await import("./Role-
|
|
412
|
+
const { Role: Role2 } = await import("./Role-5MWSGL66.mjs");
|
|
378
413
|
guild.roles.set(data.role.id, new Role2(client, data.role, guild.id));
|
|
379
414
|
}
|
|
380
415
|
client.emit(Events.GuildRoleCreate, data);
|
|
@@ -383,7 +418,7 @@ handlers.set("GUILD_ROLE_UPDATE", async (client, d) => {
|
|
|
383
418
|
const data = d;
|
|
384
419
|
const guild = client.guilds.get(data.guild_id);
|
|
385
420
|
if (guild) {
|
|
386
|
-
const { Role: Role2 } = await import("./Role-
|
|
421
|
+
const { Role: Role2 } = await import("./Role-5MWSGL66.mjs");
|
|
387
422
|
guild.roles.set(data.role.id, new Role2(client, data.role, guild.id));
|
|
388
423
|
}
|
|
389
424
|
client.emit(Events.GuildRoleUpdate, data);
|
|
@@ -407,7 +442,9 @@ handlers.set("CHANNEL_PINS_UPDATE", async (client, d) => {
|
|
|
407
442
|
client.emit(Events.ChannelPinsUpdate, d);
|
|
408
443
|
});
|
|
409
444
|
handlers.set("INVITE_CREATE", async (client, d) => {
|
|
410
|
-
|
|
445
|
+
const data = d;
|
|
446
|
+
const { Invite: Invite2 } = await import("./Invite-UM5BU5A6.mjs");
|
|
447
|
+
client.emit(Events.InviteCreate, new Invite2(client, data));
|
|
411
448
|
});
|
|
412
449
|
handlers.set("INVITE_DELETE", async (client, d) => {
|
|
413
450
|
client.emit(Events.InviteDelete, d);
|
|
@@ -434,11 +471,23 @@ handlers.set("RESUMED", async (client) => {
|
|
|
434
471
|
var eventHandlers = handlers;
|
|
435
472
|
|
|
436
473
|
// src/client/Client.ts
|
|
474
|
+
function createEventMethods(client) {
|
|
475
|
+
const result = {};
|
|
476
|
+
for (const key of Object.keys(Events)) {
|
|
477
|
+
const eventName = Events[key];
|
|
478
|
+
result[key] = (cb) => {
|
|
479
|
+
client.on(eventName, cb);
|
|
480
|
+
return client;
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
return result;
|
|
484
|
+
}
|
|
437
485
|
var Client = class extends EventEmitter {
|
|
438
486
|
/** @param options - Token, REST config, WebSocket, presence, etc. */
|
|
439
487
|
constructor(options = {}) {
|
|
440
488
|
super();
|
|
441
489
|
this.options = options;
|
|
490
|
+
this.events = createEventMethods(this);
|
|
442
491
|
Object.defineProperty(this.channels, "cache", {
|
|
443
492
|
get: () => this.channels,
|
|
444
493
|
configurable: true
|
|
@@ -457,7 +506,11 @@ var Client = class extends EventEmitter {
|
|
|
457
506
|
guilds = new GuildManager(this);
|
|
458
507
|
channels = new ChannelManager(this);
|
|
459
508
|
users = new Collection3();
|
|
509
|
+
/** Typed event handlers. Use client.events.MessageReactionAdd((reaction, user, messageId, channelId, emoji, userId) => {...}) or client.on(Events.MessageReactionAdd, ...). */
|
|
510
|
+
events;
|
|
511
|
+
/** The authenticated bot user. Null until READY is received. */
|
|
460
512
|
user = null;
|
|
513
|
+
/** Timestamp when the client became ready. Null until READY is received. */
|
|
461
514
|
readyAt = null;
|
|
462
515
|
_ws = null;
|
|
463
516
|
/**
|
|
@@ -495,13 +548,18 @@ var Client = class extends EventEmitter {
|
|
|
495
548
|
* Fetch a message by channel and message ID. Use when you have IDs (e.g. from a DB).
|
|
496
549
|
* @param channelId - Snowflake of the channel
|
|
497
550
|
* @param messageId - Snowflake of the message
|
|
498
|
-
* @returns The message
|
|
551
|
+
* @returns The message
|
|
552
|
+
* @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
|
|
499
553
|
* @deprecated Use channel.messages.fetch(messageId). For IDs-only: (await client.channels.fetch(channelId))?.messages?.fetch(messageId)
|
|
500
554
|
* @example
|
|
501
555
|
* const channel = await client.channels.fetch(channelId);
|
|
502
556
|
* const message = await channel?.messages?.fetch(messageId);
|
|
503
557
|
*/
|
|
504
558
|
async fetchMessage(channelId, messageId) {
|
|
559
|
+
emitDeprecationWarning2(
|
|
560
|
+
"Client.fetchMessage()",
|
|
561
|
+
"Use channel.messages.fetch(messageId). For IDs-only: (await client.channels.fetch(channelId))?.messages?.fetch(messageId)"
|
|
562
|
+
);
|
|
505
563
|
return this.channels.fetchMessage(channelId, messageId);
|
|
506
564
|
}
|
|
507
565
|
/**
|
|
@@ -554,7 +612,9 @@ var Client = class extends EventEmitter {
|
|
|
554
612
|
*/
|
|
555
613
|
async login(token) {
|
|
556
614
|
if (this._ws) {
|
|
557
|
-
throw new FluxerError("Client is already logged in. Call destroy() first."
|
|
615
|
+
throw new FluxerError("Client is already logged in. Call destroy() first.", {
|
|
616
|
+
code: ErrorCodes.AlreadyLoggedIn
|
|
617
|
+
});
|
|
558
618
|
}
|
|
559
619
|
this.rest.setToken(token);
|
|
560
620
|
let intents = this.options.intents ?? 0;
|
|
@@ -586,12 +646,16 @@ var Client = class extends EventEmitter {
|
|
|
586
646
|
async ({
|
|
587
647
|
data
|
|
588
648
|
}) => {
|
|
589
|
-
const { ClientUser: ClientUser2 } = await import("./ClientUser-
|
|
590
|
-
const { Guild: Guild2 } = await import("./Guild-
|
|
591
|
-
const { Channel: Channel2 } = await import("./Channel-
|
|
649
|
+
const { ClientUser: ClientUser2 } = await import("./ClientUser-DJO2FS7P.mjs");
|
|
650
|
+
const { Guild: Guild2 } = await import("./Guild-2P77HBQM.mjs");
|
|
651
|
+
const { Channel: Channel2 } = await import("./Channel-WJZZSNML.mjs");
|
|
592
652
|
this.user = new ClientUser2(this, data.user);
|
|
593
653
|
for (const g of data.guilds ?? []) {
|
|
594
|
-
const
|
|
654
|
+
const guildData = g && typeof g === "object" && "properties" in g && g.properties ? {
|
|
655
|
+
...g.properties,
|
|
656
|
+
roles: g.roles
|
|
657
|
+
} : g;
|
|
658
|
+
const guild = new Guild2(this, guildData);
|
|
595
659
|
this.guilds.set(guild.id, guild);
|
|
596
660
|
const withCh = g;
|
|
597
661
|
for (const ch of withCh.channels ?? []) {
|
|
@@ -636,15 +700,108 @@ var Client = class extends EventEmitter {
|
|
|
636
700
|
}
|
|
637
701
|
};
|
|
638
702
|
|
|
639
|
-
// src/
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
703
|
+
// src/structures/GuildEmoji.ts
|
|
704
|
+
import { Routes as Routes4 } from "@fluxerjs/types";
|
|
705
|
+
var GuildEmoji = class extends Base {
|
|
706
|
+
client;
|
|
707
|
+
id;
|
|
708
|
+
guildId;
|
|
709
|
+
name;
|
|
710
|
+
animated;
|
|
711
|
+
/** @param data - API emoji from GET /guilds/{id}/emojis or guild emoji events */
|
|
712
|
+
constructor(client, data, guildId) {
|
|
713
|
+
super();
|
|
714
|
+
this.client = client;
|
|
715
|
+
this.id = data.id;
|
|
716
|
+
this.guildId = data.guild_id ?? guildId;
|
|
717
|
+
this.name = data.name;
|
|
718
|
+
this.animated = data.animated ?? false;
|
|
719
|
+
}
|
|
720
|
+
/** CDN URL for this emoji image. */
|
|
721
|
+
get url() {
|
|
722
|
+
const ext = this.animated ? "gif" : "png";
|
|
723
|
+
return `${CDN_URL}/emojis/${this.id}.${ext}`;
|
|
724
|
+
}
|
|
725
|
+
/** Emoji identifier for use in reactions: `name:id` */
|
|
726
|
+
get identifier() {
|
|
727
|
+
return `${this.name}:${this.id}`;
|
|
728
|
+
}
|
|
729
|
+
/** Delete this emoji. Requires Manage Emojis and Stickers permission. */
|
|
730
|
+
async delete() {
|
|
731
|
+
await this.client.rest.delete(Routes4.guildEmoji(this.guildId, this.id), {
|
|
732
|
+
auth: true
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* Edit this emoji's name.
|
|
737
|
+
* Requires Manage Emojis and Stickers permission.
|
|
738
|
+
*/
|
|
739
|
+
async edit(options) {
|
|
740
|
+
const data = await this.client.rest.patch(Routes4.guildEmoji(this.guildId, this.id), {
|
|
741
|
+
body: options,
|
|
742
|
+
auth: true
|
|
743
|
+
});
|
|
744
|
+
this.name = data.name;
|
|
745
|
+
return this;
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
|
|
749
|
+
// src/structures/GuildSticker.ts
|
|
750
|
+
import { Routes as Routes5 } from "@fluxerjs/types";
|
|
751
|
+
var GuildSticker = class extends Base {
|
|
752
|
+
client;
|
|
753
|
+
id;
|
|
754
|
+
guildId;
|
|
755
|
+
name;
|
|
756
|
+
description;
|
|
757
|
+
tags;
|
|
758
|
+
animated;
|
|
759
|
+
/** @param data - API sticker from GET /guilds/{id}/stickers or guild sticker events */
|
|
760
|
+
constructor(client, data, guildId) {
|
|
761
|
+
super();
|
|
762
|
+
this.client = client;
|
|
763
|
+
this.id = data.id;
|
|
764
|
+
this.guildId = data.guild_id ?? guildId;
|
|
765
|
+
this.name = data.name;
|
|
766
|
+
this.description = data.description ?? "";
|
|
767
|
+
this.tags = data.tags ?? [];
|
|
768
|
+
this.animated = data.animated ?? false;
|
|
769
|
+
}
|
|
770
|
+
/** CDN URL for this sticker image. */
|
|
771
|
+
get url() {
|
|
772
|
+
const ext = this.animated ? "gif" : "png";
|
|
773
|
+
return `${CDN_URL}/stickers/${this.id}.${ext}`;
|
|
774
|
+
}
|
|
775
|
+
/** Delete this sticker. Requires Manage Emojis and Stickers permission. */
|
|
776
|
+
async delete() {
|
|
777
|
+
await this.client.rest.delete(Routes5.guildSticker(this.guildId, this.id), {
|
|
778
|
+
auth: true
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
/**
|
|
782
|
+
* Edit this sticker's name and/or description.
|
|
783
|
+
* Requires Manage Emojis and Stickers permission.
|
|
784
|
+
*/
|
|
785
|
+
async edit(options) {
|
|
786
|
+
const data = await this.client.rest.patch(Routes5.guildSticker(this.guildId, this.id), {
|
|
787
|
+
body: options,
|
|
788
|
+
auth: true
|
|
789
|
+
});
|
|
790
|
+
const s = data;
|
|
791
|
+
this.name = s.name;
|
|
792
|
+
this.description = s.description ?? "";
|
|
793
|
+
return this;
|
|
794
|
+
}
|
|
643
795
|
};
|
|
644
796
|
|
|
645
797
|
// src/index.ts
|
|
646
798
|
import { EmbedBuilder, MessagePayload, AttachmentBuilder } from "@fluxerjs/builders";
|
|
647
|
-
import { Routes as
|
|
799
|
+
import { Routes as Routes6, GatewayOpcodes, MessageAttachmentFlags } from "@fluxerjs/types";
|
|
800
|
+
import { resolveTenorToImageUrl } from "@fluxerjs/util";
|
|
801
|
+
import {
|
|
802
|
+
PermissionsBitField,
|
|
803
|
+
PermissionFlags
|
|
804
|
+
} from "@fluxerjs/util";
|
|
648
805
|
export {
|
|
649
806
|
AttachmentBuilder,
|
|
650
807
|
Base,
|
|
@@ -660,17 +817,33 @@ export {
|
|
|
660
817
|
FluxerError,
|
|
661
818
|
GatewayOpcodes,
|
|
662
819
|
Guild,
|
|
820
|
+
GuildBan,
|
|
663
821
|
GuildChannel,
|
|
822
|
+
GuildEmoji,
|
|
664
823
|
GuildMember,
|
|
824
|
+
GuildSticker,
|
|
825
|
+
Invite,
|
|
665
826
|
LinkChannel,
|
|
666
827
|
Message,
|
|
828
|
+
MessageAttachmentFlags,
|
|
829
|
+
MessageCollector,
|
|
667
830
|
MessageManager,
|
|
668
831
|
MessagePayload,
|
|
669
832
|
MessageReaction,
|
|
833
|
+
PermissionFlags,
|
|
834
|
+
PermissionsBitField,
|
|
835
|
+
ReactionCollector,
|
|
670
836
|
Role,
|
|
671
|
-
|
|
837
|
+
Routes6 as Routes,
|
|
672
838
|
TextChannel,
|
|
673
839
|
User,
|
|
674
840
|
VoiceChannel,
|
|
675
|
-
Webhook
|
|
841
|
+
Webhook,
|
|
842
|
+
cdnAvatarURL,
|
|
843
|
+
cdnBannerURL,
|
|
844
|
+
cdnDefaultAvatarURL,
|
|
845
|
+
cdnDisplayAvatarURL,
|
|
846
|
+
cdnMemberAvatarURL,
|
|
847
|
+
cdnMemberBannerURL,
|
|
848
|
+
resolveTenorToImageUrl
|
|
676
849
|
};
|