@fluxerjs/core 1.0.5 → 1.0.6

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.
@@ -0,0 +1,17 @@
1
+ import {
2
+ CategoryChannel,
3
+ Channel,
4
+ GuildChannel,
5
+ LinkChannel,
6
+ TextChannel,
7
+ VoiceChannel
8
+ } from "./chunk-OHIHIQAS.mjs";
9
+ import "./chunk-XNS4O6QJ.mjs";
10
+ export {
11
+ CategoryChannel,
12
+ Channel,
13
+ GuildChannel,
14
+ LinkChannel,
15
+ TextChannel,
16
+ VoiceChannel
17
+ };
@@ -0,0 +1,9 @@
1
+ import {
2
+ Message
3
+ } from "./chunk-3CNUPFDI.mjs";
4
+ import "./chunk-P4IRDGB4.mjs";
5
+ import "./chunk-HQMYRYMY.mjs";
6
+ import "./chunk-XNS4O6QJ.mjs";
7
+ export {
8
+ Message
9
+ };
@@ -0,0 +1,59 @@
1
+ import {
2
+ User
3
+ } from "./chunk-P4IRDGB4.mjs";
4
+ import {
5
+ Base
6
+ } from "./chunk-XNS4O6QJ.mjs";
7
+
8
+ // src/structures/Message.ts
9
+ import { Collection } from "@fluxerjs/collection";
10
+ import { Routes } from "@fluxerjs/types";
11
+ import { EmbedBuilder } from "@fluxerjs/builders";
12
+ var Message = class _Message extends Base {
13
+ client;
14
+ id;
15
+ channelId;
16
+ guildId;
17
+ author;
18
+ content;
19
+ createdAt;
20
+ editedAt;
21
+ pinned;
22
+ attachments;
23
+ channel;
24
+ constructor(client, data) {
25
+ super();
26
+ this.client = client;
27
+ this.id = data.id;
28
+ this.channelId = data.channel_id;
29
+ this.guildId = data.guild_id ?? null;
30
+ this.author = new User(client, data.author);
31
+ this.content = data.content;
32
+ this.createdAt = new Date(data.timestamp);
33
+ this.editedAt = data.edited_timestamp ? new Date(data.edited_timestamp) : null;
34
+ this.pinned = data.pinned;
35
+ this.attachments = new Collection();
36
+ for (const a of data.attachments ?? []) this.attachments.set(a.id, a);
37
+ }
38
+ async reply(options) {
39
+ const body = typeof options === "string" ? { content: options, message_reference: { channel_id: this.channelId, message_id: this.id, guild_id: this.guildId ?? void 0 } } : { ...options, message_reference: { channel_id: this.channelId, message_id: this.id, guild_id: this.guildId ?? void 0 } };
40
+ const data = await this.client.rest.post(Routes.channelMessages(this.channelId), { body });
41
+ return new _Message(this.client, data);
42
+ }
43
+ async edit(options) {
44
+ const body = {};
45
+ if (options.content !== void 0) body.content = options.content;
46
+ if (options.embeds?.length) {
47
+ body.embeds = options.embeds.map((e) => e instanceof EmbedBuilder ? e.toJSON() : e);
48
+ }
49
+ const data = await this.client.rest.patch(Routes.channelMessage(this.channelId, this.id), { body });
50
+ return new _Message(this.client, data);
51
+ }
52
+ async delete() {
53
+ await this.client.rest.delete(Routes.channelMessage(this.channelId, this.id));
54
+ }
55
+ };
56
+
57
+ export {
58
+ Message
59
+ };
@@ -0,0 +1,102 @@
1
+ import {
2
+ Base
3
+ } from "./chunk-XNS4O6QJ.mjs";
4
+
5
+ // src/structures/Channel.ts
6
+ import { ChannelType, Routes } from "@fluxerjs/types";
7
+ var Channel = class extends Base {
8
+ client;
9
+ id;
10
+ type;
11
+ constructor(client, data) {
12
+ super();
13
+ this.client = client;
14
+ this.id = data.id;
15
+ this.type = data.type;
16
+ }
17
+ static from(client, data) {
18
+ const type = data.type ?? 0;
19
+ if (type === ChannelType.GuildText) return new TextChannel(client, data);
20
+ if (type === ChannelType.GuildCategory) return new CategoryChannel(client, data);
21
+ if (type === ChannelType.GuildVoice) return new VoiceChannel(client, data);
22
+ if (type === ChannelType.GuildLink) return new LinkChannel(client, data);
23
+ return new GuildChannel(client, data);
24
+ }
25
+ };
26
+ var GuildChannel = class extends Channel {
27
+ guildId;
28
+ name;
29
+ position;
30
+ parentId;
31
+ constructor(client, data) {
32
+ super(client, data);
33
+ this.guildId = data.guild_id ?? "";
34
+ this.name = data.name ?? null;
35
+ this.position = data.position;
36
+ this.parentId = data.parent_id ?? null;
37
+ }
38
+ /** Create a webhook in this channel. Returns the webhook with token (required for send()). */
39
+ async createWebhook(options) {
40
+ const { Webhook } = await import("./Webhook-2RHBXH7R.mjs");
41
+ const data = await this.client.rest.post(Routes.channelWebhooks(this.id), {
42
+ body: options,
43
+ auth: true
44
+ });
45
+ return new Webhook(this.client, data);
46
+ }
47
+ /** Fetch all webhooks in this channel. Returned webhooks do not include the token (cannot send). */
48
+ async fetchWebhooks() {
49
+ const { Webhook } = await import("./Webhook-2RHBXH7R.mjs");
50
+ const data = await this.client.rest.get(Routes.channelWebhooks(this.id));
51
+ const list = Array.isArray(data) ? data : Object.values(data ?? {});
52
+ return list.map((w) => new Webhook(this.client, w));
53
+ }
54
+ };
55
+ var TextChannel = class extends GuildChannel {
56
+ topic;
57
+ nsfw;
58
+ rateLimitPerUser;
59
+ lastMessageId;
60
+ constructor(client, data) {
61
+ super(client, data);
62
+ this.topic = data.topic ?? null;
63
+ this.nsfw = data.nsfw ?? false;
64
+ this.rateLimitPerUser = data.rate_limit_per_user ?? 0;
65
+ this.lastMessageId = data.last_message_id ?? null;
66
+ }
67
+ async send(options) {
68
+ const body = typeof options === "string" ? { content: options } : options;
69
+ const { Message } = await import("./Message-33APPS76.mjs");
70
+ const data = await this.client.rest.post(Routes.channelMessages(this.id), { body });
71
+ return new Message(this.client, data);
72
+ }
73
+ };
74
+ var CategoryChannel = class extends GuildChannel {
75
+ };
76
+ var VoiceChannel = class extends GuildChannel {
77
+ bitrate;
78
+ userLimit;
79
+ rtcRegion;
80
+ constructor(client, data) {
81
+ super(client, data);
82
+ this.bitrate = data.bitrate ?? null;
83
+ this.userLimit = data.user_limit ?? null;
84
+ this.rtcRegion = data.rtc_region ?? null;
85
+ }
86
+ };
87
+ var LinkChannel = class extends GuildChannel {
88
+ url;
89
+ constructor(client, data) {
90
+ super(client, data);
91
+ this.url = data.url ?? null;
92
+ }
93
+ };
94
+
95
+ export {
96
+ Channel,
97
+ GuildChannel,
98
+ TextChannel,
99
+ CategoryChannel,
100
+ VoiceChannel,
101
+ LinkChannel
102
+ };
package/dist/index.d.mts CHANGED
@@ -2,10 +2,11 @@ import * as _fluxerjs_types from '@fluxerjs/types';
2
2
  import { APIUserPartial, APIMessageAttachment, APIMessage, APIEmbed, APIWebhook, ChannelType, APIChannelPartial, APIChannel, APIGuild, APIGuildMember, GatewayPresenceUpdateData, GatewaySendPayload, Routes, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveDispatchData, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayVoiceStateUpdateDispatchData, GatewayVoiceServerUpdateDispatchData } from '@fluxerjs/types';
