@spatulox/simplediscordbot 1.0.34 → 1.0.35
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/.env.HDFR_dev +3 -0
- package/.env.SpatuloxTest +3 -0
- package/README.md +6 -1
- package/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +147 -125
- package/dist/index.mjs +118 -94
- package/package.json +8 -2
package/dist/index.js
CHANGED
|
@@ -361,10 +361,10 @@ var _BotLog = class _BotLog {
|
|
|
361
361
|
if (logCh?.isTextBased()) {
|
|
362
362
|
_BotLog.logChannel = logCh;
|
|
363
363
|
} else {
|
|
364
|
-
Log.warn(
|
|
364
|
+
Log.warn(`Log channel ${Bot.config.log.logChannelId} invalid`);
|
|
365
365
|
}
|
|
366
366
|
} catch (error) {
|
|
367
|
-
Log.error(
|
|
367
|
+
Log.error(`Log channel fetch failed: ${error}`);
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
370
|
if (Bot.config.log?.errorChannelId) {
|
|
@@ -373,10 +373,10 @@ var _BotLog = class _BotLog {
|
|
|
373
373
|
if (errorCh?.isTextBased()) {
|
|
374
374
|
_BotLog.errorChannel = errorCh;
|
|
375
375
|
} else {
|
|
376
|
-
Log.warn(
|
|
376
|
+
Log.warn(`Error channel ${Bot.config.log.errorChannelId} invalid`);
|
|
377
377
|
}
|
|
378
378
|
} catch (error) {
|
|
379
|
-
Log.error(
|
|
379
|
+
Log.error(`Error channel fetch failed: ${error}`);
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
382
|
}
|
|
@@ -388,10 +388,16 @@ var _BotLog = class _BotLog {
|
|
|
388
388
|
let msg;
|
|
389
389
|
try {
|
|
390
390
|
if (content instanceof import_discord.EmbedBuilder) {
|
|
391
|
+
const text = content.data.description ?? content.data.title;
|
|
392
|
+
if (text) {
|
|
393
|
+
Log.info(text);
|
|
394
|
+
}
|
|
391
395
|
msg = await channel.send({ embeds: [content] });
|
|
396
|
+
} else if (content instanceof import_discord.ActionRowBuilder) {
|
|
397
|
+
msg = await channel.send({ components: [content] });
|
|
392
398
|
} else {
|
|
393
399
|
const timestamp = `\`${(/* @__PURE__ */ new Date()).toISOString()}\``;
|
|
394
|
-
msg = await channel.send(
|
|
400
|
+
msg = await channel.send(`[${timestamp}] [${prefix.toUpperCase()}] ${content}`);
|
|
395
401
|
}
|
|
396
402
|
} catch (error) {
|
|
397
403
|
Log.error(`Failed to send to Discord channel: ${error}`);
|
|
@@ -404,7 +410,7 @@ var _BotLog = class _BotLog {
|
|
|
404
410
|
static async info(content) {
|
|
405
411
|
const logConfig = Bot.config.log;
|
|
406
412
|
if (!logConfig || logConfig.info.console) {
|
|
407
|
-
if (
|
|
413
|
+
if (typeof content == "string") {
|
|
408
414
|
Log.info(content);
|
|
409
415
|
}
|
|
410
416
|
}
|
|
@@ -418,7 +424,7 @@ var _BotLog = class _BotLog {
|
|
|
418
424
|
static async error(content) {
|
|
419
425
|
const logConfig = Bot.config.log;
|
|
420
426
|
if (!logConfig || logConfig.error.console) {
|
|
421
|
-
if (
|
|
427
|
+
if (typeof content == "string") {
|
|
422
428
|
Log.error(content);
|
|
423
429
|
}
|
|
424
430
|
}
|
|
@@ -432,7 +438,7 @@ var _BotLog = class _BotLog {
|
|
|
432
438
|
static async warn(content) {
|
|
433
439
|
const logConfig = Bot.config.log;
|
|
434
440
|
if (!logConfig || logConfig?.warn.console) {
|
|
435
|
-
if (
|
|
441
|
+
if (typeof content == "string") {
|
|
436
442
|
Log.warn(content);
|
|
437
443
|
}
|
|
438
444
|
}
|
|
@@ -446,7 +452,7 @@ var _BotLog = class _BotLog {
|
|
|
446
452
|
static async debug(content) {
|
|
447
453
|
const logConfig = Bot.config.log;
|
|
448
454
|
if (!logConfig || logConfig?.debug.console) {
|
|
449
|
-
if (
|
|
455
|
+
if (typeof content == "string") {
|
|
450
456
|
Log.debug(content);
|
|
451
457
|
}
|
|
452
458
|
}
|
|
@@ -502,7 +508,8 @@ var EmbedColor = /* @__PURE__ */ ((EmbedColor3) => {
|
|
|
502
508
|
})(EmbedColor || {});
|
|
503
509
|
var EmbedManager = class {
|
|
504
510
|
static get BOT_ICON() {
|
|
505
|
-
|
|
511
|
+
if (Bot.config.botIconUrl) return Bot.config.botIconUrl;
|
|
512
|
+
return Bot.client?.user?.displayAvatarURL({ forceStatic: false, size: 128 }) || "";
|
|
506
513
|
}
|
|
507
514
|
static get DEFAULT_COLOR() {
|
|
508
515
|
return Bot.config.defaultEmbedColor || 6064856 /* default */;
|
|
@@ -512,11 +519,14 @@ var EmbedManager = class {
|
|
|
512
519
|
*/
|
|
513
520
|
static create(color = null) {
|
|
514
521
|
const embed = new import_discord2.EmbedBuilder().setColor(color ?? this.DEFAULT_COLOR).setTimestamp(/* @__PURE__ */ new Date());
|
|
515
|
-
if (
|
|
516
|
-
|
|
517
|
-
text: Bot.config.botName
|
|
518
|
-
|
|
519
|
-
|
|
522
|
+
if (Bot.config.botName) {
|
|
523
|
+
const footer = {
|
|
524
|
+
text: Bot.config.botName
|
|
525
|
+
};
|
|
526
|
+
if (this.BOT_ICON) {
|
|
527
|
+
footer.iconURL = this.BOT_ICON;
|
|
528
|
+
}
|
|
529
|
+
embed.setFooter(footer);
|
|
520
530
|
}
|
|
521
531
|
return embed;
|
|
522
532
|
}
|
|
@@ -524,7 +534,7 @@ var EmbedManager = class {
|
|
|
524
534
|
* Creates simple embed with just description
|
|
525
535
|
*/
|
|
526
536
|
static simple(description, color = null) {
|
|
527
|
-
return this.create(color).
|
|
537
|
+
return this.create(color).setDescription(description).setTimestamp(null);
|
|
528
538
|
}
|
|
529
539
|
/**
|
|
530
540
|
* Creates error embed
|
|
@@ -667,13 +677,13 @@ var BotMessage = class {
|
|
|
667
677
|
static async send(channel, content, component) {
|
|
668
678
|
try {
|
|
669
679
|
if (!channel) {
|
|
670
|
-
Log.warn("Cannot send message:
|
|
680
|
+
Log.warn("Cannot send message: Invalid channel ID");
|
|
671
681
|
return null;
|
|
672
682
|
}
|
|
673
683
|
if (typeof channel === "string") {
|
|
674
684
|
const fetchedChannel = Bot.client.channels.cache.get(channel);
|
|
675
685
|
if (!fetchedChannel?.isTextBased()) {
|
|
676
|
-
Log.warn(`Invalid channel ID: ${channel}`);
|
|
686
|
+
Log.warn(`Cannot send message : Invalid channel ID: ${channel}`);
|
|
677
687
|
return null;
|
|
678
688
|
}
|
|
679
689
|
channel = fetchedChannel;
|
|
@@ -694,7 +704,7 @@ var BotMessage = class {
|
|
|
694
704
|
} else if (component) {
|
|
695
705
|
messageCreate = SendableComponentBuilder.buildMessage(component);
|
|
696
706
|
} else {
|
|
697
|
-
throw new Error("content and component cannot be null at the same time");
|
|
707
|
+
throw new Error("Cannot send message : content and component cannot be null at the same time");
|
|
698
708
|
}
|
|
699
709
|
}
|
|
700
710
|
try {
|
|
@@ -703,7 +713,7 @@ var BotMessage = class {
|
|
|
703
713
|
throw e;
|
|
704
714
|
}
|
|
705
715
|
} catch (e) {
|
|
706
|
-
Log.error(`
|
|
716
|
+
Log.error(`Cannot send message : ${e}`);
|
|
707
717
|
return null;
|
|
708
718
|
}
|
|
709
719
|
}
|
|
@@ -723,11 +733,11 @@ var BotMessage = class {
|
|
|
723
733
|
} else if (component) {
|
|
724
734
|
messageCreate = SendableComponentBuilder.buildMessage(component);
|
|
725
735
|
} else {
|
|
726
|
-
throw new Error("content and component cannot be null at the same time");
|
|
736
|
+
throw new Error("Cannot send message : content and component cannot be null at the same time");
|
|
727
737
|
}
|
|
728
738
|
return await targetUser.send(messageCreate);
|
|
729
739
|
} catch (error) {
|
|
730
|
-
Log.error(`
|
|
740
|
+
Log.error(`Cannot send message to ${user}: ${error}`);
|
|
731
741
|
return null;
|
|
732
742
|
}
|
|
733
743
|
}
|
|
@@ -876,7 +886,7 @@ var BotEnv = {
|
|
|
876
886
|
return token;
|
|
877
887
|
},
|
|
878
888
|
get dev() {
|
|
879
|
-
return process.env.
|
|
889
|
+
return !!process.env.DISCORD_BOT_DEV;
|
|
880
890
|
},
|
|
881
891
|
get clientId() {
|
|
882
892
|
const token = process.env.DISCORD_BOT_CLIENTID;
|
|
@@ -1260,6 +1270,9 @@ var WebhookManager = class {
|
|
|
1260
1270
|
};
|
|
1261
1271
|
|
|
1262
1272
|
// src/manager/guild/ChannelManager/GuildTextChannelManager.ts
|
|
1273
|
+
var import_discord8 = require("discord.js");
|
|
1274
|
+
|
|
1275
|
+
// src/manager/guild/ChannelManager/GuildChannelManager.ts
|
|
1263
1276
|
var import_discord7 = require("discord.js");
|
|
1264
1277
|
|
|
1265
1278
|
// src/manager/guild/ChannelManager/GuildMessageManager.ts
|
|
@@ -1364,13 +1377,10 @@ var _GuildChannelManager = class _GuildChannelManager {
|
|
|
1364
1377
|
}
|
|
1365
1378
|
}
|
|
1366
1379
|
static async find(channelId) {
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
} catch {
|
|
1372
|
-
}
|
|
1373
|
-
}
|
|
1380
|
+
const cached = Bot.client.channels.cache.get(channelId);
|
|
1381
|
+
if (cached && cached instanceof import_discord7.GuildChannel) return cached;
|
|
1382
|
+
const channel = await Bot.client.channels.fetch(channelId);
|
|
1383
|
+
if (channel && channel instanceof import_discord7.GuildChannel) return channel;
|
|
1374
1384
|
Log.warn(`Channel ${channelId} not found in any guild`);
|
|
1375
1385
|
return null;
|
|
1376
1386
|
}
|
|
@@ -1443,12 +1453,12 @@ var GuildTextChannelManager = class extends GuildChannelManager {
|
|
|
1443
1453
|
Log.warn(`Guild ${guildId} not found`);
|
|
1444
1454
|
return [];
|
|
1445
1455
|
}
|
|
1446
|
-
return Array.from(guild.channels.cache.values()).filter((c) => c instanceof
|
|
1456
|
+
return Array.from(guild.channels.cache.values()).filter((c) => c instanceof import_discord8.TextChannel);
|
|
1447
1457
|
}
|
|
1448
1458
|
static async create(guildId, name, options) {
|
|
1449
1459
|
return await super._create(guildId, {
|
|
1450
1460
|
name,
|
|
1451
|
-
type:
|
|
1461
|
+
type: import_discord8.ChannelType.GuildText,
|
|
1452
1462
|
...options
|
|
1453
1463
|
});
|
|
1454
1464
|
}
|
|
@@ -1545,24 +1555,27 @@ var ReactionManager = class {
|
|
|
1545
1555
|
};
|
|
1546
1556
|
|
|
1547
1557
|
// src/manager/guild/GuildManager.ts
|
|
1548
|
-
var
|
|
1558
|
+
var import_discord15 = require("discord.js");
|
|
1549
1559
|
|
|
1550
1560
|
// src/manager/direct/BasicUserManager.ts
|
|
1551
|
-
var
|
|
1561
|
+
var import_discord9 = require("discord.js");
|
|
1552
1562
|
var BasicUserManager = class {
|
|
1553
1563
|
/**
|
|
1554
1564
|
* Find member in specific guild
|
|
1555
1565
|
*/
|
|
1556
|
-
static async findInGuild(
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
Log.error(`UserManager: Member ${memberId} not found in ${guildId}`);
|
|
1564
|
-
return null;
|
|
1566
|
+
static async findInGuild(guild, memberId) {
|
|
1567
|
+
let targetGuild = null;
|
|
1568
|
+
if (typeof guild === "string") {
|
|
1569
|
+
targetGuild = await GuildManager.find(guild);
|
|
1570
|
+
if (!targetGuild) return null;
|
|
1571
|
+
} else {
|
|
1572
|
+
targetGuild = guild;
|
|
1565
1573
|
}
|
|
1574
|
+
const cached = targetGuild.members.cache.get(memberId);
|
|
1575
|
+
if (cached) return cached;
|
|
1576
|
+
const member = await targetGuild.members.fetch(memberId).catch(() => null);
|
|
1577
|
+
if (!member) Log.error(`UserManager: Member ${memberId} not found in guild ${targetGuild.id}`);
|
|
1578
|
+
return member;
|
|
1566
1579
|
}
|
|
1567
1580
|
/**
|
|
1568
1581
|
* Check if user is still in guild
|
|
@@ -1603,7 +1616,7 @@ var BasicUserManager = class {
|
|
|
1603
1616
|
payload = content_or_component_or_options;
|
|
1604
1617
|
}
|
|
1605
1618
|
const message = await dmChannel.send(payload);
|
|
1606
|
-
if (user instanceof
|
|
1619
|
+
if (user instanceof import_discord9.GuildMember) {
|
|
1607
1620
|
Log.info(`Sent DM to ${user.id} (${user.user.username}): "${(payload.content || "Embed/Component").substring(0, 50)}..."`);
|
|
1608
1621
|
} else {
|
|
1609
1622
|
Log.info(`Sent DM to ${user.id} (${user.username}): "${(payload.content || "Embed/Component").substring(0, 50)}..."`);
|
|
@@ -1617,13 +1630,13 @@ var BasicUserManager = class {
|
|
|
1617
1630
|
};
|
|
1618
1631
|
|
|
1619
1632
|
// src/manager/guild/GuildUserManager.ts
|
|
1620
|
-
var
|
|
1633
|
+
var import_discord10 = require("discord.js");
|
|
1621
1634
|
var import_promises2 = require("timers/promises");
|
|
1622
1635
|
var MAX_NICKNAME_LENGTH = 32;
|
|
1623
1636
|
var GuildUserManager = class extends BasicUserManager {
|
|
1624
1637
|
static async find(userId, guild) {
|
|
1625
1638
|
try {
|
|
1626
|
-
if (guild instanceof
|
|
1639
|
+
if (guild instanceof import_discord10.Guild) {
|
|
1627
1640
|
return await guild.members.fetch(userId);
|
|
1628
1641
|
} else {
|
|
1629
1642
|
return await (await GuildManager.find(guild)).members.fetch(userId);
|
|
@@ -1657,7 +1670,7 @@ var GuildUserManager = class extends BasicUserManager {
|
|
|
1657
1670
|
*/
|
|
1658
1671
|
static async isBanned(guildId, userId) {
|
|
1659
1672
|
try {
|
|
1660
|
-
const guild =
|
|
1673
|
+
const guild = await GuildManager.find(guildId);
|
|
1661
1674
|
if (!guild) {
|
|
1662
1675
|
Log.warn(`Guild ${guildId} not found`);
|
|
1663
1676
|
return false;
|
|
@@ -1674,13 +1687,9 @@ var GuildUserManager = class extends BasicUserManager {
|
|
|
1674
1687
|
*/
|
|
1675
1688
|
static async deconnectFromVoice(guildId, memberId) {
|
|
1676
1689
|
try {
|
|
1677
|
-
const
|
|
1678
|
-
if (!
|
|
1679
|
-
throw new Error(`
|
|
1680
|
-
}
|
|
1681
|
-
const member = await guild.members.fetch(memberId);
|
|
1682
|
-
if (!member.voice.channel) {
|
|
1683
|
-
throw new Error(`Member ${memberId} is not in a voice channel`);
|
|
1690
|
+
const member = await GuildManager.user.findInGuild(guildId, memberId);
|
|
1691
|
+
if (!member || !member.voice.channel) {
|
|
1692
|
+
throw new Error(`Member ${memberId} not found or not in a voice channel`);
|
|
1684
1693
|
}
|
|
1685
1694
|
await member.voice.disconnect();
|
|
1686
1695
|
Log.info(`Disconnected member ${memberId} from voice in guild ${guildId}`);
|
|
@@ -1694,9 +1703,10 @@ var GuildUserManager = class extends BasicUserManager {
|
|
|
1694
1703
|
*/
|
|
1695
1704
|
static async isInVoice(memberId, guildId) {
|
|
1696
1705
|
try {
|
|
1697
|
-
const
|
|
1698
|
-
if (!
|
|
1699
|
-
|
|
1706
|
+
const member = await GuildManager.user.findInGuild(guildId, memberId);
|
|
1707
|
+
if (!member) {
|
|
1708
|
+
throw new Error(`User ${guildId} not found`);
|
|
1709
|
+
}
|
|
1700
1710
|
return member.voice.channelId !== null;
|
|
1701
1711
|
} catch (error) {
|
|
1702
1712
|
Log.debug(`Member ${memberId} not found or not in voice in guild ${guildId}`);
|
|
@@ -1708,9 +1718,10 @@ var GuildUserManager = class extends BasicUserManager {
|
|
|
1708
1718
|
*/
|
|
1709
1719
|
static async mute(guildId, memberId, reason) {
|
|
1710
1720
|
try {
|
|
1711
|
-
const
|
|
1712
|
-
if (!
|
|
1713
|
-
|
|
1721
|
+
const member = await GuildManager.user.findInGuild(guildId, memberId);
|
|
1722
|
+
if (!member) {
|
|
1723
|
+
throw new Error(`User ${guildId} not found`);
|
|
1724
|
+
}
|
|
1714
1725
|
await member.voice.setMute(true, reason);
|
|
1715
1726
|
Log.info(`Server muted ${memberId} in guild ${guildId}: ${reason || "No reason"}`);
|
|
1716
1727
|
} catch (error) {
|
|
@@ -1723,9 +1734,10 @@ var GuildUserManager = class extends BasicUserManager {
|
|
|
1723
1734
|
*/
|
|
1724
1735
|
static async unmute(guildId, memberId, reason) {
|
|
1725
1736
|
try {
|
|
1726
|
-
const
|
|
1727
|
-
if (!
|
|
1728
|
-
|
|
1737
|
+
const member = await GuildManager.user.findInGuild(guildId, memberId);
|
|
1738
|
+
if (!member) {
|
|
1739
|
+
throw new Error(`User ${guildId} not found`);
|
|
1740
|
+
}
|
|
1729
1741
|
await member.voice.setMute(false, reason);
|
|
1730
1742
|
Log.info(`Server unmuted ${memberId} in guild ${guildId}: ${reason || "No reason"}`);
|
|
1731
1743
|
} catch (error) {
|
|
@@ -1738,9 +1750,10 @@ var GuildUserManager = class extends BasicUserManager {
|
|
|
1738
1750
|
*/
|
|
1739
1751
|
static async deafen(guildId, memberId, reason) {
|
|
1740
1752
|
try {
|
|
1741
|
-
const
|
|
1742
|
-
if (!
|
|
1743
|
-
|
|
1753
|
+
const member = await GuildManager.user.findInGuild(guildId, memberId);
|
|
1754
|
+
if (!member) {
|
|
1755
|
+
throw new Error(`User ${guildId} not found`);
|
|
1756
|
+
}
|
|
1744
1757
|
await member.voice.setDeaf(true, reason);
|
|
1745
1758
|
Log.info(`Server deafened ${memberId} in guild ${guildId}: ${reason || "No reason"}`);
|
|
1746
1759
|
} catch (error) {
|
|
@@ -1753,9 +1766,10 @@ var GuildUserManager = class extends BasicUserManager {
|
|
|
1753
1766
|
*/
|
|
1754
1767
|
static async undeafen(guildId, memberId, reason) {
|
|
1755
1768
|
try {
|
|
1756
|
-
const
|
|
1757
|
-
if (!
|
|
1758
|
-
|
|
1769
|
+
const member = await GuildManager.user.findInGuild(guildId, memberId);
|
|
1770
|
+
if (!member) {
|
|
1771
|
+
throw new Error(`User ${guildId} not found`);
|
|
1772
|
+
}
|
|
1759
1773
|
await member.voice.setDeaf(false, reason);
|
|
1760
1774
|
Log.info(`Server undeafened ${memberId} in guild ${guildId}: ${reason || "No reason"}`);
|
|
1761
1775
|
} catch (error) {
|
|
@@ -1768,9 +1782,10 @@ var GuildUserManager = class extends BasicUserManager {
|
|
|
1768
1782
|
*/
|
|
1769
1783
|
static async timeout(guildId, memberId, duration, reason) {
|
|
1770
1784
|
try {
|
|
1771
|
-
const
|
|
1772
|
-
if (!
|
|
1773
|
-
|
|
1785
|
+
const member = await GuildManager.user.findInGuild(guildId, memberId);
|
|
1786
|
+
if (!member) {
|
|
1787
|
+
throw new Error(`User ${guildId} not found`);
|
|
1788
|
+
}
|
|
1774
1789
|
const expires = Date.now() + duration;
|
|
1775
1790
|
await member.timeout(expires, reason);
|
|
1776
1791
|
Log.info(`Timed out ${memberId} for ${duration}ms in guild ${guildId}: ${reason || "No reason"}`);
|
|
@@ -1784,9 +1799,10 @@ var GuildUserManager = class extends BasicUserManager {
|
|
|
1784
1799
|
*/
|
|
1785
1800
|
static async untimeout(guildId, memberId, reason) {
|
|
1786
1801
|
try {
|
|
1787
|
-
const
|
|
1788
|
-
if (!
|
|
1789
|
-
|
|
1802
|
+
const member = await GuildManager.user.findInGuild(guildId, memberId);
|
|
1803
|
+
if (!member) {
|
|
1804
|
+
throw new Error(`User ${guildId} not found`);
|
|
1805
|
+
}
|
|
1790
1806
|
await member.timeout(null, reason);
|
|
1791
1807
|
Log.info(`Untimed out ${memberId} in guild ${guildId}: ${reason || "No reason"}`);
|
|
1792
1808
|
} catch (error) {
|
|
@@ -1799,9 +1815,10 @@ var GuildUserManager = class extends BasicUserManager {
|
|
|
1799
1815
|
*/
|
|
1800
1816
|
static async kick(guildId, memberId, reason) {
|
|
1801
1817
|
try {
|
|
1802
|
-
const
|
|
1803
|
-
if (!
|
|
1804
|
-
|
|
1818
|
+
const member = await GuildManager.user.findInGuild(guildId, memberId);
|
|
1819
|
+
if (!member) {
|
|
1820
|
+
throw new Error(`User ${guildId} not found`);
|
|
1821
|
+
}
|
|
1805
1822
|
await member.kick(reason);
|
|
1806
1823
|
Log.info(`Kicked ${memberId} from guild ${guildId}: ${reason || "No reason"}`);
|
|
1807
1824
|
} catch (error) {
|
|
@@ -1810,7 +1827,7 @@ var GuildUserManager = class extends BasicUserManager {
|
|
|
1810
1827
|
}
|
|
1811
1828
|
}
|
|
1812
1829
|
static async ban(guildId, userId, banOption) {
|
|
1813
|
-
const guild =
|
|
1830
|
+
const guild = await GuildManager.find(guildId);
|
|
1814
1831
|
if (!guild) {
|
|
1815
1832
|
throw new Error(`Guild ${guildId} not found`);
|
|
1816
1833
|
}
|
|
@@ -1823,7 +1840,7 @@ var GuildUserManager = class extends BasicUserManager {
|
|
|
1823
1840
|
}
|
|
1824
1841
|
}
|
|
1825
1842
|
static async unban(guildId, userId, reason) {
|
|
1826
|
-
const guild =
|
|
1843
|
+
const guild = await GuildManager.find(guildId);
|
|
1827
1844
|
if (!guild) {
|
|
1828
1845
|
throw new Error(`Guild ${guildId} not found`);
|
|
1829
1846
|
}
|
|
@@ -1917,15 +1934,15 @@ var RoleManager = class {
|
|
|
1917
1934
|
};
|
|
1918
1935
|
|
|
1919
1936
|
// src/manager/guild/ChannelManager/ForumChannelManager.ts
|
|
1920
|
-
var
|
|
1937
|
+
var import_discord11 = require("discord.js");
|
|
1921
1938
|
var ForumChannelManager = class extends GuildChannelManager {
|
|
1922
1939
|
static async findInGuild(guildId, channelId) {
|
|
1923
1940
|
const channel = await super.findInGuild(guildId, channelId);
|
|
1924
|
-
return channel instanceof
|
|
1941
|
+
return channel instanceof import_discord11.ForumChannel ? channel : null;
|
|
1925
1942
|
}
|
|
1926
1943
|
static async find(channelId) {
|
|
1927
1944
|
const channel = await super.find(channelId);
|
|
1928
|
-
return channel instanceof
|
|
1945
|
+
return channel instanceof import_discord11.ForumChannel ? channel : null;
|
|
1929
1946
|
}
|
|
1930
1947
|
static findAll(guildId) {
|
|
1931
1948
|
const guild = Bot.client.guilds.cache.get(guildId);
|
|
@@ -1933,27 +1950,27 @@ var ForumChannelManager = class extends GuildChannelManager {
|
|
|
1933
1950
|
Log.warn(`Guild ${guildId} not found`);
|
|
1934
1951
|
return [];
|
|
1935
1952
|
}
|
|
1936
|
-
return Array.from(guild.channels.cache.values()).filter((c) => c instanceof
|
|
1953
|
+
return Array.from(guild.channels.cache.values()).filter((c) => c instanceof import_discord11.ForumChannel);
|
|
1937
1954
|
}
|
|
1938
1955
|
static async create(guildId, name, options) {
|
|
1939
1956
|
return await super._create(guildId, {
|
|
1940
1957
|
name,
|
|
1941
|
-
type:
|
|
1958
|
+
type: import_discord11.ChannelType.GuildForum,
|
|
1942
1959
|
...options
|
|
1943
1960
|
});
|
|
1944
1961
|
}
|
|
1945
1962
|
};
|
|
1946
1963
|
|
|
1947
1964
|
// src/manager/guild/ChannelManager/NewsChannelManager.ts
|
|
1948
|
-
var
|
|
1965
|
+
var import_discord12 = require("discord.js");
|
|
1949
1966
|
var NewsChannelManager = class extends GuildChannelManager {
|
|
1950
1967
|
static async findInGuild(guildId, channelId) {
|
|
1951
1968
|
const channel = await super.findInGuild(guildId, channelId);
|
|
1952
|
-
return channel instanceof
|
|
1969
|
+
return channel instanceof import_discord12.NewsChannel ? channel : null;
|
|
1953
1970
|
}
|
|
1954
1971
|
static async find(channelId) {
|
|
1955
1972
|
const channel = await super.find(channelId);
|
|
1956
|
-
return channel instanceof
|
|
1973
|
+
return channel instanceof import_discord12.NewsChannel ? channel : null;
|
|
1957
1974
|
}
|
|
1958
1975
|
static findAll(guildId) {
|
|
1959
1976
|
const guild = Bot.client.guilds.cache.get(guildId);
|
|
@@ -1961,27 +1978,27 @@ var NewsChannelManager = class extends GuildChannelManager {
|
|
|
1961
1978
|
Log.warn(`Guild ${guildId} not found`);
|
|
1962
1979
|
return [];
|
|
1963
1980
|
}
|
|
1964
|
-
return Array.from(guild.channels.cache.values()).filter((c) => c instanceof
|
|
1981
|
+
return Array.from(guild.channels.cache.values()).filter((c) => c instanceof import_discord12.NewsChannel);
|
|
1965
1982
|
}
|
|
1966
1983
|
static async create(guildId, name, options) {
|
|
1967
1984
|
return await super._create(guildId, {
|
|
1968
1985
|
name,
|
|
1969
|
-
type:
|
|
1986
|
+
type: import_discord12.ChannelType.GuildAnnouncement,
|
|
1970
1987
|
...options
|
|
1971
1988
|
});
|
|
1972
1989
|
}
|
|
1973
1990
|
};
|
|
1974
1991
|
|
|
1975
1992
|
// src/manager/guild/ChannelManager/StageChannelManager.ts
|
|
1976
|
-
var
|
|
1993
|
+
var import_discord13 = require("discord.js");
|
|
1977
1994
|
var StageChannelManager = class extends GuildChannelManager {
|
|
1978
1995
|
static async findInGuild(guildId, channelId) {
|
|
1979
1996
|
const channel = await super.findInGuild(guildId, channelId);
|
|
1980
|
-
return channel instanceof
|
|
1997
|
+
return channel instanceof import_discord13.StageChannel ? channel : null;
|
|
1981
1998
|
}
|
|
1982
1999
|
static async find(channelId) {
|
|
1983
2000
|
const channel = await super.find(channelId);
|
|
1984
|
-
return channel instanceof
|
|
2001
|
+
return channel instanceof import_discord13.StageChannel ? channel : null;
|
|
1985
2002
|
}
|
|
1986
2003
|
static findAll(guildId) {
|
|
1987
2004
|
const guild = Bot.client.guilds.cache.get(guildId);
|
|
@@ -1989,12 +2006,12 @@ var StageChannelManager = class extends GuildChannelManager {
|
|
|
1989
2006
|
Log.warn(`Guild ${guildId} not found`);
|
|
1990
2007
|
return [];
|
|
1991
2008
|
}
|
|
1992
|
-
return Array.from(guild.channels.cache.values()).filter((c) => c instanceof
|
|
2009
|
+
return Array.from(guild.channels.cache.values()).filter((c) => c instanceof import_discord13.StageChannel);
|
|
1993
2010
|
}
|
|
1994
2011
|
static async create(guildId, name, options) {
|
|
1995
2012
|
return await super._create(guildId, {
|
|
1996
2013
|
name,
|
|
1997
|
-
type:
|
|
2014
|
+
type: import_discord13.ChannelType.GuildStageVoice,
|
|
1998
2015
|
...options
|
|
1999
2016
|
});
|
|
2000
2017
|
}
|
|
@@ -2042,7 +2059,7 @@ var ThreadChannelManager = class {
|
|
|
2042
2059
|
};
|
|
2043
2060
|
|
|
2044
2061
|
// src/manager/guild/ChannelManager/GuildVoiceChannelManager.ts
|
|
2045
|
-
var
|
|
2062
|
+
var import_discord14 = require("discord.js");
|
|
2046
2063
|
var GuildVoiceChannelManager = class extends GuildChannelManager {
|
|
2047
2064
|
static async findInGuild(guildId, channelId) {
|
|
2048
2065
|
const channel = await super.findInGuild(guildId, channelId);
|
|
@@ -2058,12 +2075,12 @@ var GuildVoiceChannelManager = class extends GuildChannelManager {
|
|
|
2058
2075
|
Log.warn(`Guild ${guildId} not found`);
|
|
2059
2076
|
return [];
|
|
2060
2077
|
}
|
|
2061
|
-
return Array.from(guild.channels.cache.values()).filter((c) => c instanceof
|
|
2078
|
+
return Array.from(guild.channels.cache.values()).filter((c) => c instanceof import_discord14.VoiceChannel);
|
|
2062
2079
|
}
|
|
2063
2080
|
static async create(guildId, name, options) {
|
|
2064
2081
|
return await super._create(guildId, {
|
|
2065
2082
|
name,
|
|
2066
|
-
type:
|
|
2083
|
+
type: import_discord14.ChannelType.GuildVoice,
|
|
2067
2084
|
...options
|
|
2068
2085
|
});
|
|
2069
2086
|
}
|
|
@@ -2184,7 +2201,7 @@ var GuildManager = class {
|
|
|
2184
2201
|
*/
|
|
2185
2202
|
static async fetchAllMembers(guildId, MAX_ATTEMPTS = 3, RETRY_DELAY = Time.minute.MIN_05.toMilliseconds()) {
|
|
2186
2203
|
let guild;
|
|
2187
|
-
if (guildId instanceof
|
|
2204
|
+
if (guildId instanceof import_discord15.Guild) {
|
|
2188
2205
|
guild = guildId;
|
|
2189
2206
|
} else {
|
|
2190
2207
|
let tmp = Bot.client.guilds.cache.get(guildId);
|
|
@@ -2237,10 +2254,10 @@ var GuildManager = class {
|
|
|
2237
2254
|
if (!toChannel) {
|
|
2238
2255
|
throw new Error(`To channel ${toChannelId} not found`);
|
|
2239
2256
|
}
|
|
2240
|
-
if (!(fromChannel instanceof
|
|
2257
|
+
if (!(fromChannel instanceof import_discord15.VoiceChannel || fromChannel instanceof import_discord15.StageChannel)) {
|
|
2241
2258
|
throw new Error(`From channel ${fromChannelId} is not a voice/stage channel`);
|
|
2242
2259
|
}
|
|
2243
|
-
if (!(toChannel instanceof
|
|
2260
|
+
if (!(toChannel instanceof import_discord15.VoiceChannel || toChannel instanceof import_discord15.StageChannel)) {
|
|
2244
2261
|
throw new Error(`To channel ${toChannelId} is not a voice/stage channel`);
|
|
2245
2262
|
}
|
|
2246
2263
|
if (member.voice.channelId !== fromChannelId) {
|
|
@@ -2268,17 +2285,16 @@ GuildManager.invite = InviteManager;
|
|
|
2268
2285
|
// src/manager/direct/UserManager.ts
|
|
2269
2286
|
var UserManager = class extends BasicUserManager {
|
|
2270
2287
|
static async find(userId) {
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
}
|
|
2288
|
+
const cached = Bot.client.users.cache.get(userId);
|
|
2289
|
+
if (cached) return cached;
|
|
2290
|
+
const user = await Bot.client.users.fetch(userId).catch(() => null);
|
|
2291
|
+
if (!user) Log.error(`UserManager: User ${userId} not found`);
|
|
2292
|
+
return user;
|
|
2277
2293
|
}
|
|
2278
2294
|
};
|
|
2279
2295
|
|
|
2280
2296
|
// src/manager/interactions/ModalManager.ts
|
|
2281
|
-
var
|
|
2297
|
+
var import_discord16 = require("discord.js");
|
|
2282
2298
|
var ModalManager = class _ModalManager {
|
|
2283
2299
|
/**
|
|
2284
2300
|
* Load modal from JSON file and return ModalBuilder
|
|
@@ -2304,17 +2320,17 @@ var ModalManager = class _ModalManager {
|
|
|
2304
2320
|
}
|
|
2305
2321
|
}
|
|
2306
2322
|
static jsonToBuilder(json) {
|
|
2307
|
-
const modal = new
|
|
2323
|
+
const modal = new import_discord16.ModalBuilder().setCustomId(json.customId).setTitle(json.title.slice(0, 45));
|
|
2308
2324
|
const actionRows = [];
|
|
2309
2325
|
for (const fieldJson of json.fields) {
|
|
2310
2326
|
const input = this.fieldJsonToInput(fieldJson);
|
|
2311
|
-
const row = new
|
|
2327
|
+
const row = new import_discord16.ActionRowBuilder().addComponents(input);
|
|
2312
2328
|
actionRows.push(row);
|
|
2313
2329
|
}
|
|
2314
2330
|
return modal.addComponents(...actionRows);
|
|
2315
2331
|
}
|
|
2316
2332
|
static fieldJsonToInput(fieldJson) {
|
|
2317
|
-
const input = new
|
|
2333
|
+
const input = new import_discord16.TextInputBuilder().setCustomId(fieldJson.customId).setLabel(fieldJson.title.slice(0, 45)).setPlaceholder(fieldJson.placeholder || "Enter value...").setRequired(fieldJson.required !== false).setMinLength(fieldJson.minLength || 0).setMaxLength(fieldJson.maxLength || 400);
|
|
2318
2334
|
const style = fieldJson.style;
|
|
2319
2335
|
if (typeof style === "number") {
|
|
2320
2336
|
input.setStyle(style);
|
|
@@ -2323,13 +2339,13 @@ var ModalManager = class _ModalManager {
|
|
|
2323
2339
|
case "Number":
|
|
2324
2340
|
case "Phone":
|
|
2325
2341
|
case "Date":
|
|
2326
|
-
input.setStyle(
|
|
2342
|
+
input.setStyle(import_discord16.TextInputStyle.Short);
|
|
2327
2343
|
input.setPlaceholder(
|
|
2328
2344
|
style === "Number" ? "123" : style === "Phone" ? "+33 6 12 34 56 78" : "2024-02-05"
|
|
2329
2345
|
);
|
|
2330
2346
|
break;
|
|
2331
2347
|
default:
|
|
2332
|
-
input.setStyle(
|
|
2348
|
+
input.setStyle(import_discord16.TextInputStyle.Short);
|
|
2333
2349
|
}
|
|
2334
2350
|
}
|
|
2335
2351
|
return input;
|
|
@@ -2365,13 +2381,13 @@ var ModalManager = class _ModalManager {
|
|
|
2365
2381
|
};
|
|
2366
2382
|
|
|
2367
2383
|
// src/manager/interactions/SelectMenuManager.ts
|
|
2368
|
-
var
|
|
2384
|
+
var import_discord17 = require("discord.js");
|
|
2369
2385
|
var SelectMenuManager = class {
|
|
2370
2386
|
/**
|
|
2371
2387
|
* Creates base StringSelectMenu - SIMPLE API !
|
|
2372
2388
|
*/
|
|
2373
2389
|
static create(customId, placeholder = "Select an option...") {
|
|
2374
|
-
return new
|
|
2390
|
+
return new import_discord17.StringSelectMenuBuilder().setCustomId(customId).setPlaceholder(placeholder).setMinValues(1).setMaxValues(1);
|
|
2375
2391
|
}
|
|
2376
2392
|
/**
|
|
2377
2393
|
* Quick StringSelectMenu
|
|
@@ -2389,10 +2405,10 @@ var SelectMenuManager = class {
|
|
|
2389
2405
|
* Pagination menu
|
|
2390
2406
|
*/
|
|
2391
2407
|
static paginated(customId, options, pageSize = 25) {
|
|
2392
|
-
const row = new
|
|
2408
|
+
const row = new import_discord17.ActionRowBuilder();
|
|
2393
2409
|
for (let i = 0; i < options.length; i += pageSize) {
|
|
2394
2410
|
const pageOptions = options.slice(i, i + pageSize);
|
|
2395
|
-
const menu = new
|
|
2411
|
+
const menu = new import_discord17.StringSelectMenuBuilder().setCustomId(`${customId}_page_${Math.floor(i / pageSize)}`).setPlaceholder(`Page ${Math.floor(i / pageSize) + 1}`).addOptions(pageOptions.map((opt) => {
|
|
2396
2412
|
return this.option(opt);
|
|
2397
2413
|
}));
|
|
2398
2414
|
row.addComponents(menu);
|
|
@@ -2403,25 +2419,25 @@ var SelectMenuManager = class {
|
|
|
2403
2419
|
* User Select Menu (Components V2)
|
|
2404
2420
|
*/
|
|
2405
2421
|
static users(customId, placeholder = "Select users...") {
|
|
2406
|
-
return new
|
|
2422
|
+
return new import_discord17.UserSelectMenuBuilder().setCustomId(customId).setPlaceholder(placeholder).setMinValues(1).setMaxValues(25);
|
|
2407
2423
|
}
|
|
2408
2424
|
/**
|
|
2409
2425
|
* Role Select Menu (Components V2)
|
|
2410
2426
|
*/
|
|
2411
2427
|
static roles(customId, placeholder = "Select roles...") {
|
|
2412
|
-
return new
|
|
2428
|
+
return new import_discord17.RoleSelectMenuBuilder().setCustomId(customId).setPlaceholder(placeholder).setMinValues(1).setMaxValues(25);
|
|
2413
2429
|
}
|
|
2414
2430
|
/**
|
|
2415
2431
|
* Mentionable Select Menu (Components V2)
|
|
2416
2432
|
*/
|
|
2417
2433
|
static mentionables(customId, placeholder = "Select users/roles...") {
|
|
2418
|
-
return new
|
|
2434
|
+
return new import_discord17.MentionableSelectMenuBuilder().setCustomId(customId).setPlaceholder(placeholder).setMinValues(1).setMaxValues(25);
|
|
2419
2435
|
}
|
|
2420
2436
|
/**
|
|
2421
2437
|
* Channel Select Menu (Components V2)
|
|
2422
2438
|
*/
|
|
2423
2439
|
static channels(customId, placeholder = "Select channels...", channelTypes = []) {
|
|
2424
|
-
return new
|
|
2440
|
+
return new import_discord17.ChannelSelectMenuBuilder().setCustomId(customId).setPlaceholder(placeholder).setMinValues(1).setMaxValues(25).setChannelTypes(...channelTypes);
|
|
2425
2441
|
}
|
|
2426
2442
|
static option(option) {
|
|
2427
2443
|
if (Array.isArray(option)) {
|
|
@@ -2430,7 +2446,7 @@ var SelectMenuManager = class {
|
|
|
2430
2446
|
return this._createOption(option);
|
|
2431
2447
|
}
|
|
2432
2448
|
static _createOption(option) {
|
|
2433
|
-
const builder = new
|
|
2449
|
+
const builder = new import_discord17.StringSelectMenuOptionBuilder().setLabel(option.label).setValue(option.value);
|
|
2434
2450
|
option.description && builder.setDescription(option.description);
|
|
2435
2451
|
option.emoji && builder.setEmoji(option.emoji);
|
|
2436
2452
|
return builder;
|
|
@@ -2451,7 +2467,7 @@ var SelectMenuManager = class {
|
|
|
2451
2467
|
* ActionRow
|
|
2452
2468
|
*/
|
|
2453
2469
|
static row(component) {
|
|
2454
|
-
return new
|
|
2470
|
+
return new import_discord17.ActionRowBuilder().addComponents(component);
|
|
2455
2471
|
}
|
|
2456
2472
|
/**
|
|
2457
2473
|
* Rows multiples (5 max)
|
|
@@ -2504,7 +2520,7 @@ var SimpleMutex = class {
|
|
|
2504
2520
|
// package.json
|
|
2505
2521
|
var package_default = {
|
|
2506
2522
|
name: "@spatulox/simplediscordbot",
|
|
2507
|
-
version: "1.0.
|
|
2523
|
+
version: "1.0.34",
|
|
2508
2524
|
author: "Spatulox",
|
|
2509
2525
|
description: "Simple discord bot framework to set up a bot under 30 secondes",
|
|
2510
2526
|
exports: {
|
|
@@ -2516,13 +2532,19 @@ var package_default = {
|
|
|
2516
2532
|
scripts: {
|
|
2517
2533
|
build: "rm -r dist/ && tsup",
|
|
2518
2534
|
patch: "npm run build && npm version patch",
|
|
2535
|
+
minor: "npm run build && npm version minor",
|
|
2536
|
+
major: "npm run build && npm version major",
|
|
2537
|
+
premajor: "npm run build && npm version premajor",
|
|
2538
|
+
"premajor:alpha": "npm run build && npm version premajor --preid=alpha",
|
|
2519
2539
|
pub: "npm run patch && npm publish --access public",
|
|
2540
|
+
"pub:major": "npm run major && npm publish --access public",
|
|
2541
|
+
"pub:alpha": "npm run premajor:alpha && npm publish --tag alpha --access public",
|
|
2520
2542
|
"test-pack": "npm run patch && npm publish --access public",
|
|
2521
2543
|
dev: "nodemon --exec tsx src/test/index.ts"
|
|
2522
2544
|
},
|
|
2523
2545
|
license: "MIT",
|
|
2524
2546
|
dependencies: {
|
|
2525
|
-
"@spatulox/discord-interaction-manager": "^1.0.
|
|
2547
|
+
"@spatulox/discord-interaction-manager": "^1.0.15",
|
|
2526
2548
|
"discord.js": "^14.25.1"
|
|
2527
2549
|
},
|
|
2528
2550
|
devDependencies: {
|