@fluxerjs/core 1.0.8 → 1.0.9

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.
@@ -6,7 +6,7 @@ import {
6
6
  LinkChannel,
7
7
  TextChannel,
8
8
  VoiceChannel
9
- } from "./chunk-CZIO2D7F.mjs";
9
+ } from "./chunk-FJS5FBXO.mjs";
10
10
  import "./chunk-XNS4O6QJ.mjs";
11
11
  export {
12
12
  CategoryChannel,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ClientUser
3
- } from "./chunk-4GCZFOS5.mjs";
3
+ } from "./chunk-GCIJYVRC.mjs";
4
4
  import "./chunk-HQMYRYMY.mjs";
5
5
  import "./chunk-XNS4O6QJ.mjs";
6
6
  export {
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  Guild
3
- } from "./chunk-TJVZEILY.mjs";
3
+ } from "./chunk-X77DFNE3.mjs";
4
4
  import "./chunk-HQMYRYMY.mjs";
5
- import "./chunk-JVEOQFUX.mjs";
5
+ import "./chunk-GFUJVQ7L.mjs";
6
6
  import "./chunk-SQVCCSNN.mjs";
7
7
  import "./chunk-XNS4O6QJ.mjs";
8
8
  export {
@@ -0,0 +1,7 @@
1
+ import {
2
+ GuildBan
3
+ } from "./chunk-RCP27MRC.mjs";
4
+ import "./chunk-XNS4O6QJ.mjs";
5
+ export {
6
+ GuildBan
7
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  GuildMember
3
- } from "./chunk-JVEOQFUX.mjs";
3
+ } from "./chunk-GFUJVQ7L.mjs";
4
4
  import "./chunk-XNS4O6QJ.mjs";
5
5
  export {
6
6
  GuildMember
@@ -0,0 +1,7 @@
1
+ import {
2
+ Invite
3
+ } from "./chunk-QEXIYXXU.mjs";
4
+ import "./chunk-XNS4O6QJ.mjs";
5
+ export {
6
+ Invite
7
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Message
3
- } from "./chunk-CO5EL5LH.mjs";
3
+ } from "./chunk-DSPSRPHF.mjs";
4
4
  import "./chunk-XNS4O6QJ.mjs";
5
5
  export {
6
6
  Message
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Webhook
3
- } from "./chunk-ZGMM6IPQ.mjs";
3
+ } from "./chunk-53Y37KRG.mjs";
4
4
  import "./chunk-XNS4O6QJ.mjs";