3
3
  export { GatewayOpcodes, Routes } from '@fluxerjs/types';
4
4
  import { Collection } from '@fluxerjs/collection';
5
+ import { EmbedBuilder } from '@fluxerjs/builders';
6
+ export { AttachmentBuilder, EmbedBuilder, MessagePayload } from '@fluxerjs/builders';
5
7
  import { EventEmitter } from 'events';
6
8
  import { REST } from '@fluxerjs/rest';
7
9
  import { WebSocketManager } from '@fluxerjs/ws';
8
- export { AttachmentBuilder, EmbedBuilder, MessagePayload } from '@fluxerjs/builders';
9
10
 
10
11
  declare abstract class Base {
11
12
  abstract readonly client: Client;
@@ -30,6 +31,11 @@ declare class User extends Base {
30
31
  toString(): string;
31
32
  }
32
33
 
34
+ /** Options for editing a message (content and/or embeds). */
35
+ interface MessageEditOptions {
36
+ content?: string;
37
+ embeds?: (APIEmbed | EmbedBuilder)[];
38
+ }
33
39
  declare class Message extends Base {
34
40
  readonly client: Client;
35
41
  readonly id: string;
@@ -47,9 +53,7 @@ declare class Message extends Base {
47
53
  content?: string;
48
54
  embeds?: APIEmbed[];
49
55
  }): Promise<Message>;
50
- edit(options: {
51
- content?: string;
52
- }): Promise<Message>;
56
+ edit(options: MessageEditOptions): Promise<Message>;
53
57
  delete(): Promise<void>;
54
58
  }
