revbot.js 0.1.8 → 0.1.10

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/index.mjs CHANGED
@@ -90,6 +90,7 @@ var _BaseManager = class _BaseManager {
90
90
  /**
91
91
  * Adds a raw object to the cache, constructing the holdable class.
92
92
  * Automatically evicts oldest entries if the max size is exceeded.
93
+ * @private
93
94
  */
94
95
  _add(raw) {
95
96
  if (!this.holds) throw new Error("Holds is not defined");
@@ -98,7 +99,9 @@ var _BaseManager = class _BaseManager {
98
99
  this.enforceMaxSize();
99
100
  return obj;
100
101
  }
101
- /** Remove an entry by id. */
102
+ /** Remove an entry by id.
103
+ * @private
104
+ */
102
105
  _remove(id) {
103
106
  this.cache.delete(id);
104
107
  }
@@ -2020,6 +2023,8 @@ var ServerChannel = class extends Channel {
2020
2023
  this.description = null;
2021
2024
  /** The icon of the channel, or `null` if none is set. */
2022
2025
  this.icon = null;
2026
+ /** Manages the messages in this Server channel. */
2027
+ this.messages = new MessageManager(this);
2023
2028
  /** The permission overwrites for the channel. */
2024
2029
  this.overwrites = /* @__PURE__ */ new Map();
2025
2030
  /** Whether the channel is marked as NSFW (Not Safe For Work). */
@@ -2090,6 +2095,20 @@ var ServerChannel = class extends Channel {
2090
2095
  get server() {
2091
2096
  return this.client.servers.cache.get(this.serverId);
2092
2097
  }
2098
+ /**
2099
+ * Sends a message to this Server channel.
2100
+ *
2101
+ * @param {MessageOptions | string} options - The message content or options for the message.
2102
+ * @returns {Promise<Message>} A promise that resolves with the sent message.
2103
+ *
2104
+ * @example
2105
+ * ```typescript
2106
+ * await serverChannel.send("Hello, world!");
2107
+ * ```
2108
+ */
2109
+ send(options) {
2110
+ return this.messages.send(options);
2111
+ }
2093
2112
  /**
2094
2113
  * Retrieves the category this channel belongs to, if any.
2095
2114
  *
@@ -2500,8 +2519,10 @@ var Emoji2 = class extends Base {
2500
2519
  var ChannelManager = class extends BaseManager {
2501
2520
  constructor() {
2502
2521
  super(...arguments);
2522
+ /** @private */
2503
2523
  this.holds = null;
2504
2524
  }
2525
+ /** @private */
2505
2526
  _add(data) {
2506
2527
  let channel;
2507
2528
  switch (data.channel_type) {
@@ -2595,8 +2616,10 @@ var ChannelManager = class extends BaseManager {
2595
2616
  var ServerManager = class extends BaseManager {
2596
2617
  constructor() {
2597
2618
  super(...arguments);
2619
+ /** @private */
2598
2620
  this.holds = Server2;
2599
2621
  }
2622
+ /** @private */
2600
2623
  _remove(id) {
2601
2624
  var _a;
2602
2625
  const server = this.cache.get(id);
@@ -2649,6 +2672,7 @@ var ServerManager = class extends BaseManager {
2649
2672
  var UserManager = class extends BaseManager {
2650
2673
  constructor() {
2651
2674
  super(...arguments);
2675
+ /** @private */
2652
2676
  this.holds = User;
2653
2677
  }
2654
2678
  /**
@@ -2692,6 +2716,7 @@ var MessageManager = class extends BaseManager {
2692
2716
  constructor(channel, maxSize = 1e3) {
2693
2717
  super(channel.client, maxSize);
2694
2718
  this.channel = channel;
2719
+ /** @private */
2695
2720
  this.holds = MessageStruct;
2696
2721
  }
2697
2722
  /**
@@ -2935,8 +2960,10 @@ var RoleManager = class extends BaseManager {
2935
2960
  constructor(server) {
2936
2961
  super(server.client);
2937
2962
  this.server = server;
2963
+ /** @private */
2938
2964
  this.holds = Role;
2939
2965
  }
2966
+ /** @private */
2940
2967
  _add(data) {
2941
2968
  const role = new Role(this.server, data);
2942
2969
  this.cache.set(role.id, role);
@@ -3008,8 +3035,10 @@ var ServerChannelManager = class extends BaseManager {
3008
3035
  constructor(server) {
3009
3036
  super(server.client);
3010
3037
  this.server = server;
3038
+ /** @private */
3011
3039
  this.holds = ServerChannel;
3012
3040
  }
3041
+ /** @private */
3013
3042
  _add(data) {
3014
3043
  let channel;
3015
3044
  switch (data.channel_type) {
@@ -3028,11 +3057,12 @@ var ServerChannelManager = class extends BaseManager {
3028
3057
  return channel;
3029
3058
  }
3030
3059
  /**
3031
- * creates a new channel in the server
3032
- * @param name The name of the channel to create
3033
- * @param type The type of the channel to create. Can be "Text" or "Voice". Defaults to "Text".
3034
- * @param description The description of the channel to create. Only used for voice channels.
3035
- * @returns A promise that resolves to the created channel
3060
+ * Creates a new channel in the server.
3061
+ * @param options - Options for creating the channel.
3062
+ * @param options.name - The name of the channel to create.
3063
+ * @param [options.type="Text"] - The type of the channel to create. Can be "Text" or "Voice". Defaults to "Text".
3064
+ * @param [options.description] - The description of the channel to create. Only used for voice channels.
3065
+ * @returns A promise that resolves to the created channel.
3036
3066
  */
3037
3067
  create(_0) {
3038
3068
  return __async(this, arguments, function* ({
@@ -3084,6 +3114,7 @@ var ServerMemberManager = class extends BaseManager {
3084
3114
  constructor(server) {
3085
3115
  super(server.client);
3086
3116
  this.server = server;
3117
+ /** @private */
3087
3118
  this.holds = ServerMember3;
3088
3119
  }
3089
3120
  /**
@@ -3199,7 +3230,7 @@ import { EventEmitter } from "node:events";
3199
3230
  import { AxiosError } from "axios";
3200
3231
 
3201
3232
  // package.json
3202
- var version = "0.1.8";
3233
+ var version = "0.1.10";
3203
3234
 
3204
3235
  // src/rest/restUtils/rateLimitQueue.ts
3205
3236
  import axios3 from "axios";
@@ -3297,7 +3328,7 @@ var RestClient = class {
3297
3328
  */
3298
3329
  request(method, url, body, query, retry) {
3299
3330
  return __async(this, null, function* () {
3300
- var _a, _b, _c;
3331
+ var _a, _b, _c, _d, _e;
3301
3332
  try {
3302
3333
  if (!this.client.token) throw new Error("Token is required");
3303
3334
  const authHeader = this.client.bot ? "X-Bot-Token" : "X-Session-Token";
@@ -3311,7 +3342,7 @@ var RestClient = class {
3311
3342
  "User-Agent": `RevBot.js/${version}`
3312
3343
  }
3313
3344
  }), {
3314
- url: `${apiUrl}${url}`
3345
+ url: `${((_c = this.client.options.rest) == null ? void 0 : _c.instanceURL) ? (_d = this.client.options.rest) == null ? void 0 : _d.instanceURL : apiUrl}${url}`
3315
3346
  });
3316
3347
  const response = yield this.rateLimitQueue.request(config);
3317
3348
  return response.data;
@@ -3323,7 +3354,7 @@ var RestClient = class {
3323
3354
  }
3324
3355
  if (error.status) {
3325
3356
  throw new Error(
3326
- `API call failed with status ${error.status}: ${(_c = error.response) == null ? void 0 : _c.statusText}`
3357
+ `API call failed with status ${error.status}: ${(_e = error.response) == null ? void 0 : _e.statusText}`
3327
3358
  );
3328
3359
  }
3329
3360
  }
@@ -3499,7 +3530,6 @@ var CDNClient = class {
3499
3530
  * POST request.
3500
3531
  * @param url The URL for the request.
3501
3532
  * @param data The request body.
3502
- * @param query Query parameters (if applicable).
3503
3533
  * @returns The API response.
3504
3534
  */
3505
3535
  post(url, data) {
@@ -3599,6 +3629,7 @@ var ChannelCreate = class extends Event {
3599
3629
  *
3600
3630
  * @param {API.Channel} data - The raw data for the created channel from the API.
3601
3631
  * @returns {Promise<{ channel: unknown }>} A promise that resolves with the created channel.
3632
+ * @private
3602
3633
  */
3603
3634
  handle(data) {
3604
3635
  return __async(this, null, function* () {
@@ -3739,6 +3770,7 @@ var Message = class extends Event {
3739
3770
  *
3740
3771
  * @param {API.Message} data - The raw data for the message from the API.
3741
3772
  * @returns {Promise<{ message: unknown }>} A promise that resolves with the created message, or an empty object if the channel is not text-based.
3773
+ * @private
3742
3774
  */
3743
3775
  handle(data) {
3744
3776
  return __async(this, null, function* () {
@@ -3808,6 +3840,7 @@ var ServerCreate = class extends Event {
3808
3840
  *
3809
3841
  * @param {API.Server} data - The raw data for the created server from the API.
3810
3842
  * @returns {Promise<void>} A promise that resolves when the server is added and members are optionally fetched.
3843
+ * @private
3811
3844
  */
3812
3845
  handle(data) {
3813
3846
  return __async(this, null, function* () {
@@ -4333,21 +4366,21 @@ var WebSocketClient = class {
4333
4366
  this.client.users._add(user);
4334
4367
  }
4335
4368
  }
4336
- for (const server of packet.servers) {
4337
- const s = this.client.servers._add(server);
4338
- if (this.client.options.fetchMembers) {
4339
- promises.push(s.members.fetch());
4340
- }
4341
- }
4342
- for (const channel of packet.channels) {
4343
- this.client.channels._add(channel);
4344
- }
4345
4369
  for (const member of packet.members) {
4346
4370
  (_a = this.client.servers.cache.get(member._id.server)) == null ? void 0 : _a.members._add(member);
4347
4371
  }
4348
4372
  for (const emoji of packet.emojis) {
4349
4373
  (_b = this.client.servers.cache.get(emoji.parent.id)) == null ? void 0 : _b.emojis.set(emoji._id, __spreadProps(__spreadValues({}, emoji), { _id: emoji._id }));
4350
4374
  }
4375
+ for (const channel of packet.channels) {
4376
+ this.client.channels._add(channel);
4377
+ }
4378
+ for (const server of packet.servers) {
4379
+ const s = this.client.servers._add(server);
4380
+ if (this.client.options.fetchMembers) {
4381
+ promises.push(s.members.fetch());
4382
+ }
4383
+ }
4351
4384
  this.setHeartbeatTimer(
4352
4385
  (_d = (_c = this.client.options.ws) == null ? void 0 : _c.heartbeatInterval) != null ? _d : 3e4
4353
4386
  );