5
5
  export {
6
6
  Webhook
@@ -28,6 +28,38 @@ var Webhook = class _Webhook extends Base {
28
28
  async delete() {
29
29
  await this.client.rest.delete(Routes.webhook(this.id), { auth: true });
30
30
  }
31
+ /**
32
+ * Edit this webhook. With token: name and avatar only. Without token (bot auth): name, avatar, and channel_id.
33
+ * @param options - Fields to update (name, avatar, channel_id when using bot auth)
34
+ * @returns This webhook instance with updated fields
35
+ */
36
+ async edit(options) {
37
+ const body = {};
38
+ if (options.name !== void 0) body.name = options.name;
39
+ if (options.avatar !== void 0) body.avatar = options.avatar;
40
+ if ("channel_id" in options && options.channel_id !== void 0 && !this.token) {
41
+ body.channel_id = options.channel_id;
42
+ }
43
+ if (this.token) {
44
+ const data2 = await this.client.rest.patch(
45
+ Routes.webhookExecute(this.id, this.token),
46
+ { body, auth: false }
47
+ );
48
+ const w2 = data2;
49
+ this.name = w2.name ?? this.name;
50
+ this.avatar = w2.avatar ?? null;
51
+ return this;
52
+ }
53
+ const data = await this.client.rest.patch(Routes.webhook(this.id), {
54
+ body,
55
+ auth: true
56
+ });
57
+ const w = data;
58
+ this.name = w.name ?? this.name;
59
+ this.avatar = w.avatar ?? null;
60
+ this.channelId = w.channel_id ?? this.channelId;
61
+ return this;
62
+ }
31
63
  /**
32
64
  * Send a message via this webhook. Requires the webhook token (only present when created, not when fetched).
33
65
  * @throws Error if token is not available
@@ -4,7 +4,7 @@ import {
4
4
 
5
5
  // src/structures/Message.ts
6
6
  import { Collection } from "@fluxerjs/collection";
7
- import { Routes } from "@fluxerjs/types";
7
+ import { MessageType, Routes } from "@fluxerjs/types";
8
8
  import { EmbedBuilder } from "@fluxerjs/builders";
9
9
  var Message = class _Message extends Base {
10
10
  client;
@@ -17,6 +17,17 @@ var Message = class _Message extends Base {
17
17
  editedAt;
18
18
  pinned;
19
19
  attachments;
20
+ type;
21
+ flags;
22
+ mentionEveryone;
23
+ tts;
24
+ embeds;
25
+ stickers;
26
+ reactions;
27
+ messageReference;
28
+ messageSnapshots;
29
+ call;
30
+ referencedMessage;
20
31
  /** Channel where this message was sent. Resolved from cache; null if not cached (e.g. DM channel not in cache). */
21
32
  get channel() {
22
33
  return this.client.channels.get(this.channelId) ?? null;
@@ -39,6 +50,17 @@ var Message = class _Message extends Base {
39
50
  this.pinned = data.pinned;
40
51
  this.attachments = new Collection();
41
52
  for (const a of data.attachments ?? []) this.attachments.set(a.id, a);
53
+ this.type = data.type ?? MessageType.Default;
54
+ this.flags = data.flags ?? 0;
55
+ this.mentionEveryone = data.mention_everyone ?? false;
56
+ this.tts = data.tts ?? false;
57
+ this.embeds = data.embeds ?? [];
58
+ this.stickers = data.stickers ?? [];
59
+ this.reactions = data.reactions ?? [];
60
+ this.messageReference = data.message_reference ?? null;
61
+ this.messageSnapshots = data.message_snapshots ?? [];
62
+ this.call = data.call ?? null;
63
+ this.referencedMessage = data.referenced_message ? new _Message(client, data.referenced_message) : null;
42
64
  }
43
65
  /**
44
66
  * Send a message to this channel without replying. Use when you want a standalone message.
@@ -116,6 +138,16 @@ var Message = class _Message extends Base {
116
138
  async delete() {
117
139
  await this.client.rest.delete(Routes.channelMessage(this.channelId, this.id));
118
140
  }
141
+ /** Pin this message to the channel. Requires Manage Messages permission. */
142
+ async pin() {
143
+ await this.client.rest.put(Routes.channelPinMessage(this.channelId, this.id));
144
+ this.pinned = true;
145
+ }
146
+ /** Unpin this message from the channel. Requires Manage Messages permission. */
147
+ async unpin() {
148
+ await this.client.rest.delete(Routes.channelPinMessage(this.channelId, this.id));
149
+ this.pinned = false;
150
+ }
119
151
  /**
120
152
  * Format emoji for reaction API: unicode string or "name:id" for custom.
121
153
  * For string resolution (e.g. :name:), use client.resolveEmoji; Message methods resolve automatically when guildId is available.
@@ -90,7 +90,7 @@ var GuildChannel = class extends Channel {
90
90
  * @returns The webhook with token (required for send()). Requires Manage Webhooks permission.
91
91
  */
92
92
  async createWebhook(options) {
93
- const { Webhook } = await import("./Webhook-2MQESB7Z.mjs");
93
+ const { Webhook } = await import("./Webhook-32VJD4AL.mjs");
94
94
  const data = await this.client.rest.post(Routes.channelWebhooks(this.id), {
95
95
  body: options,
96
96
  auth: true
@@ -102,7 +102,7 @@ var GuildChannel = class extends Channel {
102
102
  * @returns Webhooks (includes token when listing from channel; can send via send())
103
103
  */
104
104
  async fetchWebhooks() {
105
- const { Webhook } = await import("./Webhook-2MQESB7Z.mjs");
105
+ const { Webhook } = await import("./Webhook-32VJD4AL.mjs");
106
106
  const data = await this.client.rest.get(Routes.channelWebhooks(this.id));
107
107
  const list = Array.isArray(data) ? data : Object.values(data ?? {});
108
108
  return list.map((w) => new Webhook(this.client, w));
@@ -126,7 +126,7 @@ var TextChannel = class extends GuildChannel {
126
126
  */
127
127
  async send(options) {
128
128
  const body = typeof options === "string" ? { content: options } : options;
129
- const { Message } = await import("./Message-G2QIKZQK.mjs");
129
+ const { Message } = await import("./Message-6IYEYSV6.mjs");
130
130
  const data = await this.client.rest.post(Routes.channelMessages(this.id), { body });
131
131
  return new Message(this.client, data);
132
132
  }
@@ -134,6 +134,19 @@ var TextChannel = class extends GuildChannel {
134
134
  get messages() {
135
135
  return new MessageManager(this.client, this.id);
136
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
+ }
137
150
  /**
138
151
  * Fetch a message by ID from this channel.
139
152
  * @param messageId - Snowflake of the message
@@ -176,7 +189,7 @@ var DMChannel = class extends Channel {
176
189
  */
177
190
  async send(options) {
178
191
  const body = typeof options === "string" ? { content: options } : options;
179
- const { Message } = await import("./Message-G2QIKZQK.mjs");
192
+ const { Message } = await import("./Message-6IYEYSV6.mjs");
180
193
  const data = await this.client.rest.post(Routes.channelMessages(this.id), { body });
181
194
  return new Message(this.client, data);
182
195
  }
@@ -184,6 +197,19 @@ var DMChannel = class extends Channel {
184
197
  get messages() {
185
198
  return new MessageManager(this.client, this.id);
186
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
+ }
187
213
  /**
188
214
  * Fetch a message by ID from this DM channel.
189
215
  * @param messageId - Snowflake of the message
@@ -56,7 +56,7 @@ var User = class extends Base {
56
56
  * Returns the DM channel; use {@link DMChannel.send} to send messages.
57
57
  */
58
58
  async createDM() {
59
- const { DMChannel: DMChannelClass } = await import("./Channel-TWPDKW2P.mjs");
59
+ const { DMChannel: DMChannelClass } = await import("./Channel-ICWNKXBR.mjs");
60
60
  const data = await this.client.rest.post(Routes.userMeChannels(), {
61
61
  body: { recipient_id: this.id },
62
62
  auth: true
@@ -13,6 +13,12 @@ var GuildMember = class extends Base {
13
13
  roles;
14
14
  joinedAt;
15
15
  communicationDisabledUntil;
16
+ mute;
17
+ deaf;
18
+ avatar;
19
+ banner;
20
+ accentColor;
21
+ profileFlags;
16
22
  /** @param data - API guild member from GET /guilds/{id}/members or GET /guilds/{id}/members/{user_id} */
17
23
  constructor(client, data, guild) {
18
24
  super();
@@ -24,6 +30,12 @@ var GuildMember = class extends Base {
24
30
  this.roles = data.roles ?? [];
25
31
  this.joinedAt = new Date(data.joined_at);
26
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;
27
39
  }
28
40
  /** Nickname, or global name, or username. */
29
41
  get displayName() {
@@ -0,0 +1,62 @@
1
+ import {
2
+ Base
3
+ } from "./chunk-XNS4O6QJ.mjs";
4
+
5
+ // src/structures/Invite.ts
6
+ import { Routes } from "@fluxerjs/types";
7
+ var Invite = class extends Base {
8
+ client;
9
+ code;
10
+ type;
11
+ guild;
12
+ channel;
13
+ inviter;
14
+ memberCount;
15
+ presenceCount;
16
+ expiresAt;
17
+ temporary;
18
+ createdAt;
19
+ uses;
20
+ maxUses;
21
+ maxAge;
22
+ /** @param data - API invite from GET /invites/{code}, channel/guild invite list, or gateway INVITE_CREATE */
23
+ constructor(client, data) {
24
+ super();
25
+ this.client = client;
26
+ this.code = data.code;
27
+ this.type = data.type;
28
+ this.guild = data.guild;
29
+ this.channel = data.channel;
30
+ this.inviter = data.inviter ? client.getOrCreateUser(data.inviter) : null;
31
+ this.memberCount = data.member_count ?? null;
32
+ this.presenceCount = data.presence_count ?? null;
33
+ this.expiresAt = data.expires_at ?? null;
34
+ this.temporary = data.temporary ?? null;
35
+ this.createdAt = data.created_at ?? null;
36
+ this.uses = data.uses ?? null;
37
+ this.maxUses = data.max_uses ?? null;
38
+ this.maxAge = data.max_age ?? null;
39
+ }
40
+ /** Full invite URL (https://fluxer.gg/{code} or instance-specific). */
41
+ get url() {
42
+ return `https://fluxer.gg/${this.code}`;
43
+ }
44
+ /**
45
+ * Resolve the guild from cache if available.
46
+ * @returns The guild, or null if not cached
47
+ */
48
+ getGuild() {
49
+ return this.guild?.id ? this.client.guilds.get(this.guild.id) ?? null : null;
50
+ }
51
+ /**
52
+ * Delete this invite.
53
+ * Requires Manage Guild or Create Instant Invite permission.
54
+ */
55
+ async delete() {
56
+ await this.client.rest.delete(Routes.invite(this.code), { auth: true });
57
+ }
58
+ };
59
+
60
+ export {
61
+ Invite
62
+ };
@@ -0,0 +1,33 @@
1
+ import {
2
+ Base
3
+ } from "./chunk-XNS4O6QJ.mjs";
4
+
5
+ // src/structures/GuildBan.ts
6
+ import { Routes } from "@fluxerjs/types";
7
+ var GuildBan = class extends Base {
8
+ client;
9
+ guildId;
10
+ user;
11
+ reason;
12
+ /** @param data - API ban from GET /guilds/{id}/bans or gateway GUILD_BAN_ADD */
13
+ constructor(client, data, guildId) {
14
+ super();
15
+ this.client = client;
16
+ this.guildId = data.guild_id ?? guildId;
17
+ this.user = client.getOrCreateUser(data.user);
18
+ this.reason = data.reason ?? null;
19
+ }
20
+ /**
21
+ * Remove this ban (unban the user).
22
+ * Requires Ban Members permission.
23
+ */
24
+ async unban() {
25
+ await this.client.rest.delete(Routes.guildBan(this.guildId, this.user.id), {
26
+ auth: true
27
+ });
28
+ }
29
+ };
30
+
31
+ export {
32
+ GuildBan
33
+ };
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-HQMYRYMY.mjs";
4
4
  import {
5
5
  GuildMember
6
- } from "./chunk-JVEOQFUX.mjs";
6
+ } from "./chunk-GFUJVQ7L.mjs";
7
7
  import {
8
8
  Role
9
9
  } from "./chunk-SQVCCSNN.mjs";
@@ -106,9 +106,25 @@ var Guild = class extends Base {
106
106
  return null;
107
107
  }
108
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
+ }
109
125
  /** Fetch all webhooks in this guild. Returned webhooks do not include the token (cannot send). */
110
126
  async fetchWebhooks() {
111
- const { Webhook } = await import("./Webhook-2MQESB7Z.mjs");
127
+ const { Webhook } = await import("./Webhook-32VJD4AL.mjs");
112
128
  const data = await this.client.rest.get(Routes.guildWebhooks(this.id));
113
129
  const list = Array.isArray(data) ? data : Object.values(data ?? {});
114
130
  return list.map((w) => new Webhook(this.client, w));