55
59
 
@@ -289,4 +293,4 @@ declare const ErrorCodes: {
289
293
  readonly InvalidToken: "INVALID_TOKEN";
290
294
  };
291
295
 
292
- export { Base, CategoryChannel, Channel, Client, type ClientEvents, ClientUser, ErrorCodes, Events, FluxerError, Guild, GuildChannel, GuildMember, LinkChannel, Message, TextChannel, User, VoiceChannel, Webhook, type WebhookSendOptions };
296
+ export { Base, CategoryChannel, Channel, Client, type ClientEvents, ClientUser, ErrorCodes, Events, FluxerError, Guild, GuildChannel, GuildMember, LinkChannel, Message, type MessageEditOptions, TextChannel, User, VoiceChannel, Webhook, type WebhookSendOptions };
package/dist/index.d.ts CHANGED
@@ -2,10 +2,11 @@ import * as _fluxerjs_types from '@fluxerjs/types';
2
2
  import { APIUserPartial, APIMessageAttachment, APIMessage, APIEmbed, APIWebhook, ChannelType, APIChannelPartial, APIChannel, APIGuild, APIGuildMember, GatewayPresenceUpdateData, GatewaySendPayload, Routes, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveDispatchData, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayVoiceStateUpdateDispatchData, GatewayVoiceServerUpdateDispatchData } from '@fluxerjs/types';
3
3
  export { GatewayOpcodes, Routes } from '@fluxerjs/types';
4
4
  import { Collection } from '@fluxerjs/collection';
5
+ import { EmbedBuilder } from '@fluxerjs/builders';
6
+ export { AttachmentBuilder, EmbedBuilder, MessagePayload } from '@fluxerjs/builders';
5
7
  import { EventEmitter } from 'events';
6
8
  import { REST } from '@fluxerjs/rest';
7
9
  import { WebSocketManager } from '@fluxerjs/ws';
8
- export { AttachmentBuilder, EmbedBuilder, MessagePayload } from '@fluxerjs/builders';
9
10
 
10
11
  declare abstract class Base {
11
12
  abstract readonly client: Client;
@@ -30,6 +31,11 @@ declare class User extends Base {
30
31
  toString(): string;
31
32
  }
32
33
 
34
+ /** Options for editing a message (content and/or embeds). */
35
+ interface MessageEditOptions {
36
+ content?: string;
37
+ embeds?: (APIEmbed | EmbedBuilder)[];
38
+ }
33
39
  declare class Message extends Base {
34
40
  readonly client: Client;
35
41
  readonly id: string;
@@ -47,9 +53,7 @@ declare class Message extends Base {
47
53
  content?: string;
48
54
  embeds?: APIEmbed[];
49
55
  }): Promise<Message>;
50
- edit(options: {
51
- content?: string;
52
- }): Promise<Message>;
56
+ edit(options: MessageEditOptions): Promise<Message>;
53
57
  delete(): Promise<void>;
54
58
  }
55
59
 
@@ -289,4 +293,4 @@ declare const ErrorCodes: {
289
293
  readonly InvalidToken: "INVALID_TOKEN";
290
294
  };
291
295
 
