@spatulox/simplediscordbot 2.0.0 → 2.0.2
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/CHANGELOG.md +3 -0
- package/README.md +4 -6
- package/dist/index.js +20 -5
- package/dist/index.mjs +23 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
Date format : dd/mm/yyy
|
|
3
3
|
|
|
4
|
+
### 08/04/2026 - 2.0.1
|
|
5
|
+
- Fix the README.md to match the new BotLog system
|
|
6
|
+
|
|
4
7
|
### 08/04/2026 - 2.0.0
|
|
5
8
|
- GuildManager.find now seach in cache then fetch. Now can return Guild | null
|
|
6
9
|
- BotLog now have separate channelId for each log type
|
package/README.md
CHANGED
|
@@ -40,12 +40,10 @@ const config: BotConfig = {
|
|
|
40
40
|
defaultSimpleColor: SimpleColor.blue,
|
|
41
41
|
botName: "Simple Discord Bot",
|
|
42
42
|
log: {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
warn: { console: true, discord: true },
|
|
48
|
-
debug: { console: true, discord: false }
|
|
43
|
+
info: {channelId: "YOUR_LOG_CHANNEL_ID", console: true, discord: true},
|
|
44
|
+
error: {channelId: "YOUR_LOG_CHANNEL_ID", console: true, discord: true},
|
|
45
|
+
warn: {channelId: "YOUR_LOG_CHANNEL_ID", console: true, discord: true},
|
|
46
|
+
debug: {channelId: "YOUR_LOG_CHANNEL_ID", console: true, discord: false},
|
|
49
47
|
}
|
|
50
48
|
};
|
|
51
49
|
|
package/dist/index.js
CHANGED
|
@@ -14561,8 +14561,11 @@ var WebhookManager = class {
|
|
|
14561
14561
|
*/
|
|
14562
14562
|
async getTextChannel(channelId) {
|
|
14563
14563
|
const channel = await this.client.channels.fetch(channelId);
|
|
14564
|
-
if (!channel
|
|
14565
|
-
throw new Error(`Channel ${channelId}
|
|
14564
|
+
if (!channel) {
|
|
14565
|
+
throw new Error(`Channel ${channelId} not found`);
|
|
14566
|
+
}
|
|
14567
|
+
if (!(channel instanceof import_discord7.TextChannel) && !(channel instanceof import_discord7.ThreadChannel)) {
|
|
14568
|
+
throw new Error(`Channel ${channelId} is not a TextChannel nor a ThreadChannel`);
|
|
14566
14569
|
}
|
|
14567
14570
|
return channel;
|
|
14568
14571
|
}
|
|
@@ -14572,9 +14575,21 @@ var WebhookManager = class {
|
|
|
14572
14575
|
async getWebhook(channelId) {
|
|
14573
14576
|
if (this.webhook) return this.webhook;
|
|
14574
14577
|
try {
|
|
14575
|
-
const
|
|
14578
|
+
const textThreadChannel = await this.getTextChannel(channelId);
|
|
14579
|
+
let textChannel;
|
|
14580
|
+
if (textThreadChannel instanceof import_discord7.ThreadChannel) {
|
|
14581
|
+
const parent = textThreadChannel.parent;
|
|
14582
|
+
if (!parent || !(parent instanceof import_discord7.BaseGuildTextChannel)) {
|
|
14583
|
+
throw new Error("Targeted channel parent is not a BaseGuildTextChannel");
|
|
14584
|
+
}
|
|
14585
|
+
textChannel = parent;
|
|
14586
|
+
} else {
|
|
14587
|
+
textChannel = textThreadChannel;
|
|
14588
|
+
}
|
|
14576
14589
|
const webhooks = await textChannel.fetchWebhooks();
|
|
14577
|
-
this.webhook = webhooks.find(
|
|
14590
|
+
this.webhook = webhooks.find(
|
|
14591
|
+
(h3) => h3.name === this.name && h3.owner?.id === this.client.user?.id
|
|
14592
|
+
) ?? await textChannel.createWebhook({
|
|
14578
14593
|
name: this.name,
|
|
14579
14594
|
avatar: await this.getAvatar(),
|
|
14580
14595
|
reason: "Auto-created by WebhookManager"
|
|
@@ -16132,7 +16147,7 @@ var SimpleMutex = class {
|
|
|
16132
16147
|
// package.json
|
|
16133
16148
|
var package_default = {
|
|
16134
16149
|
name: "@spatulox/simplediscordbot",
|
|
16135
|
-
version: "
|
|
16150
|
+
version: "2.0.1",
|
|
16136
16151
|
author: "Spatulox",
|
|
16137
16152
|
description: "Simple discord bot framework to set up a bot under 30 secondes",
|
|
16138
16153
|
exports: {
|
package/dist/index.mjs
CHANGED
|
@@ -14528,7 +14528,9 @@ var FileManager = class {
|
|
|
14528
14528
|
|
|
14529
14529
|
// src/manager/messages/WebhookManager.ts
|
|
14530
14530
|
import {
|
|
14531
|
-
|
|
14531
|
+
BaseGuildTextChannel,
|
|
14532
|
+
TextChannel as TextChannel3,
|
|
14533
|
+
ThreadChannel as ThreadChannel2
|
|
14532
14534
|
} from "discord.js";
|
|
14533
14535
|
import { readFile } from "fs/promises";
|
|
14534
14536
|
import { resolve } from "path";
|
|
@@ -14557,8 +14559,11 @@ var WebhookManager = class {
|
|
|
14557
14559
|
*/
|
|
14558
14560
|
async getTextChannel(channelId) {
|
|
14559
14561
|
const channel = await this.client.channels.fetch(channelId);
|
|
14560
|
-
if (!channel
|
|
14561
|
-
throw new Error(`Channel ${channelId}
|
|
14562
|
+
if (!channel) {
|
|
14563
|
+
throw new Error(`Channel ${channelId} not found`);
|
|
14564
|
+
}
|
|
14565
|
+
if (!(channel instanceof TextChannel3) && !(channel instanceof ThreadChannel2)) {
|
|
14566
|
+
throw new Error(`Channel ${channelId} is not a TextChannel nor a ThreadChannel`);
|
|
14562
14567
|
}
|
|
14563
14568
|
return channel;
|
|
14564
14569
|
}
|
|
@@ -14568,9 +14573,21 @@ var WebhookManager = class {
|
|
|
14568
14573
|
async getWebhook(channelId) {
|
|
14569
14574
|
if (this.webhook) return this.webhook;
|
|
14570
14575
|
try {
|
|
14571
|
-
const
|
|
14576
|
+
const textThreadChannel = await this.getTextChannel(channelId);
|
|
14577
|
+
let textChannel;
|
|
14578
|
+
if (textThreadChannel instanceof ThreadChannel2) {
|
|
14579
|
+
const parent = textThreadChannel.parent;
|
|
14580
|
+
if (!parent || !(parent instanceof BaseGuildTextChannel)) {
|
|
14581
|
+
throw new Error("Targeted channel parent is not a BaseGuildTextChannel");
|
|
14582
|
+
}
|
|
14583
|
+
textChannel = parent;
|
|
14584
|
+
} else {
|
|
14585
|
+
textChannel = textThreadChannel;
|
|
14586
|
+
}
|
|
14572
14587
|
const webhooks = await textChannel.fetchWebhooks();
|
|
14573
|
-
this.webhook = webhooks.find(
|
|
14588
|
+
this.webhook = webhooks.find(
|
|
14589
|
+
(h3) => h3.name === this.name && h3.owner?.id === this.client.user?.id
|
|
14590
|
+
) ?? await textChannel.createWebhook({
|
|
14574
14591
|
name: this.name,
|
|
14575
14592
|
avatar: await this.getAvatar(),
|
|
14576
14593
|
reason: "Auto-created by WebhookManager"
|
|
@@ -16151,7 +16168,7 @@ var SimpleMutex = class {
|
|
|
16151
16168
|
// package.json
|
|
16152
16169
|
var package_default = {
|
|
16153
16170
|
name: "@spatulox/simplediscordbot",
|
|
16154
|
-
version: "
|
|
16171
|
+
version: "2.0.1",
|
|
16155
16172
|
author: "Spatulox",
|
|
16156
16173
|
description: "Simple discord bot framework to set up a bot under 30 secondes",
|
|
16157
16174
|
exports: {
|