@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.
Files changed (36) hide show
  1. package/LICENSE +203 -0
  2. package/dist/{Channel-ICWNKXBR.mjs → Channel-4WVFDOCG.mjs} +4 -1
  3. package/dist/{ClientUser-WWXUMO5O.mjs → ClientUser-PXAAKR2P.mjs} +1 -1
  4. package/dist/Guild-FMBCTAV4.mjs +12 -0
  5. package/dist/{GuildBan-M4PA3HAA.mjs → GuildBan-7CXLTPKY.mjs} +1 -1
  6. package/dist/GuildMember-43B5E5CH.mjs +9 -0
  7. package/dist/Message-OFIVTTAZ.mjs +9 -0
  8. package/dist/{MessageReaction-XRPYZDSC.mjs → MessageReaction-AYSOCOMX.mjs} +2 -1
  9. package/dist/{Role-SVLWIAMN.mjs → Role-5MWSGL66.mjs} +1 -1
  10. package/dist/Webhook-RWDDYW2Q.mjs +10 -0
  11. package/dist/{chunk-GCIJYVRC.mjs → chunk-4F765HVV.mjs} +54 -3
  12. package/dist/chunk-AH7KYH2Z.mjs +50 -0
  13. package/dist/{chunk-53Y37KRG.mjs → chunk-CJVQNARM.mjs} +44 -10
  14. package/dist/chunk-DQ4TNBPG.mjs +63 -0
  15. package/dist/chunk-DUQAD7F6.mjs +173 -0
  16. package/dist/chunk-FRVZ7D6D.mjs +293 -0
  17. package/dist/{chunk-HBF5QEDH.mjs → chunk-K6NLD6SB.mjs} +23 -1
  18. package/dist/chunk-PM2IUGNR.mjs +29 -0
  19. package/dist/chunk-RWFKZ3DF.mjs +413 -0
  20. package/dist/{chunk-RCP27MRC.mjs → chunk-UXIF75BV.mjs} +3 -0
  21. package/dist/chunk-V6T5VMWD.mjs +26 -0
  22. package/dist/{chunk-DSPSRPHF.mjs → chunk-V7LPVPGH.mjs} +123 -18
  23. package/dist/chunk-X6K3ZD62.mjs +53 -0
  24. package/dist/index.d.mts +603 -113
  25. package/dist/index.d.ts +603 -113
  26. package/dist/index.js +1335 -426
  27. package/dist/index.mjs +189 -125
  28. package/package.json +8 -8
  29. package/dist/Guild-TM6YGJWB.mjs +0 -10
  30. package/dist/GuildMember-RZWZ3OCG.mjs +0 -7
  31. package/dist/Message-6IYEYSV6.mjs +0 -7
  32. package/dist/Webhook-32VJD4AL.mjs +0 -7
  33. package/dist/chunk-FJS5FBXO.mjs +0 -233
  34. package/dist/chunk-GFUJVQ7L.mjs +0 -64
  35. package/dist/chunk-SQVCCSNN.mjs +0 -41
  36. package/dist/chunk-X77DFNE3.mjs +0 -136