292
- export { Base, CategoryChannel, Channel, Client, type ClientEvents, ClientUser, ErrorCodes, Events, FluxerError, Guild, GuildChannel, GuildMember, LinkChannel, Message, TextChannel, User, VoiceChannel, Webhook, type WebhookSendOptions };
296
+ export { Base, CategoryChannel, Channel, Client, type ClientEvents, ClientUser, ErrorCodes, Events, FluxerError, Guild, GuildChannel, GuildMember, LinkChannel, Message, type MessageEditOptions, TextChannel, User, VoiceChannel, Webhook, type WebhookSendOptions };
package/dist/index.js CHANGED
@@ -85,13 +85,14 @@ var Message_exports = {};
85
85
  __export(Message_exports, {
86
86
  Message: () => Message
87
87
  });
88
- var import_collection, import_types, Message;
88
+ var import_collection, import_types, import_builders, Message;
89
89
  var init_Message = __esm({
90
90
  "src/structures/Message.ts"() {
91
91
  "use strict";
92
92
  init_Base();
93
93
  import_collection = require("@fluxerjs/collection");
94
94
  import_types = require("@fluxerjs/types");
95
+ import_builders = require("@fluxerjs/builders");
95
96
  init_User();
96
97
  Message = class _Message extends Base {
97
98
  client;
@@ -125,7 +126,12 @@ var init_Message = __esm({
125
126
  return new _Message(this.client, data);
126
127
  }
127
128
  async edit(options) {
128
- const data = await this.client.rest.patch(import_types.Routes.channelMessage(this.channelId, this.id), { body: options });
129
+ const body = {};
130
+ if (options.content !== void 0) body.content = options.content;
131
+ if (options.embeds?.length) {
132
+ body.embeds = options.embeds.map((e) => e instanceof import_builders.EmbedBuilder ? e.toJSON() : e);
133
+ }
134
+ const data = await this.client.rest.patch(import_types.Routes.channelMessage(this.channelId, this.id), { body });
129
135
  return new _Message(this.client, data);
130
136
  }
131
137
  async delete() {
@@ -426,13 +432,13 @@ var init_ClientUser = __esm({
426
432
  // src/index.ts
427
433
  var index_exports = {};
428
434
  __export(index_exports, {
429
- AttachmentBuilder: () => import_builders.AttachmentBuilder,
435
+ AttachmentBuilder: () => import_builders2.AttachmentBuilder,
430
436
  Base: () => Base,
431
437
  CategoryChannel: () => CategoryChannel,
432
438
  Channel: () => Channel,
433
439
  Client: () => Client,
434
440
  ClientUser: () => ClientUser,
435
- EmbedBuilder: () => import_builders.EmbedBuilder,
441
+ EmbedBuilder: () => import_builders2.EmbedBuilder,
436
442
  ErrorCodes: () => ErrorCodes,
437
443
  Events: () => Events,
438
444
  FluxerError: () => FluxerError,
@@ -442,7 +448,7 @@ __export(index_exports, {
442
448
  GuildMember: () => GuildMember,
443
449
  LinkChannel: () => LinkChannel,
444
450
  Message: () => Message,
445
- MessagePayload: () => import_builders.MessagePayload,
451
+ MessagePayload: () => import_builders2.MessagePayload,
446
452
  Routes: () => import_types6.Routes,
447
453
  TextChannel: () => TextChannel,
448
454
  User: () => User,
@@ -754,7 +760,7 @@ var ErrorCodes = {
754
760
  };
755
761
 
756
762
  // src/index.ts
757
- var import_builders = require("@fluxerjs/builders");
763
+ var import_builders2 = require("@fluxerjs/builders");
758
764
  var import_types6 = require("@fluxerjs/types");
759
765
  // Annotate the CommonJS export names for ESM import in node:
760
766
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Message
3
- } from "./chunk-LBBIQOSH.mjs";
3
+ } from "./chunk-3CNUPFDI.mjs";
4
4
  import {
5
5
  Webhook
6
6
  } from "./chunk-BUEXP5SZ.mjs";
@@ -14,7 +14,7 @@ import {
14
14
  LinkChannel,
15
15
  TextChannel,
16
16
  VoiceChannel
17
- } from "./chunk-ZHRQQZ4X.mjs";
17
+ } from "./chunk-OHIHIQAS.mjs";
18
18
  import {
19
19
  GuildMember
20
20
  } from "./chunk-TE5IC7IP.mjs";
@@ -95,12 +95,12 @@ var Client = class extends EventEmitter {
95
95
  try {
96
96
  switch (event) {
97
97
  case "MESSAGE_CREATE": {
98
- const { Message: Message2 } = await import("./Message-23Z3RPCZ.mjs");
98
+ const { Message: Message2 } = await import("./Message-33APPS76.mjs");
99
99
  this.emit(Events.MessageCreate, new Message2(this, d));
100
100
  break;
101
101
  }
102
102
  case "MESSAGE_UPDATE": {
103
- const { Message: Message2 } = await import("./Message-23Z3RPCZ.mjs");
103
+ const { Message: Message2 } = await import("./Message-33APPS76.mjs");
104
104
  this.emit(Events.MessageUpdate, null, new Message2(this, d));
105
105
  break;
106
106
  }
@@ -121,7 +121,7 @@ var Client = class extends EventEmitter {
121
121
  break;
122
122
  case "GUILD_CREATE": {
123
123
  const { Guild: Guild2 } = await import("./Guild-NHNQ5TIA.mjs");
124
- const { Channel: Channel2 } = await import("./Channel-2WNJ445K.mjs");
124
+ const { Channel: Channel2 } = await import("./Channel-IKL3SJXN.mjs");
125
125
  const guild = new Guild2(this, d);
126
126
  this.guilds.set(guild.id, guild);
127
127
  const g = d;
@@ -154,7 +154,7 @@ var Client = class extends EventEmitter {
154
154
  break;
155
155
  }
156
156
  case "CHANNEL_CREATE": {
157
- const { Channel: Channel2 } = await import("./Channel-2WNJ445K.mjs");
157
+ const { Channel: Channel2 } = await import("./Channel-IKL3SJXN.mjs");
158
158
  const ch = Channel2.from(this, d);
159
159
  if (ch) {
160
160
  this.channels.set(ch.id, ch);
@@ -163,7 +163,7 @@ var Client = class extends EventEmitter {
163
163
  break;
164
164
  }
165
165
  case "CHANNEL_UPDATE": {
166
- const { Channel: Channel2 } = await import("./Channel-2WNJ445K.mjs");
166
+ const { Channel: Channel2 } = await import("./Channel-IKL3SJXN.mjs");
167
167
  const ch = d;
168
168
  const oldCh = this.channels.get(ch.id);
169
169
  const newCh = Channel2.from(this, ch);
@@ -264,7 +264,7 @@ var Client = class extends EventEmitter {
264
264
  this._ws.on("ready", async ({ data }) => {
265
265
  const { ClientUser: ClientUser2 } = await import("./ClientUser-RNDKHQ3Z.mjs");
266
266
  const { Guild: Guild2 } = await import("./Guild-NHNQ5TIA.mjs");
267
- const { Channel: Channel2 } = await import("./Channel-2WNJ445K.mjs");
267
+ const { Channel: Channel2 } = await import("./Channel-IKL3SJXN.mjs");
268
268
  this.user = new ClientUser2(this, data.user);
269
269
  for (const g of data.guilds ?? []) {
270
270
  const guild = new Guild2(this, g);
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.0.5",
6
+ "version": "1.0.6",
7
7
  "description": "A fully-featured SDK for Fluxer bots",
8
8
  "main": "./dist/index.js",
9
9
  "module": "./dist/index.mjs",
@@ -19,12 +19,12 @@
19
19
  "dist"
20
20
  ],
21
21
  "dependencies": {
22
- "@fluxerjs/rest": "1.0.5",
23
- "@fluxerjs/builders": "1.0.5",
24
- "@fluxerjs/ws": "1.0.5",
25
- "@fluxerjs/util": "1.0.5",
26
- "@fluxerjs/types": "1.0.5",
27
- "@fluxerjs/collection": "1.0.5"
22
+ "@fluxerjs/rest": "1.0.6",
23
+ "@fluxerjs/ws": "1.0.6",
24
+ "@fluxerjs/collection": "1.0.6",
25
+ "@fluxerjs/types": "1.0.6",
26
+ "@fluxerjs/builders": "1.0.6",
27
+ "@fluxerjs/util": "1.0.6"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/node": "^20.0.0",