@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.mjs
CHANGED
|
@@ -289,7 +289,7 @@ InternetChecker.TARGET = "https://1.1.1.1";
|
|
|
289
289
|
InternetChecker.RETRY_TIME = Time.second.SEC_30;
|
|
290
290
|
|
|
291
291
|
// src/bot/BotLog.ts
|
|
292
|
-
import { EmbedBuilder } from "discord.js";
|
|
292
|
+
import { EmbedBuilder, ActionRowBuilder } from "discord.js";
|
|
293
293
|
var _BotLog = class _BotLog {
|
|
294
294
|
constructor() {
|
|
295
295
|
}
|
|
@@ -310,10 +310,10 @@ var _BotLog = class _BotLog {
|
|
|
310
310
|
if (logCh?.isTextBased()) {
|
|
311
311
|
_BotLog.logChannel = logCh;
|
|
312
312
|
} else {
|
|
313
|
-
Log.warn(
|
|
313
|
+
Log.warn(`Log channel ${Bot.config.log.logChannelId} invalid`);
|
|
314
314
|
}
|
|
315
315
|
} catch (error) {
|
|
316
|
-
Log.error(
|
|
316
|
+
Log.error(`Log channel fetch failed: ${error}`);
|
|
317
317
|
}
|
|
318
318
|
}
|
|
319
319
|
if (Bot.config.log?.errorChannelId) {
|
|
@@ -322,10 +322,10 @@ var _BotLog = class _BotLog {
|
|
|
322
322
|
if (errorCh?.isTextBased()) {
|
|
323
323
|
_BotLog.errorChannel = errorCh;
|
|
324
324
|
} else {
|
|
325
|
-
Log.warn(
|
|
325
|
+
Log.warn(`Error channel ${Bot.config.log.errorChannelId} invalid`);
|
|
326
326
|
}
|
|
327
327
|
} catch (error) {
|
|
328
|
-
Log.error(
|
|
328
|
+
Log.error(`Error channel fetch failed: ${error}`);
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
331
|
}
|
|
@@ -337,10 +337,16 @@ var _BotLog = class _BotLog {
|
|
|
337
337
|
let msg;
|
|
338
338
|
try {
|
|
339
339
|
if (content instanceof EmbedBuilder) {
|
|
340
|
+
const text = content.data.description ?? content.data.title;
|
|
341
|
+
if (text) {
|
|
342
|
+
Log.info(text);
|
|
343
|
+
}
|
|
340
344
|
msg = await channel.send({ embeds: [content] });
|
|
345
|
+
} else if (content instanceof ActionRowBuilder) {
|
|
346
|
+
msg = await channel.send({ components: [content] });
|
|
341
347
|
} else {
|
|
342
348
|
const timestamp = `\`${(/* @__PURE__ */ new Date()).toISOString()}\``;
|
|
343
|
-
msg = await channel.send(
|
|
349
|
+
msg = await channel.send(`[${timestamp}] [${prefix.toUpperCase()}] ${content}`);
|
|
344
350
|
}
|
|
345
351
|
} catch (error) {
|
|
346
352
|
Log.error(`Failed to send to Discord channel: ${error}`);
|
|
@@ -353,7 +359,7 @@ var _BotLog = class _BotLog {
|
|
|
353
359
|
static async info(content) {
|
|
354
360
|
const logConfig = Bot.config.log;
|
|
355
361
|
if (!logConfig || logConfig.info.console) {
|
|
356
|
-
if (
|
|
362
|
+
if (typeof content == "string") {
|
|
357
363
|
Log.info(content);
|
|
358
364
|
}
|
|
359
365
|
}
|
|
@@ -367,7 +373,7 @@ var _BotLog = class _BotLog {
|
|
|
367
373
|
static async error(content) {
|
|
368
374
|
const logConfig = Bot.config.log;
|
|
369
375
|
if (!logConfig || logConfig.error.console) {
|
|
370
|
-
if (
|
|
376
|
+
if (typeof content == "string") {
|
|
371
377
|
Log.error(content);
|
|
372
378
|
}
|
|
373
379
|
}
|
|
@@ -381,7 +387,7 @@ var _BotLog = class _BotLog {
|
|
|
381
387
|
static async warn(content) {
|
|
382
388
|
const logConfig = Bot.config.log;
|
|
383
389
|
if (!logConfig || logConfig?.warn.console) {
|
|
384
|
-
if (
|
|
390
|
+
if (typeof content == "string") {
|
|
385
391
|
Log.warn(content);
|
|
386
392
|
}
|
|
387
393
|
}
|
|
@@ -395,7 +401,7 @@ var _BotLog = class _BotLog {
|
|
|
395
401
|
static async debug(content) {
|
|
396
402
|
const logConfig = Bot.config.log;
|
|
397
403
|
if (!logConfig || logConfig?.debug.console) {
|
|
398
|
-
if (
|
|
404
|
+
if (typeof content == "string") {
|
|
399
405
|
Log.debug(content);
|
|
400
406
|
}
|
|
401
407
|
}
|
|
@@ -454,7 +460,8 @@ var EmbedColor = /* @__PURE__ */ ((EmbedColor3) => {
|
|
|
454
460
|
})(EmbedColor || {});
|
|
455
461
|
var EmbedManager = class {
|
|
456
462
|
static get BOT_ICON() {
|
|
457
|
-
|
|
463
|
+
if (Bot.config.botIconUrl) return Bot.config.botIconUrl;
|
|
464
|
+
return Bot.client?.user?.displayAvatarURL({ forceStatic: false, size: 128 }) || "";
|
|
458
465
|
}
|
|
459
466
|
static get DEFAULT_COLOR() {
|
|
460
467
|
return Bot.config.defaultEmbedColor || 6064856 /* default */;
|
|
@@ -464,11 +471,14 @@ var EmbedManager = class {
|
|
|
464
471
|
*/
|
|
465
472
|
static create(color = null) {
|
|
466
473
|
const embed = new EmbedBuilder2().setColor(color ?? this.DEFAULT_COLOR).setTimestamp(/* @__PURE__ */ new Date());
|
|
467
|
-
if (
|
|
468
|
-
|
|
469
|
-
text: Bot.config.botName
|
|
470
|
-
|
|
471
|
-
|
|
474
|
+
if (Bot.config.botName) {
|
|
475
|
+
const footer = {
|
|
476
|
+
text: Bot.config.botName
|
|
477
|
+
};
|
|
478
|
+
if (this.BOT_ICON) {
|
|
479
|
+
footer.iconURL = this.BOT_ICON;
|
|
480
|
+
}
|
|
481
|
+
embed.setFooter(footer);
|
|
472
482
|
}
|
|
473
483
|
return embed;
|
|
474
484
|
}
|
|
@@ -476,7 +486,7 @@ var EmbedManager = class {
|
|
|
476
486
|
* Creates simple embed with just description
|
|
477
487
|
*/
|
|
478
488
|
static simple(description, color = null) {
|
|
479
|
-
return this.create(color).
|
|
489
|
+
return this.create(color).setDescription(description).setTimestamp(null);
|
|
480
490
|
}
|
|
481
491
|
/**
|
|
482
492
|
* Creates error embed
|
|
@@ -565,13 +575,13 @@ import {
|
|
|
565
575
|
|
|
566
576
|
// src/manager/builder/SendableComponentBuilder.ts
|
|
567
577
|
import {
|
|
568
|
-
ActionRowBuilder,
|
|
578
|
+
ActionRowBuilder as ActionRowBuilder2,
|
|
569
579
|
EmbedBuilder as EmbedBuilder3,
|
|
570
580
|
MessageFlags as MessageFlags2
|
|
571
581
|
} from "discord.js";
|
|
572
582
|
var SendableComponentBuilder = class {
|
|
573
583
|
static isSendableComponent(thing) {
|
|
574
|
-
return thing instanceof EmbedBuilder3 || thing instanceof
|
|
584
|
+
return thing instanceof EmbedBuilder3 || thing instanceof ActionRowBuilder2;
|
|
575
585
|
}
|
|
576
586
|
static build(base, content, components) {
|
|
577
587
|
if (content) {
|
|
@@ -583,7 +593,7 @@ var SendableComponentBuilder = class {
|
|
|
583
593
|
base.embeds = base.embeds || [];
|
|
584
594
|
base.embeds.push(comp);
|
|
585
595
|
}
|
|
586
|
-
if (comp instanceof
|
|
596
|
+
if (comp instanceof ActionRowBuilder2) {
|
|
587
597
|
base.components = base.components || [];
|
|
588
598
|
base.components.push(comp);
|
|
589
599
|
}
|
|
@@ -626,13 +636,13 @@ var BotMessage = class {
|
|
|
626
636
|
static async send(channel, content, component) {
|
|
627
637
|
try {
|
|
628
638
|
if (!channel) {
|
|
629
|
-
Log.warn("Cannot send message:
|
|
639
|
+
Log.warn("Cannot send message: Invalid channel ID");
|
|
630
640
|
return null;
|
|
631
641
|
}
|
|
632
642
|
if (typeof channel === "string") {
|
|
633
643
|
const fetchedChannel = Bot.client.channels.cache.get(channel);
|
|
634
644
|
if (!fetchedChannel?.isTextBased()) {
|
|
635
|
-
Log.warn(`Invalid channel ID: ${channel}`);
|
|
645
|
+
Log.warn(`Cannot send message : Invalid channel ID: ${channel}`);
|
|
636
646
|
return null;
|
|
637
647
|
}
|
|
638
648
|
channel = fetchedChannel;
|
|
@@ -653,7 +663,7 @@ var BotMessage = class {
|
|
|
653
663
|
} else if (component) {
|
|
654
664
|
messageCreate = SendableComponentBuilder.buildMessage(component);
|
|
655
665
|
} else {
|
|
656
|
-
throw new Error("content and component cannot be null at the same time");
|
|
666
|
+
throw new Error("Cannot send message : content and component cannot be null at the same time");
|
|
657
667
|
}
|
|
658
668
|
}
|
|
659
669
|
try {
|
|
@@ -662,7 +672,7 @@ var BotMessage = class {
|
|
|
662
672
|
throw e;
|
|
663
673
|
}
|
|
664
674
|
} catch (e) {
|
|
665
|
-
Log.error(`
|
|
675
|
+
Log.error(`Cannot send message : ${e}`);
|
|
666
676
|
return null;
|
|
667
677
|
}
|
|
668
678
|
}
|
|
@@ -682,11 +692,11 @@ var BotMessage = class {
|
|
|
682
692
|
} else if (component) {
|
|
683
693
|
messageCreate = SendableComponentBuilder.buildMessage(component);
|
|
684
694
|
} else {
|
|
685
|
-
throw new Error("content and component cannot be null at the same time");
|
|
695
|
+
throw new Error("Cannot send message : content and component cannot be null at the same time");
|
|
686
696
|
}
|
|
687
697
|
return await targetUser.send(messageCreate);
|
|
688
698
|
} catch (error) {
|
|
689
|
-
Log.error(`
|
|
699
|
+
Log.error(`Cannot send message to ${user}: ${error}`);
|
|
690
700
|
return null;
|
|
691
701
|
}
|
|
692
702
|
}
|
|
@@ -835,7 +845,7 @@ var BotEnv = {
|
|
|
835
845
|
return token;
|
|
836
846
|
},
|
|
837
847
|
get dev() {
|
|
838
|
-
return process.env.
|
|
848
|
+
return !!process.env.DISCORD_BOT_DEV;
|
|
839
849
|
},
|
|
840
850
|
get clientId() {
|
|
841
851
|
const token = process.env.DISCORD_BOT_CLIENTID;
|
|
@@ -1223,6 +1233,11 @@ var WebhookManager = class {
|
|
|
1223
1233
|
// src/manager/guild/ChannelManager/GuildTextChannelManager.ts
|
|
1224
1234
|
import { TextChannel as TextChannel4, ChannelType } from "discord.js";
|
|
1225
1235
|
|
|
1236
|
+
// src/manager/guild/ChannelManager/GuildChannelManager.ts
|
|
1237
|
+
import {
|
|
1238
|
+
GuildChannel
|
|
1239
|
+
} from "discord.js";
|
|
1240
|
+
|
|
1226
1241
|
// src/manager/guild/ChannelManager/GuildMessageManager.ts
|
|
1227
1242
|
var GuildMessageManager = class {
|
|
1228
1243
|
/**
|
|
@@ -1325,13 +1340,10 @@ var _GuildChannelManager = class _GuildChannelManager {
|
|
|
1325
1340
|
}
|
|
1326
1341
|
}
|
|
1327
1342
|
static async find(channelId) {
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
} catch {
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1343
|
+
const cached = Bot.client.channels.cache.get(channelId);
|
|
1344
|
+
if (cached && cached instanceof GuildChannel) return cached;
|
|
1345
|
+
const channel = await Bot.client.channels.fetch(channelId);
|
|
1346
|
+
if (channel && channel instanceof GuildChannel) return channel;
|
|
1335
1347
|
Log.warn(`Channel ${channelId} not found in any guild`);
|
|
1336
1348
|
return null;
|
|
1337
1349
|
}
|
|
@@ -1507,7 +1519,7 @@ var ReactionManager = class {
|
|
|
1507
1519
|
|
|
1508
1520
|
// src/manager/guild/GuildManager.ts
|
|
1509
1521
|
import {
|
|
1510
|
-
Guild as
|
|
1522
|
+
Guild as Guild3,
|
|
1511
1523
|
VoiceChannel as VoiceChannel2,
|
|
1512
1524
|
StageChannel as StageChannel2
|
|
1513
1525
|
} from "discord.js";
|
|
@@ -1518,16 +1530,19 @@ var BasicUserManager = class {
|
|
|
1518
1530
|
/**
|
|
1519
1531
|
* Find member in specific guild
|
|
1520
1532
|
*/
|
|
1521
|
-
static async findInGuild(
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
Log.error(`UserManager: Member ${memberId} not found in ${guildId}`);
|
|
1529
|
-
return null;
|
|
1533
|
+
static async findInGuild(guild, memberId) {
|
|
1534
|
+
let targetGuild = null;
|
|
1535
|
+
if (typeof guild === "string") {
|
|
1536
|
+
targetGuild = await GuildManager.find(guild);
|
|
1537
|
+
if (!targetGuild) return null;
|
|
1538
|
+
} else {
|
|
1539
|
+
targetGuild = guild;
|
|
1530
1540
|
}
|
|
1541
|
+
const cached = targetGuild.members.cache.get(memberId);
|
|
1542
|
+
if (cached) return cached;
|
|
1543
|
+
const member = await targetGuild.members.fetch(memberId).catch(() => null);
|
|
1544
|
+
if (!member) Log.error(`UserManager: Member ${memberId} not found in guild ${targetGuild.id}`);
|
|
1545
|
+
return member;
|
|
1531
1546
|
}
|
|
1532
1547
|
/**
|
|
1533
1548
|
* Check if user is still in guild
|
|
@@ -1582,13 +1597,13 @@ var BasicUserManager = class {
|
|
|
1582
1597
|
};
|
|
1583
1598
|
|
|
1584
1599
|
// src/manager/guild/GuildUserManager.ts
|
|
1585
|
-
import { Guild } from "discord.js";
|
|
1600
|
+
import { Guild as Guild2 } from "discord.js";
|
|
1586
1601
|
import { setTimeout as setTimeout2 } from "timers/promises";
|
|
1587
1602
|
var MAX_NICKNAME_LENGTH = 32;
|
|
1588
1603
|
var GuildUserManager = class extends BasicUserManager {
|
|
1589
1604
|
static async find(userId, guild) {
|
|
1590
1605
|
try {
|
|
1591
|
-
if (guild instanceof
|
|
1606
|
+
if (guild instanceof Guild2) {
|
|
1592
1607
|
return await guild.members.fetch(userId);
|
|
1593
1608
|
} else {
|
|
1594
1609
|
return await (await GuildManager.find(guild)).members.fetch(userId);
|
|
@@ -1622,7 +1637,7 @@ var GuildUserManager = class extends BasicUserManager {
|
|
|
1622
1637
|
*/
|
|
1623
1638
|
static async isBanned(guildId, userId) {
|
|
1624
1639
|
try {
|
|
1625
|
-
const guild =
|
|
1640
|
+
const guild = await GuildManager.find(guildId);
|
|
1626
1641
|
if (!guild) {
|
|
1627
1642
|
Log.warn(`Guild ${guildId} not found`);
|
|
1628
1643
|
return false;
|
|
@@ -1639,13 +1654,9 @@ var GuildUserManager = class extends BasicUserManager {
|
|
|
1639
1654
|
*/
|
|
1640
1655
|
static async deconnectFromVoice(guildId, memberId) {
|
|
1641
1656
|
try {
|
|
1642
|
-
const
|
|
1643
|
-
if (!
|
|
1644
|
-
throw new Error(`
|
|
1645
|
-
}
|
|
1646
|
-
const member = await guild.members.fetch(memberId);
|
|
1647
|
-
if (!member.voice.channel) {
|
|
1648
|
-
throw new Error(`Member ${memberId} is not in a voice channel`);
|
|
1657
|
+
const member = await GuildManager.user.findInGuild(guildId, memberId);
|
|
1658
|
+
if (!member || !member.voice.channel) {
|
|
1659
|
+
throw new Error(`Member ${memberId} not found or not in a voice channel`);
|
|
1649
1660
|
}
|
|
1650
1661
|
await member.voice.disconnect();
|
|
1651
1662
|
Log.info(`Disconnected member ${memberId} from voice in guild ${guildId}`);
|
|
@@ -1659,9 +1670,10 @@ var GuildUserManager = class extends BasicUserManager {
|
|
|
1659
1670
|
*/
|
|
1660
1671
|
static async isInVoice(memberId, guildId) {
|
|
1661
1672
|
try {
|
|
1662
|
-
const
|
|
1663
|
-
if (!
|
|
1664
|
-
|
|
1673
|
+
const member = await GuildManager.user.findInGuild(guildId, memberId);
|
|
1674
|
+
if (!member) {
|
|
1675
|
+
throw new Error(`User ${guildId} not found`);
|
|
1676
|
+
}
|
|
1665
1677
|
return member.voice.channelId !== null;
|
|
1666
1678
|
} catch (error) {
|
|
1667
1679
|
Log.debug(`Member ${memberId} not found or not in voice in guild ${guildId}`);
|
|
@@ -1673,9 +1685,10 @@ var GuildUserManager = class extends BasicUserManager {
|
|
|
1673
1685
|
*/
|
|
1674
1686
|
static async mute(guildId, memberId, reason) {
|
|
1675
1687
|
try {
|
|
1676
|
-
const
|
|
1677
|
-
if (!
|
|
1678
|
-
|
|
1688
|
+
const member = await GuildManager.user.findInGuild(guildId, memberId);
|
|
1689
|
+
if (!member) {
|
|
1690
|
+
throw new Error(`User ${guildId} not found`);
|
|
1691
|
+
}
|
|
1679
1692
|
await member.voice.setMute(true, reason);
|
|
1680
1693
|
Log.info(`Server muted ${memberId} in guild ${guildId}: ${reason || "No reason"}`);
|
|
1681
1694
|
} catch (error) {
|
|
@@ -1688,9 +1701,10 @@ var GuildUserManager = class extends BasicUserManager {
|
|
|
1688
1701
|
*/
|
|
1689
1702
|
static async unmute(guildId, memberId, reason) {
|
|
1690
1703
|
try {
|
|
1691
|
-
const
|
|
1692
|
-
if (!
|
|
1693
|
-
|
|
1704
|
+
const member = await GuildManager.user.findInGuild(guildId, memberId);
|
|
1705
|
+
if (!member) {
|
|
1706
|
+
throw new Error(`User ${guildId} not found`);
|
|
1707
|
+
}
|
|
1694
1708
|
await member.voice.setMute(false, reason);
|
|
1695
1709
|
Log.info(`Server unmuted ${memberId} in guild ${guildId}: ${reason || "No reason"}`);
|
|
1696
1710
|
} catch (error) {
|
|
@@ -1703,9 +1717,10 @@ var GuildUserManager = class extends BasicUserManager {
|
|
|
1703
1717
|
*/
|
|
1704
1718
|
static async deafen(guildId, memberId, reason) {
|
|
1705
1719
|
try {
|
|
1706
|
-
const
|
|
1707
|
-
if (!
|
|
1708
|
-
|
|
1720
|
+
const member = await GuildManager.user.findInGuild(guildId, memberId);
|
|
1721
|
+
if (!member) {
|
|
1722
|
+
throw new Error(`User ${guildId} not found`);
|
|
1723
|
+
}
|
|
1709
1724
|
await member.voice.setDeaf(true, reason);
|
|
1710
1725
|
Log.info(`Server deafened ${memberId} in guild ${guildId}: ${reason || "No reason"}`);
|
|
1711
1726
|
} catch (error) {
|
|
@@ -1718,9 +1733,10 @@ var GuildUserManager = class extends BasicUserManager {
|
|
|
1718
1733
|
*/
|
|
1719
1734
|
static async undeafen(guildId, memberId, reason) {
|
|
1720
1735
|
try {
|
|
1721
|
-
const
|
|
1722
|
-
if (!
|
|
1723
|
-
|
|
1736
|
+
const member = await GuildManager.user.findInGuild(guildId, memberId);
|
|
1737
|
+
if (!member) {
|
|
1738
|
+
throw new Error(`User ${guildId} not found`);
|
|
1739
|
+
}
|
|
1724
1740
|
await member.voice.setDeaf(false, reason);
|
|
1725
1741
|
Log.info(`Server undeafened ${memberId} in guild ${guildId}: ${reason || "No reason"}`);
|
|
1726
1742
|
} catch (error) {
|
|
@@ -1733,9 +1749,10 @@ var GuildUserManager = class extends BasicUserManager {
|
|
|
1733
1749
|
*/
|
|
1734
1750
|
static async timeout(guildId, memberId, duration, reason) {
|
|
1735
1751
|
try {
|
|
1736
|
-
const
|
|
1737
|
-
if (!
|
|
1738
|
-
|
|
1752
|
+
const member = await GuildManager.user.findInGuild(guildId, memberId);
|
|
1753
|
+
if (!member) {
|
|
1754
|
+
throw new Error(`User ${guildId} not found`);
|
|
1755
|
+
}
|
|
1739
1756
|
const expires = Date.now() + duration;
|
|
1740
1757
|
await member.timeout(expires, reason);
|
|
1741
1758
|
Log.info(`Timed out ${memberId} for ${duration}ms in guild ${guildId}: ${reason || "No reason"}`);
|
|
@@ -1749,9 +1766,10 @@ var GuildUserManager = class extends BasicUserManager {
|
|
|
1749
1766
|
*/
|
|
1750
1767
|
static async untimeout(guildId, memberId, reason) {
|
|
1751
1768
|
try {
|
|
1752
|
-
const
|
|
1753
|
-
if (!
|
|
1754
|
-
|
|
1769
|
+
const member = await GuildManager.user.findInGuild(guildId, memberId);
|
|
1770
|
+
if (!member) {
|
|
1771
|
+
throw new Error(`User ${guildId} not found`);
|
|
1772
|
+
}
|
|
1755
1773
|
await member.timeout(null, reason);
|
|
1756
1774
|
Log.info(`Untimed out ${memberId} in guild ${guildId}: ${reason || "No reason"}`);
|
|
1757
1775
|
} catch (error) {
|
|
@@ -1764,9 +1782,10 @@ var GuildUserManager = class extends BasicUserManager {
|
|
|
1764
1782
|
*/
|
|
1765
1783
|
static async kick(guildId, memberId, reason) {
|
|
1766
1784
|
try {
|
|
1767
|
-
const
|
|
1768
|
-
if (!
|
|
1769
|
-
|
|
1785
|
+
const member = await GuildManager.user.findInGuild(guildId, memberId);
|
|
1786
|
+
if (!member) {
|
|
1787
|
+
throw new Error(`User ${guildId} not found`);
|
|
1788
|
+
}
|
|
1770
1789
|
await member.kick(reason);
|
|
1771
1790
|
Log.info(`Kicked ${memberId} from guild ${guildId}: ${reason || "No reason"}`);
|
|
1772
1791
|
} catch (error) {
|
|
@@ -1775,7 +1794,7 @@ var GuildUserManager = class extends BasicUserManager {
|
|
|
1775
1794
|
}
|
|
1776
1795
|
}
|
|
1777
1796
|
static async ban(guildId, userId, banOption) {
|
|
1778
|
-
const guild =
|
|
1797
|
+
const guild = await GuildManager.find(guildId);
|
|
1779
1798
|
if (!guild) {
|
|
1780
1799
|
throw new Error(`Guild ${guildId} not found`);
|
|
1781
1800
|
}
|
|
@@ -1788,7 +1807,7 @@ var GuildUserManager = class extends BasicUserManager {
|
|
|
1788
1807
|
}
|
|
1789
1808
|
}
|
|
1790
1809
|
static async unban(guildId, userId, reason) {
|
|
1791
|
-
const guild =
|
|
1810
|
+
const guild = await GuildManager.find(guildId);
|
|
1792
1811
|
if (!guild) {
|
|
1793
1812
|
throw new Error(`Guild ${guildId} not found`);
|
|
1794
1813
|
}
|
|
@@ -2149,7 +2168,7 @@ var GuildManager = class {
|
|
|
2149
2168
|
*/
|
|
2150
2169
|
static async fetchAllMembers(guildId, MAX_ATTEMPTS = 3, RETRY_DELAY = Time.minute.MIN_05.toMilliseconds()) {
|
|
2151
2170
|
let guild;
|
|
2152
|
-
if (guildId instanceof
|
|
2171
|
+
if (guildId instanceof Guild3) {
|
|
2153
2172
|
guild = guildId;
|
|
2154
2173
|
} else {
|
|
2155
2174
|
let tmp = Bot.client.guilds.cache.get(guildId);
|
|
@@ -2233,18 +2252,17 @@ GuildManager.invite = InviteManager;
|
|
|
2233
2252
|
// src/manager/direct/UserManager.ts
|
|
2234
2253
|
var UserManager = class extends BasicUserManager {
|
|
2235
2254
|
static async find(userId) {
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
}
|
|
2255
|
+
const cached = Bot.client.users.cache.get(userId);
|
|
2256
|
+
if (cached) return cached;
|
|
2257
|
+
const user = await Bot.client.users.fetch(userId).catch(() => null);
|
|
2258
|
+
if (!user) Log.error(`UserManager: User ${userId} not found`);
|
|
2259
|
+
return user;
|
|
2242
2260
|
}
|
|
2243
2261
|
};
|
|
2244
2262
|
|
|
2245
2263
|
// src/manager/interactions/ModalManager.ts
|
|
2246
2264
|
import {
|
|
2247
|
-
ActionRowBuilder as
|
|
2265
|
+
ActionRowBuilder as ActionRowBuilder3,
|
|
2248
2266
|
ModalBuilder,
|
|
2249
2267
|
TextInputBuilder,
|
|
2250
2268
|
TextInputStyle
|
|
@@ -2278,7 +2296,7 @@ var ModalManager = class _ModalManager {
|
|
|
2278
2296
|
const actionRows = [];
|
|
2279
2297
|
for (const fieldJson of json.fields) {
|
|
2280
2298
|
const input = this.fieldJsonToInput(fieldJson);
|
|
2281
|
-
const row = new
|
|
2299
|
+
const row = new ActionRowBuilder3().addComponents(input);
|
|
2282
2300
|
actionRows.push(row);
|
|
2283
2301
|
}
|
|
2284
2302
|
return modal.addComponents(...actionRows);
|
|
@@ -2336,7 +2354,7 @@ var ModalManager = class _ModalManager {
|
|
|
2336
2354
|
|
|
2337
2355
|
// src/manager/interactions/SelectMenuManager.ts
|
|
2338
2356
|
import {
|
|
2339
|
-
ActionRowBuilder as
|
|
2357
|
+
ActionRowBuilder as ActionRowBuilder4,
|
|
2340
2358
|
StringSelectMenuBuilder,
|
|
2341
2359
|
StringSelectMenuOptionBuilder,
|
|
2342
2360
|
UserSelectMenuBuilder,
|
|
@@ -2367,7 +2385,7 @@ var SelectMenuManager = class {
|
|
|
2367
2385
|
* Pagination menu
|
|
2368
2386
|
*/
|
|
2369
2387
|
static paginated(customId, options, pageSize = 25) {
|
|
2370
|
-
const row = new
|
|
2388
|
+
const row = new ActionRowBuilder4();
|
|
2371
2389
|
for (let i = 0; i < options.length; i += pageSize) {
|
|
2372
2390
|
const pageOptions = options.slice(i, i + pageSize);
|
|
2373
2391
|
const menu = new StringSelectMenuBuilder().setCustomId(`${customId}_page_${Math.floor(i / pageSize)}`).setPlaceholder(`Page ${Math.floor(i / pageSize) + 1}`).addOptions(pageOptions.map((opt) => {
|
|
@@ -2429,7 +2447,7 @@ var SelectMenuManager = class {
|
|
|
2429
2447
|
* ActionRow
|
|
2430
2448
|
*/
|
|
2431
2449
|
static row(component) {
|
|
2432
|
-
return new
|
|
2450
|
+
return new ActionRowBuilder4().addComponents(component);
|
|
2433
2451
|
}
|
|
2434
2452
|
/**
|
|
2435
2453
|
* Rows multiples (5 max)
|
|
@@ -2482,7 +2500,7 @@ var SimpleMutex = class {
|
|
|
2482
2500
|
// package.json
|
|
2483
2501
|
var package_default = {
|
|
2484
2502
|
name: "@spatulox/simplediscordbot",
|
|
2485
|
-
version: "1.0.
|
|
2503
|
+
version: "1.0.34",
|
|
2486
2504
|
author: "Spatulox",
|
|
2487
2505
|
description: "Simple discord bot framework to set up a bot under 30 secondes",
|
|
2488
2506
|
exports: {
|
|
@@ -2494,13 +2512,19 @@ var package_default = {
|
|
|
2494
2512
|
scripts: {
|
|
2495
2513
|
build: "rm -r dist/ && tsup",
|
|
2496
2514
|
patch: "npm run build && npm version patch",
|
|
2515
|
+
minor: "npm run build && npm version minor",
|
|
2516
|
+
major: "npm run build && npm version major",
|
|
2517
|
+
premajor: "npm run build && npm version premajor",
|
|
2518
|
+
"premajor:alpha": "npm run build && npm version premajor --preid=alpha",
|
|
2497
2519
|
pub: "npm run patch && npm publish --access public",
|
|
2520
|
+
"pub:major": "npm run major && npm publish --access public",
|
|
2521
|
+
"pub:alpha": "npm run premajor:alpha && npm publish --tag alpha --access public",
|
|
2498
2522
|
"test-pack": "npm run patch && npm publish --access public",
|
|
2499
2523
|
dev: "nodemon --exec tsx src/test/index.ts"
|
|
2500
2524
|
},
|
|
2501
2525
|
license: "MIT",
|
|
2502
2526
|
dependencies: {
|
|
2503
|
-
"@spatulox/discord-interaction-manager": "^1.0.
|
|
2527
|
+
"@spatulox/discord-interaction-manager": "^1.0.15",
|
|
2504
2528
|
"discord.js": "^14.25.1"
|
|
2505
2529
|
},
|
|
2506
2530
|
devDependencies: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spatulox/simplediscordbot",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.35",
|
|
4
4
|
"author": "Spatulox",
|
|
5
5
|
"description": "Simple discord bot framework to set up a bot under 30 secondes",
|
|
6
6
|
"exports": {
|
|
@@ -12,13 +12,19 @@
|
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "rm -r dist/ && tsup",
|
|
14
14
|
"patch": "npm run build && npm version patch",
|
|
15
|
+
"minor": "npm run build && npm version minor",
|
|
16
|
+
"major": "npm run build && npm version major",
|
|
17
|
+
"premajor": "npm run build && npm version premajor",
|
|
18
|
+
"premajor:alpha": "npm run build && npm version premajor --preid=alpha",
|
|
15
19
|
"pub": "npm run patch && npm publish --access public",
|
|
20
|
+
"pub:major": "npm run major && npm publish --access public",
|
|
21
|
+
"pub:alpha": "npm run premajor:alpha && npm publish --tag alpha --access public",
|
|
16
22
|
"test-pack": "npm run patch && npm publish --access public",
|
|
17
23
|
"dev": "nodemon --exec tsx src/test/index.ts"
|
|
18
24
|
},
|
|
19
25
|
"license": "MIT",
|
|
20
26
|
"dependencies": {
|
|
21
|
-
"@spatulox/discord-interaction-manager": "^1.0.
|
|
27
|
+
"@spatulox/discord-interaction-manager": "^1.0.15",
|
|
22
28
|
"discord.js": "^14.25.1"
|
|
23
29
|
},
|
|
24
30
|
"devDependencies": {
|