@@ -1,233 +0,0 @@
1
- import {
2
- Base
3
- } from "./chunk-XNS4O6QJ.mjs";
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
-
21
- // src/structures/Channel.ts
22
- import { ChannelType, Routes } from "@fluxerjs/types";
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
- }
36
- /** Create a DM channel from API data (type DM or GroupDM). */
37
- static createDM(client, data) {
38
- return new DMChannel(client, data);
39
- }
40
- client;
41
- id;
42
- type;
43
- /** @param data - API channel from GET /channels/{id} or GET /guilds/{id}/channels */
44
- constructor(client, data) {
45
- super();
46
- this.client = client;
47
- this.id = data.id;
48
- this.type = data.type;
49
- }
50
- /**
51
- * Create the appropriate channel subclass from API data.
52
- * @param client - The client instance
53
- * @param data - Channel data from the API
54
- */
55
- static from(client, data) {
56
- const type = data.type ?? 0;
57
- if (type === ChannelType.GuildText) return new TextChannel(client, data);
58
- if (type === ChannelType.GuildCategory) return new CategoryChannel(client, data);
59
- if (type === ChannelType.GuildVoice) return new VoiceChannel(client, data);
60
- if (type === ChannelType.GuildLink || type === ChannelType.GuildLinkExtended)
61
- return new LinkChannel(client, data);
62
- return new GuildChannel(client, data);
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
- }
74
- };
75
- var GuildChannel = class extends Channel {
76
- guildId;
77
- name;
78
- position;
79
- parentId;
80
- constructor(client, data) {
81
- super(client, data);
82
- this.guildId = data.guild_id ?? "";
83
- this.name = data.name ?? null;
84
- this.position = data.position;
85
- this.parentId = data.parent_id ?? null;
86
- }
87
- /**
88
- * Create a webhook in this channel.
89
- * @param options - Webhook name and optional avatar URL
90
- * @returns The webhook with token (required for send()). Requires Manage Webhooks permission.
91
- */
92
- async createWebhook(options) {
93
- const { Webhook } = await import("./Webhook-32VJD4AL.mjs");
94
- const data = await this.client.rest.post(Routes.channelWebhooks(this.id), {
95
- body: options,
96
- auth: true
97
- });
98
- return new Webhook(this.client, data);
99
- }
100
- /**
101
- * Fetch all webhooks in this channel.
102
- * @returns Webhooks (includes token when listing from channel; can send via send())
103
- */
104
- async fetchWebhooks() {
105
- const { Webhook } = await import("./Webhook-32VJD4AL.mjs");
106
- const data = await this.client.rest.get(Routes.channelWebhooks(this.id));
107
- const list = Array.isArray(data) ? data : Object.values(data ?? {});
108
- return list.map((w) => new Webhook(this.client, w));
109
- }
110
- };
111
- var TextChannel = class extends GuildChannel {
112
- topic;
113
- nsfw;
114
- rateLimitPerUser;
115
- lastMessageId;
116
- constructor(client, data) {
117
- super(client, data);
118
- this.topic = data.topic ?? null;
119
- this.nsfw = data.nsfw ?? false;
120
- this.rateLimitPerUser = data.rate_limit_per_user ?? 0;
121
- this.lastMessageId = data.last_message_id ?? null;
122
- }
123
- /**
124
- * Send a message to this channel.
125
- * @param options - Text content or object with `content` and/or `embeds`
126
- */
127
- async send(options) {
128
- const body = typeof options === "string" ? { content: options } : options;
129
- const { Message } = await import("./Message-6IYEYSV6.mjs");
130
- const data = await this.client.rest.post(Routes.channelMessages(this.id), { body });
131
- return new Message(this.client, data);
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 pinned messages in this channel.
139
- * @returns Pinned messages
140
- */
141
- async fetchPinnedMessages() {
142
- const { Message } = await import("./Message-6IYEYSV6.mjs");
143
- const data = await this.client.rest.get(Routes.channelPins(this.id));
144
- const list = Array.isArray(data) ? data : data?.items ?? [];
145
- return list.map((item) => {
146
- const msg = typeof item === "object" && item && "message" in item ? item.message : item;
147
- return new Message(this.client, msg);
148
- });
149
- }
150
- /**
151
- * Fetch a message by ID from this channel.
152
- * @param messageId - Snowflake of the message
153
- * @returns The message, or null if not found
154
- * @deprecated Use channel.messages.fetch(messageId) instead.
155
- */
156
- async fetchMessage(messageId) {
157
- return this.client.channels.fetchMessage(this.id, messageId);
158
- }
159
- };
160
- var CategoryChannel = class extends GuildChannel {
161
- };
162
- var VoiceChannel = class extends GuildChannel {
163
- bitrate;
164
- userLimit;
165
- rtcRegion;
166
- constructor(client, data) {
167
- super(client, data);
168
- this.bitrate = data.bitrate ?? null;
169
- this.userLimit = data.user_limit ?? null;
170
- this.rtcRegion = data.rtc_region ?? null;
171
- }
172
- };
173
- var LinkChannel = class extends GuildChannel {
174
- url;
175
- constructor(client, data) {
176
- super(client, data);
177
- this.url = data.url ?? null;
178
- }
179
- };
180
- var DMChannel = class extends Channel {
181
- lastMessageId;
182
- constructor(client, data) {
183
- super(client, data);
184
- this.lastMessageId = data.last_message_id ?? null;
185
- }
186
- /**
187
- * Send a message to this DM channel.
188
- * @param options - Text content or object with `content` and/or `embeds`
189
- */
190
- async send(options) {
191
- const body = typeof options === "string" ? { content: options } : options;
192
- const { Message } = await import("./Message-6IYEYSV6.mjs");
193
- const data = await this.client.rest.post(Routes.channelMessages(this.id), { body });
194
- return new Message(this.client, data);
195
- }
196
- /** Message manager for this channel. Use channel.messages.fetch(messageId). */
197
- get messages() {
198
- return new MessageManager(this.client, this.id);
199
- }
200
- /**
201
- * Fetch pinned messages in this DM channel.
202
- * @returns Pinned messages
203
- */
204
- async fetchPinnedMessages() {
205
- const { Message } = await import("./Message-6IYEYSV6.mjs");
206
- const data = await this.client.rest.get(Routes.channelPins(this.id));
207
- const list = Array.isArray(data) ? data : data?.items ?? [];
208
- return list.map((item) => {
209
- const msg = typeof item === "object" && item && "message" in item ? item.message : item;
210
- return new Message(this.client, msg);
211
- });
212
- }
213
- /**
214
- * Fetch a message by ID from this DM channel.
215
- * @param messageId - Snowflake of the message
216
- * @returns The message, or null if not found
217
- * @deprecated Use channel.messages.fetch(messageId) instead.
218
- */
219
- async fetchMessage(messageId) {
220
- return this.client.channels.fetchMessage(this.id, messageId);
221
- }
222
- };
223
-
224
- export {
225
- MessageManager,
226
- Channel,
227
- GuildChannel,
228
- TextChannel,
229
- CategoryChannel,
230
- VoiceChannel,
231
- LinkChannel,
232
- DMChannel
233
- };
@@ -1,64 +0,0 @@
1
- import {
2
- Base
3
- } from "./chunk-XNS4O6QJ.mjs";
4
-
5
- // src/structures/GuildMember.ts
6
- import { Routes } from "@fluxerjs/types";
7
- var GuildMember = class extends Base {
8
- client;
9
- id;
10
- user;
11
- guild;
12
- nick;
13
- roles;
14
- joinedAt;
15
- communicationDisabledUntil;
16
- mute;
17
- deaf;
18
- avatar;
19
- banner;
20
- accentColor;
21
- profileFlags;
22
- /** @param data - API guild member from GET /guilds/{id}/members or GET /guilds/{id}/members/{user_id} */
23
- constructor(client, data, guild) {
24
- super();
25
- this.client = client;
26
- this.user = client.getOrCreateUser(data.user);
27
- this.id = data.user.id;
28
- this.guild = guild;
29
- this.nick = data.nick ?? null;
30
- this.roles = data.roles ?? [];
31
- this.joinedAt = new Date(data.joined_at);
32
- this.communicationDisabledUntil = data.communication_disabled_until ? new Date(data.communication_disabled_until) : null;
33
- this.mute = data.mute ?? false;
34
- this.deaf = data.deaf ?? false;
35
- this.avatar = data.avatar ?? null;
36
- this.banner = data.banner ?? null;
37
- this.accentColor = data.accent_color ?? null;
38
- this.profileFlags = data.profile_flags ?? null;
39
- }
40
- /** Nickname, or global name, or username. */
41
- get displayName() {
42
- return this.nick ?? this.user.globalName ?? this.user.username;
43
- }
44
- /**
45
- * Add a role to this member.
46
- * @param roleId - The role ID to add
47
- * Requires Manage Roles permission.
48
- */
49
- async addRole(roleId) {
50
- await this.client.rest.put(Routes.guildMemberRole(this.guild.id, this.id, roleId));
51
- }
52
- /**
53
- * Remove a role from this member.
54
- * @param roleId - The role ID to remove
55
- * Requires Manage Roles permission.
56
- */
57
- async removeRole(roleId) {
58
- await this.client.rest.delete(Routes.guildMemberRole(this.guild.id, this.id, roleId));
59
- }
60
- };
61
-
62
- export {
63
- GuildMember
64
- };
@@ -1,41 +0,0 @@
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
- };
@@ -1,136 +0,0 @@
1
- import {
2
- CDN_URL
3
- } from "./chunk-HQMYRYMY.mjs";
4
- import {
5
- GuildMember
6
- } from "./chunk-GFUJVQ7L.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
- /**
110
- * Fetch guild audit logs. Requires View Audit Log permission.
111
- * @param options - Optional limit, before, after, user_id, action_type for filtering
112
- */
113
- async fetchAuditLogs(options) {
114
- const params = new URLSearchParams();
115
- if (options?.limit != null) params.set("limit", String(options.limit));
116
- if (options?.before) params.set("before", options.before);
117
- if (options?.after) params.set("after", options.after);
118
- if (options?.userId) params.set("user_id", options.userId);
119
- if (options?.actionType != null)
120
- params.set("action_type", String(options.actionType));
121
- const qs = params.toString();
122
- const url = Routes.guildAuditLogs(this.id) + (qs ? `?${qs}` : "");
123
- return this.client.rest.get(url);
124
- }
125
- /** Fetch all webhooks in this guild. Returned webhooks do not include the token (cannot send). */
126
- async fetchWebhooks() {
127
- const { Webhook } = await import("./Webhook-32VJD4AL.mjs");
128
- const data = await this.client.rest.get(Routes.guildWebhooks(this.id));
129
- const list = Array.isArray(data) ? data : Object.values(data ?? {});
130
- return list.map((w) => new Webhook(this.client, w));
131
- }
132
- };
133
-
134
- export {
135
- Guild
136
- };