@spatulox/simplediscordbot 2.0.2 → 2.0.3

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.d.mts CHANGED
@@ -264,9 +264,10 @@ declare class WebhookManager {
264
264
  /**
265
265
  * Récupère le channel à partir de l'ID ou utilise directement si TextChannel/ThreadChannel
266
266
  */
267
- private getTextChannel;
267
+ private getChannel;
268
268
  /**
269
269
  * Get or create webhook (lazy initialization)
270
+ * Create the webhook in the parent channel if it's in a thread
270
271
  */
271
272
  private getWebhook;
272
273
  /**
package/dist/index.d.ts CHANGED
@@ -264,9 +264,10 @@ declare class WebhookManager {
264
264
  /**
265
265
  * Récupère le channel à partir de l'ID ou utilise directement si TextChannel/ThreadChannel
266
266
  */
267
- private getTextChannel;
267
+ private getChannel;
268
268
  /**
269
269
  * Get or create webhook (lazy initialization)
270
+ * Create the webhook in the parent channel if it's in a thread
270
271
  */
271
272
  private getWebhook;
272
273
  /**
package/dist/index.js CHANGED
@@ -14559,7 +14559,7 @@ var WebhookManager = class {
14559
14559
  /**
14560
14560
  * Récupère le channel à partir de l'ID ou utilise directement si TextChannel/ThreadChannel
14561
14561
  */
14562
- async getTextChannel(channelId) {
14562
+ async getChannel(channelId) {
14563
14563
  const channel = await this.client.channels.fetch(channelId);
14564
14564
  if (!channel) {
14565
14565
  throw new Error(`Channel ${channelId} not found`);
@@ -14571,16 +14571,17 @@ var WebhookManager = class {
14571
14571
  }
14572
14572
  /**
14573
14573
  * Get or create webhook (lazy initialization)
14574
+ * Create the webhook in the parent channel if it's in a thread
14574
14575
  */
14575
14576
  async getWebhook(channelId) {
14576
14577
  if (this.webhook) return this.webhook;
14577
14578
  try {
14578
- const textThreadChannel = await this.getTextChannel(channelId);
14579
+ const textThreadChannel = await this.getChannel(channelId);
14579
14580
  let textChannel;
14580
14581
  if (textThreadChannel instanceof import_discord7.ThreadChannel) {
14581
14582
  const parent = textThreadChannel.parent;
14582
- if (!parent || !(parent instanceof import_discord7.BaseGuildTextChannel)) {
14583
- throw new Error("Targeted channel parent is not a BaseGuildTextChannel");
14583
+ if (!parent || !(parent instanceof import_discord7.BaseGuildTextChannel) && !(parent instanceof import_discord7.ThreadOnlyChannel)) {
14584
+ throw new Error("Targeted channel parent is not a BaseGuildTextChannel or ThreadOnlyChannel");
14584
14585
  }
14585
14586
  textChannel = parent;
14586
14587
  } else {
@@ -14613,6 +14614,10 @@ var WebhookManager = class {
14613
14614
  } else {
14614
14615
  options.content = String(content);
14615
14616
  }
14617
+ const channelType = await this.getChannel(channelId);
14618
+ if (channelType instanceof import_discord7.ThreadChannel) {
14619
+ options.threadId = channelId;
14620
+ }
14616
14621
  try {
14617
14622
  return await webhook.send(options);
14618
14623
  } catch (error) {
@@ -16147,7 +16152,7 @@ var SimpleMutex = class {
16147
16152
  // package.json
16148
16153
  var package_default = {
16149
16154
  name: "@spatulox/simplediscordbot",
16150
- version: "2.0.1",
16155
+ version: "2.0.2",
16151
16156
  author: "Spatulox",
16152
16157
  description: "Simple discord bot framework to set up a bot under 30 secondes",
16153
16158
  exports: {
package/dist/index.mjs CHANGED
@@ -14530,7 +14530,8 @@ var FileManager = class {
14530
14530
  import {
14531
14531
  BaseGuildTextChannel,
14532
14532
  TextChannel as TextChannel3,
14533
- ThreadChannel as ThreadChannel2
14533
+ ThreadChannel as ThreadChannel2,
14534
+ ThreadOnlyChannel
14534
14535
  } from "discord.js";
14535
14536
  import { readFile } from "fs/promises";
14536
14537
  import { resolve } from "path";
@@ -14557,7 +14558,7 @@ var WebhookManager = class {
14557
14558
  /**
14558
14559
  * Récupère le channel à partir de l'ID ou utilise directement si TextChannel/ThreadChannel
14559
14560
  */
14560
- async getTextChannel(channelId) {
14561
+ async getChannel(channelId) {
14561
14562
  const channel = await this.client.channels.fetch(channelId);
14562
14563
  if (!channel) {
14563
14564
  throw new Error(`Channel ${channelId} not found`);
@@ -14569,16 +14570,17 @@ var WebhookManager = class {
14569
14570
  }
14570
14571
  /**
14571
14572
  * Get or create webhook (lazy initialization)
14573
+ * Create the webhook in the parent channel if it's in a thread
14572
14574
  */
14573
14575
  async getWebhook(channelId) {
14574
14576
  if (this.webhook) return this.webhook;
14575
14577
  try {
14576
- const textThreadChannel = await this.getTextChannel(channelId);
14578
+ const textThreadChannel = await this.getChannel(channelId);
14577
14579
  let textChannel;
14578
14580
  if (textThreadChannel instanceof ThreadChannel2) {
14579
14581
  const parent = textThreadChannel.parent;
14580
- if (!parent || !(parent instanceof BaseGuildTextChannel)) {
14581
- throw new Error("Targeted channel parent is not a BaseGuildTextChannel");
14582
+ if (!parent || !(parent instanceof BaseGuildTextChannel) && !(parent instanceof ThreadOnlyChannel)) {
14583
+ throw new Error("Targeted channel parent is not a BaseGuildTextChannel or ThreadOnlyChannel");
14582
14584
  }
14583
14585
  textChannel = parent;
14584
14586
  } else {
@@ -14611,6 +14613,10 @@ var WebhookManager = class {
14611
14613
  } else {
14612
14614
  options.content = String(content);
14613
14615
  }
14616
+ const channelType = await this.getChannel(channelId);
14617
+ if (channelType instanceof ThreadChannel2) {
14618
+ options.threadId = channelId;
14619
+ }
14614
14620
  try {
14615
14621
  return await webhook.send(options);
14616
14622
  } catch (error) {
@@ -16168,7 +16174,7 @@ var SimpleMutex = class {
16168
16174
  // package.json
16169
16175
  var package_default = {
16170
16176
  name: "@spatulox/simplediscordbot",
16171
- version: "2.0.1",
16177
+ version: "2.0.2",
16172
16178
  author: "Spatulox",
16173
16179
  description: "Simple discord bot framework to set up a bot under 30 secondes",
16174
16180
  exports: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spatulox/simplediscordbot",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "author": "Spatulox",
5
5
  "description": "Simple discord bot framework to set up a bot under 30 secondes",
6
6
  "exports": {