djs-builder 0.5.20 → 0.5.32
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/.tsbuildinfo +1 -1
- package/dist/discord/builder/system/Pagination.d.ts +5 -2
- package/dist/discord/builder/system/Pagination.d.ts.map +1 -1
- package/dist/discord/builder/system/Pagination.js +17 -14
- package/dist/discord/builder/system/Pagination.js.map +1 -1
- package/dist/discord/events-handler/eventLoader.d.ts +2 -1
- package/dist/discord/events-handler/eventLoader.d.ts.map +1 -1
- package/dist/discord/events-handler/eventLoader.js +23 -0
- package/dist/discord/events-handler/eventLoader.js.map +1 -1
- package/dist/discord/events-handler/events.d.ts.map +1 -1
- package/dist/discord/events-handler/events.js.map +1 -1
- package/dist/discord/events-handler/login.d.ts +6 -2
- package/dist/discord/events-handler/login.d.ts.map +1 -1
- package/dist/discord/events-handler/login.js +98 -5
- package/dist/discord/events-handler/login.js.map +1 -1
- package/dist/discord/events-handler/prefixLoader.d.ts +2 -1
- package/dist/discord/events-handler/prefixLoader.d.ts.map +1 -1
- package/dist/discord/events-handler/prefixLoader.js +23 -0
- package/dist/discord/events-handler/prefixLoader.js.map +1 -1
- package/dist/discord/events-handler/slash-responder.js +4 -4
- package/dist/discord/events-handler/slash-responder.js.map +1 -1
- package/dist/discord/events-handler/slashLoader.d.ts +2 -1
- package/dist/discord/events-handler/slashLoader.d.ts.map +1 -1
- package/dist/discord/events-handler/slashLoader.js +23 -0
- package/dist/discord/events-handler/slashLoader.js.map +1 -1
- package/dist/discord/games/X-O.d.ts +20 -0
- package/dist/discord/games/X-O.d.ts.map +1 -0
- package/dist/discord/games/X-O.js +166 -0
- package/dist/discord/games/X-O.js.map +1 -0
- package/dist/discord/games/rps.d.ts +21 -0
- package/dist/discord/games/rps.d.ts.map +1 -0
- package/dist/discord/games/rps.js +99 -0
- package/dist/discord/games/rps.js.map +1 -0
- package/dist/discord/types/starter.d.ts +12 -0
- package/dist/discord/types/starter.d.ts.map +1 -1
- package/dist/discord/utils.d.ts.map +1 -1
- package/dist/discord/utils.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/lib/discord/builder/system/Pagination.ts +32 -28
- package/lib/discord/events-handler/eventLoader.ts +29 -1
- package/lib/discord/events-handler/events.ts +1 -0
- package/lib/discord/events-handler/login.ts +115 -10
- package/lib/discord/events-handler/prefixLoader.ts +31 -2
- package/lib/discord/events-handler/slash-responder.ts +4 -4
- package/lib/discord/events-handler/slashLoader.ts +29 -1
- package/lib/discord/types/starter.ts +12 -0
- package/lib/discord/utils.ts +2 -1
- package/lib/index.ts +1 -1
- package/package.json +2 -1
- package/dist/discord/builder/components/Pagination.d.ts +0 -65
- package/dist/discord/builder/components/Pagination.d.ts.map +0 -1
- package/dist/discord/builder/components/Pagination.js +0 -189
- package/dist/discord/builder/components/Pagination.js.map +0 -1
- package/dist/discord/events-handler/events loader.d.ts +0 -3
- package/dist/discord/events-handler/events loader.d.ts.map +0 -1
- package/dist/discord/events-handler/events loader.js +0 -20
- package/dist/discord/events-handler/events loader.js.map +0 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RPS = void 0;
|
|
4
|
+
const discord_js_1 = require("discord.js");
|
|
5
|
+
class RPS {
|
|
6
|
+
playerChoices = new Map();
|
|
7
|
+
resultData = null;
|
|
8
|
+
async players({ interaction, challengerId, }) {
|
|
9
|
+
const userId = 'user' in interaction ? interaction.user.id : interaction.author.id;
|
|
10
|
+
const duelEmbed = new discord_js_1.EmbedBuilder()
|
|
11
|
+
.setTitle('Rock-Paper-Scissors Duel!')
|
|
12
|
+
.setDescription(`<@${challengerId}>, you have been challenged to a duel of Rock-Paper-Scissors by <@${userId}>. Make your choice!`)
|
|
13
|
+
.setColor('DarkNavy');
|
|
14
|
+
const row = new discord_js_1.ActionRowBuilder().addComponents(new discord_js_1.ButtonBuilder().setCustomId('rock').setLabel('🪨 Rock').setStyle(discord_js_1.ButtonStyle.Primary), new discord_js_1.ButtonBuilder().setCustomId('paper').setLabel('📄 Paper').setStyle(discord_js_1.ButtonStyle.Primary), new discord_js_1.ButtonBuilder().setCustomId('scissors').setLabel('✂️ Scissors').setStyle(discord_js_1.ButtonStyle.Primary));
|
|
15
|
+
const duelMessage = 'user' in interaction
|
|
16
|
+
? await interaction.reply({
|
|
17
|
+
embeds: [duelEmbed],
|
|
18
|
+
components: [row],
|
|
19
|
+
fetchReply: true,
|
|
20
|
+
ephemeral: false,
|
|
21
|
+
})
|
|
22
|
+
: await interaction.reply({ embeds: [duelEmbed], components: [row] });
|
|
23
|
+
const filter = (btnInteraction) => {
|
|
24
|
+
return [userId, challengerId].includes(btnInteraction.user.id);
|
|
25
|
+
};
|
|
26
|
+
const collector = duelMessage.createMessageComponentCollector({
|
|
27
|
+
filter,
|
|
28
|
+
time: 60000,
|
|
29
|
+
});
|
|
30
|
+
collector.on('collect', async (btnInteraction) => {
|
|
31
|
+
const playerId = btnInteraction.user.id;
|
|
32
|
+
const playerChoice = btnInteraction.customId;
|
|
33
|
+
if (!this.playerChoices.has(playerId)) {
|
|
34
|
+
this.playerChoices.set(playerId, playerChoice);
|
|
35
|
+
await btnInteraction.reply({ content: `You chose ${playerChoice}`, ephemeral: true });
|
|
36
|
+
if (this.playerChoices.size === 2) {
|
|
37
|
+
collector.stop();
|
|
38
|
+
this.displayResults(interaction, userId, challengerId);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
collector.on('end', async (_collected, reason) => {
|
|
43
|
+
if (reason === 'time') {
|
|
44
|
+
const endMessage = `The duel has expired. <@${challengerId}> did not respond in time!`;
|
|
45
|
+
if ('editReply' in interaction) {
|
|
46
|
+
await interaction.editReply({ content: endMessage, components: [] });
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
await interaction.channel?.send({ content: endMessage });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
async displayResults(interaction, userId, challengerId) {
|
|
55
|
+
const userChoice = this.playerChoices.get(userId);
|
|
56
|
+
const challengerChoice = this.playerChoices.get(challengerId);
|
|
57
|
+
const result = this.getResult(userChoice, challengerChoice);
|
|
58
|
+
this.resultData = {
|
|
59
|
+
userId,
|
|
60
|
+
challengerId,
|
|
61
|
+
results: {
|
|
62
|
+
[userId]: result === userId,
|
|
63
|
+
[challengerId]: result === challengerId,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
const resultEmbed = new discord_js_1.EmbedBuilder()
|
|
67
|
+
.setTitle('Rock-Paper-Scissors Results')
|
|
68
|
+
.setDescription(`<@${userId}> chose **${userChoice}**.\n<@${challengerId}> chose **${challengerChoice}**.\n\n**${result}**`)
|
|
69
|
+
.setColor('DarkNavy');
|
|
70
|
+
if ('editReply' in interaction) {
|
|
71
|
+
await interaction.editReply({ embeds: [resultEmbed], components: [] });
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
await interaction.channel?.send({ embeds: [resultEmbed], components: [] });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
getResult(userChoice, challengerChoice) {
|
|
78
|
+
if (userChoice === challengerChoice)
|
|
79
|
+
return "It's a tie!";
|
|
80
|
+
if ((userChoice === 'rock' && challengerChoice === 'scissors') ||
|
|
81
|
+
(userChoice === 'paper' && challengerChoice === 'rock') ||
|
|
82
|
+
(userChoice === 'scissors' && challengerChoice === 'paper')) {
|
|
83
|
+
return userChoice ? userChoice : "";
|
|
84
|
+
}
|
|
85
|
+
return challengerChoice ? challengerChoice : "";
|
|
86
|
+
}
|
|
87
|
+
results() {
|
|
88
|
+
if (this.resultData) {
|
|
89
|
+
return {
|
|
90
|
+
userId: this.resultData.userId,
|
|
91
|
+
challengerId: this.resultData.challengerId,
|
|
92
|
+
results: this.resultData.results,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
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OUNCE_DELAY?: number;
|
|
45
|
+
};
|
|
42
46
|
}
|
|
43
47
|
export interface PrefixOptions {
|
|
44
48
|
path: string;
|
|
@@ -51,6 +55,10 @@ export interface PrefixOptions {
|
|
|
51
55
|
}[];
|
|
52
56
|
similarity?: boolean;
|
|
53
57
|
logsId?: string;
|
|
58
|
+
autoLoader?: {
|
|
59
|
+
enable?: boolean;
|
|
60
|
+
DEBOUNCE_DELAY?: number;
|
|
61
|
+
};
|
|
54
62
|
}
|
|
55
63
|
export interface MongoDbOptions {
|
|
56
64
|
mongoURI: string;
|
|
@@ -78,6 +86,10 @@ export interface EventsOptions {
|
|
|
78
86
|
logsId?: string;
|
|
79
87
|
recursive?: boolean;
|
|
80
88
|
eventBlacklist?: string[];
|
|
89
|
+
autoLoader?: {
|
|
90
|
+
enable?: boolean;
|
|
91
|
+
DEBOUNCE_DELAY?: number;
|
|
92
|
+
};
|
|
81
93
|
}
|
|
82
94
|
export interface Event {
|
|
83
95
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"starter.d.ts","sourceRoot":"","sources":["../../../lib/discord/types/starter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEnC,MAAM,WAAW,UAAU;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE;QACH,OAAO,CAAC,EAAE;YACN,MAAM,EAAE,OAAO,CAAC;YAChB,WAAW,EAAE,GAAG,CAAC;YACjB,UAAU,EAAE,MAAM,CAAC;YACnB,OAAO,CAAC,EAAE,MAAM,CAAC;SACpB,CAAC;QACF,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,SAAS,CAAC,EAAE,OAAO,CAAC;KACvB,CAAC;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE;QACN,K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AAgB,EAAE,eAAe,EAAE,gBAAgB,EAAE,SAAS,EAAE,qBAAqB,EACjI,gBAAgB,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/discord/utils.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/discord/utils.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;AAa1C,wFAbA,iBAAO,OAaA;AAZhB,2CAAgF;AAY9D,8FAZT,qBAAa,OAYS;AAAE,4FAZT,mBAAW,OAYS;AAAE,kGAZT,yBAAiB,OAYS;AAX/D,8DAA2D;AAWM,4FAXxD,yBAAW,OAWwD;AAV5E,gEAA6D;AAUiB,6FAVrE,2BAAY,OAUqE;AAT1F,8DAA2D;AASiC,4FATnF,yBAAW,OASmF;AARvG,sEAAgE;AAQyC,6FARhG,8BAAY,OAQgG;AAPrH,wEAAoF;AAQrE,2FARN,6BAAU,OAQM;AAAE,oGARN,sCAAmB,OAQM;AAP9C,oEAAwE;AAOwC,sGAPvG,sCAAqB,OAOuG;AANrI,sEAA6D;AAMzD,0FANK,2BAAS,OAML;AALb,+CAAgF;AAM1D,yFANb,iBAAQ,OAMa;AAAE,wFANb,gBAAO,OAMa;AAAE,2FANb,mBAAU,OAMa;AAAE,2FANb,mBAAU,OAMa;AAL/D,4DAAyD;AAKQ,2FALxD,uBAAU,OAKwD;AAJ3E,oDAAuI;AAEhB,2FAF9G,mBAAU,OAE8G;AAC5B,0FAHhF,kBAAS,OAGgF;AAC1G,iGAJ4B,yBAAgB,OAI5B;AAD4B,iGAHE,yBAAgB,OAGF;AAAmB,iGAHf,yBAAgB,OAGe;AAAjC,gGAHoB,wBAAe,OAGpB"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
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AAS,EAAE,UAAU,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAE,SAAS,EAAE,qBAAqB,EAChI,gBAAgB,EAAG,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;AACpE,wBAE+E;AAC/E,cAAc,yBAAyB,CAAC"}
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
MessageActionRowComponentBuilder,
|
|
8
8
|
ButtonStyle,
|
|
9
9
|
StringSelectMenuBuilder,
|
|
10
|
-
StringSelectMenuInteraction
|
|
11
10
|
} from "discord.js";
|
|
12
11
|
|
|
13
12
|
interface PagerOptions {
|
|
@@ -55,9 +54,13 @@ import {
|
|
|
55
54
|
attachment?: (string | Buffer)[];
|
|
56
55
|
content?: string[];
|
|
57
56
|
};
|
|
58
|
-
navigationMenu?:
|
|
57
|
+
navigationMenu?: {
|
|
58
|
+
enabled?: boolean;
|
|
59
|
+
placeHolder?: string;
|
|
60
|
+
selects?: string[];
|
|
61
|
+
};
|
|
59
62
|
}
|
|
60
|
-
|
|
63
|
+
|
|
61
64
|
const CUSTOM_IDS = {
|
|
62
65
|
NEXT: "next-djs-builder",
|
|
63
66
|
BACK: "back-djs-builder",
|
|
@@ -86,9 +89,7 @@ import {
|
|
|
86
89
|
private options: Required<PagerOptions>;
|
|
87
90
|
private buttons: ButtonBuilder[];
|
|
88
91
|
private components: ActionRowBuilder<MessageActionRowComponentBuilder>[];
|
|
89
|
-
private selectMenus: ActionRowBuilder<StringSelectMenuBuilder>[];
|
|
90
92
|
private naw_page: number = 0;
|
|
91
|
-
|
|
92
93
|
|
|
93
94
|
constructor(message: Message, options: PagerOptions) {
|
|
94
95
|
this.message = message;
|
|
@@ -103,16 +104,14 @@ import {
|
|
|
103
104
|
label: {},
|
|
104
105
|
emoji: { emojiNext: "➡", emojiBack: "⬅", emojiFirst: "⏪", emojiLast: "⏩", emojiHome: "🏠", emojiDelete: "🗑" },
|
|
105
106
|
pages: { embeds: [], attachment: [], content: [] },
|
|
106
|
-
navigationMenu: false,
|
|
107
|
+
navigationMenu: { enabled: false, placeHolder: "Choose a page", selects: [] },
|
|
107
108
|
...options,
|
|
108
109
|
};
|
|
109
110
|
|
|
110
111
|
this.validateOptions();
|
|
111
112
|
this.buttons = this.createButtons();
|
|
112
113
|
this.components = this.createComponents();
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
114
|
+
}
|
|
116
115
|
private validateOptions() {
|
|
117
116
|
const { emoji } = this.options;
|
|
118
117
|
if (!Object.values(emoji).every(isValidEmoji)) {
|
|
@@ -187,35 +186,40 @@ import {
|
|
|
187
186
|
|
|
188
187
|
private createComponents(): ActionRowBuilder<MessageActionRowComponentBuilder>[] {
|
|
189
188
|
const buttonRow = new ActionRowBuilder<MessageActionRowComponentBuilder>().addComponents(this.buttons);
|
|
190
|
-
|
|
189
|
+
|
|
191
190
|
const otherRows = this.options.otherComponents || [];
|
|
192
|
-
const selectMenus = this.options.navigationMenu ? this.createSelectMenus() : [];
|
|
193
|
-
|
|
191
|
+
const selectMenus = this.options.navigationMenu?.enabled ? this.createSelectMenus() : [];
|
|
192
|
+
|
|
194
193
|
return [buttonRow, ...selectMenus, ...otherRows];
|
|
195
194
|
}
|
|
196
|
-
|
|
195
|
+
|
|
197
196
|
private createSelectMenus(): ActionRowBuilder<StringSelectMenuBuilder>[] {
|
|
198
197
|
const { embeds = [], content = [], attachment = [] } = this.options.pages || {};
|
|
199
198
|
const longest_length = Math.max(embeds.length, content.length, attachment.length);
|
|
200
|
-
|
|
201
199
|
const selectMenus: ActionRowBuilder<StringSelectMenuBuilder>[] = [];
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
200
|
+
const select_status = this.options.navigationMenu?.enabled;
|
|
201
|
+
const select_placeholder = this.options.navigationMenu?.placeHolder;
|
|
202
|
+
const selects = this.options.navigationMenu?.selects || [];
|
|
203
|
+
|
|
204
|
+
if (select_status) {
|
|
205
|
+
for (let i = 0; i < longest_length; i += 25) {
|
|
206
|
+
const menuOptions = Array.from({ length: Math.min(25, longest_length - i) }, (_, j) => ({
|
|
207
|
+
label: selects[i + j] ? selects[i + j] : `Page ${i + j + 1}`,
|
|
208
|
+
value: `${i + j}`
|
|
209
|
+
}));
|
|
210
|
+
|
|
211
|
+
const selectMenu = new StringSelectMenuBuilder()
|
|
212
|
+
.setCustomId(`select_${i}`)
|
|
213
|
+
.setPlaceholder(select_placeholder || "Choose a page")
|
|
214
|
+
.addOptions(menuOptions);
|
|
215
|
+
|
|
216
|
+
selectMenus.push(new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(selectMenu));
|
|
217
|
+
}
|
|
214
218
|
}
|
|
215
|
-
|
|
219
|
+
|
|
216
220
|
return selectMenus;
|
|
217
221
|
}
|
|
218
|
-
|
|
222
|
+
|
|
219
223
|
public async send() {
|
|
220
224
|
const { embeds = [], content = [], attachment = [] } = this.options.pages || {};
|
|
221
225
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Collection } from 'discord.js';
|
|
1
|
+
import { Client, Collection } from 'discord.js';
|
|
2
2
|
import { readdir } from 'fs/promises';
|
|
3
3
|
import { resolve, extname } from 'path';
|
|
4
4
|
import { Event } from '../types/utils';
|
|
5
5
|
import { logError, logInfo } from '../functions/logger';
|
|
6
6
|
import { botData } from './login';
|
|
7
|
+
import { watch } from 'fs';
|
|
7
8
|
|
|
8
9
|
const validExtensions = ['.js', '.ts'];
|
|
9
10
|
|
|
@@ -136,3 +137,30 @@ async function withRetry(handler: (...args: any[]) => Promise<void>, retryAttemp
|
|
|
136
137
|
logError('Reached maximum retry attempts.');
|
|
137
138
|
};
|
|
138
139
|
}
|
|
140
|
+
|
|
141
|
+
export function autoEventLoader(client: Client, DEBOUNCE_DELAY: number = 10000, eventsOptions: Events = {}) {
|
|
142
|
+
|
|
143
|
+
const slashPath = botData.get('slashCommandPath') as string;
|
|
144
|
+
const commandPath = resolve(process.cwd(), slashPath);
|
|
145
|
+
|
|
146
|
+
let debounceTimer: NodeJS.Timeout | null = null;
|
|
147
|
+
|
|
148
|
+
const handleReload = async () => {
|
|
149
|
+
if (debounceTimer) {
|
|
150
|
+
clearTimeout(debounceTimer);
|
|
151
|
+
}
|
|
152
|
+
debounceTimer = setTimeout(async () => {
|
|
153
|
+
await eventLoader(client, eventsOptions);
|
|
154
|
+
logInfo('Slash commands successfully reloaded after debounce.');
|
|
155
|
+
}, DEBOUNCE_DELAY);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
watch(commandPath, { recursive: false }, (eventType: any, filename: any) => {
|
|
159
|
+
if (filename && validExtensions.includes(extname(filename))) {
|
|
160
|
+
logInfo(`Detected ${eventType} in ${filename}, waiting for debouncing...`);
|
|
161
|
+
handleReload();
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
logInfo('Started watching for changes in slash commands...');
|
|
166
|
+
}
|
|
@@ -123,6 +123,7 @@ export async function loadEvents(client: any, eventsOptions: EventsOptions) {
|
|
|
123
123
|
|
|
124
124
|
const eventCount = await countEventFiles(eventsOptions.path, eventsOptions);
|
|
125
125
|
client.eventSize = eventCount;
|
|
126
|
+
|
|
126
127
|
} catch (error: any) {
|
|
127
128
|
logError(`Error while loading events from path: ${eventsOptions.path}`);
|
|
128
129
|
logError(error.message, error);
|
|
@@ -1,24 +1,119 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Collection, Routes, resolveImage, ActivityType, Client } from 'discord.js';
|
|
2
2
|
import { StarterOptions } from '../types/starter';
|
|
3
3
|
import { loadPrefix } from './prefix-responder';
|
|
4
4
|
import { loadSlash } from './slash-responder';
|
|
5
5
|
import { readCommands } from './prefix-register';
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import { GatewayIntentBits } from 'discord-api-types/v10';
|
|
7
|
+
import { logError, logInfo, logWarning } from '../utils';
|
|
8
8
|
import * as path from 'path';
|
|
9
9
|
import fs from 'fs';
|
|
10
|
-
|
|
10
|
+
import { autoSlashLoader } from './slashLoader';
|
|
11
|
+
import { autoPrefixLoader } from './prefixLoader';
|
|
12
|
+
import { autoEventLoader } from './eventLoader';
|
|
13
|
+
|
|
14
|
+
export const botData = new Collection<string, string | string[]>();
|
|
15
|
+
|
|
16
|
+
export async function login(djs: Client & { botData?: Collection<string, string | string[]>; botInfo?: any; ownerId?: string }, options: StarterOptions) {
|
|
11
17
|
|
|
12
18
|
if (!djs) {
|
|
13
19
|
throw new Error("⚠️ \x1b[31mMissing client parameter. Please provide a valid Discord client.\x1b[0m");
|
|
14
20
|
}
|
|
21
|
+
|
|
22
|
+
djs.on('rateLimit', (rateLimitInfo) => {
|
|
23
|
+
logWarning(`Rate limit hit: ${rateLimitInfo.timeout}ms timeout for ${rateLimitInfo.limit} requests.`);
|
|
24
|
+
logInfo(`Route: ${rateLimitInfo.route}`);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
djs.on('error', (error) => {
|
|
28
|
+
logError('An error occurred', error);
|
|
29
|
+
});
|
|
30
|
+
|
|
15
31
|
if (options.bot.token) {
|
|
16
32
|
try {
|
|
17
33
|
await djs.login(options.bot.token);
|
|
18
34
|
|
|
19
35
|
if (options.bot?.token) botData.set('botToken', options.bot.token);
|
|
20
|
-
|
|
21
|
-
|
|
36
|
+
|
|
37
|
+
const REQUIRED_INTENTS = {
|
|
38
|
+
'guildCreate': GatewayIntentBits.Guilds,
|
|
39
|
+
'guildUpdate': GatewayIntentBits.Guilds,
|
|
40
|
+
'guildDelete': GatewayIntentBits.Guilds,
|
|
41
|
+
'channelCreate': GatewayIntentBits.Guilds,
|
|
42
|
+
'channelUpdate': GatewayIntentBits.Guilds,
|
|
43
|
+
'channelDelete': GatewayIntentBits.Guilds,
|
|
44
|
+
'channelPinsUpdate': GatewayIntentBits.Guilds,
|
|
45
|
+
'threadCreate': GatewayIntentBits.Guilds,
|
|
46
|
+
'threadUpdate': GatewayIntentBits.Guilds,
|
|
47
|
+
'threadDelete': GatewayIntentBits.Guilds,
|
|
48
|
+
'threadListSync': GatewayIntentBits.Guilds,
|
|
49
|
+
'threadMemberUpdate': GatewayIntentBits.Guilds,
|
|
50
|
+
'threadMembersUpdate': GatewayIntentBits.Guilds,
|
|
51
|
+
'stageInstanceCreate': GatewayIntentBits.Guilds,
|
|
52
|
+
'stageInstanceUpdate': GatewayIntentBits.Guilds,
|
|
53
|
+
'stageInstanceDelete': GatewayIntentBits.Guilds,
|
|
54
|
+
'guildMemberAdd': GatewayIntentBits.GuildMembers,
|
|
55
|
+
'guildMemberUpdate': GatewayIntentBits.GuildMembers,
|
|
56
|
+
'guildMemberRemove': GatewayIntentBits.GuildMembers,
|
|
57
|
+
'guildAuditLogEntryCreate': GatewayIntentBits.GuildModeration,
|
|
58
|
+
'guildBanAdd': GatewayIntentBits.GuildModeration,
|
|
59
|
+
'guildBanRemove': GatewayIntentBits.GuildModeration,
|
|
60
|
+
'guildEmojisUpdate': GatewayIntentBits.GuildEmojisAndStickers,
|
|
61
|
+
'guildStickersUpdate': GatewayIntentBits.GuildEmojisAndStickers,
|
|
62
|
+
'guildIntegrationsUpdate': GatewayIntentBits.GuildIntegrations,
|
|
63
|
+
'integrationCreate': GatewayIntentBits.GuildIntegrations,
|
|
64
|
+
'integrationUpdate': GatewayIntentBits.GuildIntegrations,
|
|
65
|
+
'integrationDelete': GatewayIntentBits.GuildIntegrations,
|
|
66
|
+
'webhooksUpdate': GatewayIntentBits.GuildWebhooks,
|
|
67
|
+
'inviteCreate': GatewayIntentBits.GuildInvites,
|
|
68
|
+
'inviteDelete': GatewayIntentBits.GuildInvites,
|
|
69
|
+
'voiceStateUpdate': GatewayIntentBits.GuildVoiceStates,
|
|
70
|
+
'presenceUpdate': GatewayIntentBits.GuildPresences,
|
|
71
|
+
'messageCreate': GatewayIntentBits.GuildMessages | GatewayIntentBits.DirectMessages,
|
|
72
|
+
'messageUpdate': GatewayIntentBits.GuildMessages | GatewayIntentBits.DirectMessages,
|
|
73
|
+
'messageDelete': GatewayIntentBits.GuildMessages | GatewayIntentBits.DirectMessages,
|
|
74
|
+
'messageDeleteBulk': GatewayIntentBits.GuildMessages,
|
|
75
|
+
'messageReactionAdd': GatewayIntentBits.GuildMessageReactions,
|
|
76
|
+
'messageReactionRemove': GatewayIntentBits.GuildMessageReactions,
|
|
77
|
+
'messageReactionRemoveAll': GatewayIntentBits.GuildMessageReactions,
|
|
78
|
+
'messageReactionRemoveEmoji': GatewayIntentBits.GuildMessageReactions,
|
|
79
|
+
'typingStart': GatewayIntentBits.GuildMessageTyping,
|
|
80
|
+
'guildScheduledEventCreate': GatewayIntentBits.GuildScheduledEvents,
|
|
81
|
+
'guildScheduledEventUpdate': GatewayIntentBits.GuildScheduledEvents,
|
|
82
|
+
'guildScheduledEventDelete': GatewayIntentBits.GuildScheduledEvents,
|
|
83
|
+
'guildScheduledEventUserAdd': GatewayIntentBits.GuildScheduledEvents,
|
|
84
|
+
'guildScheduledEventUserRemove': GatewayIntentBits.GuildScheduledEvents,
|
|
85
|
+
'autoModerationRuleCreate': GatewayIntentBits.AutoModerationConfiguration,
|
|
86
|
+
'autoModerationRuleUpdate': GatewayIntentBits.AutoModerationConfiguration,
|
|
87
|
+
'autoModerationRuleDelete': GatewayIntentBits.AutoModerationConfiguration,
|
|
88
|
+
'autoModerationActionExecution': GatewayIntentBits.AutoModerationExecution,
|
|
89
|
+
'messagePollVoteAdd': GatewayIntentBits.GuildMessagePolls,
|
|
90
|
+
'messagePollVoteRemove': GatewayIntentBits.GuildMessagePolls
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const missingIntents = new Set();
|
|
94
|
+
const intents = Number(djs.options.intents.bitfield);
|
|
95
|
+
for (const eventName of Object.keys((djs as any)._events)) {
|
|
96
|
+
const requiredBit = REQUIRED_INTENTS[eventName as keyof typeof REQUIRED_INTENTS];
|
|
97
|
+
if (!requiredBit) continue;
|
|
98
|
+
if ((intents & requiredBit) === 0) {
|
|
99
|
+
missingIntents.add(requiredBit);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (missingIntents.size > 0) {
|
|
104
|
+
const EventNames: { [key: number]: string } = Object.fromEntries(
|
|
105
|
+
Object.entries(GatewayIntentBits).map(([key, value]) => [value, key])
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const missingIntentNames = [...missingIntents].map(bit => {
|
|
109
|
+
return EventNames[bit as keyof typeof EventNames] ?? 'unknown';
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
logError(`Missing intents: ${missingIntentNames.join(', ')}`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
} catch (error: any) {
|
|
116
|
+
logError("⚠️ \x1b[31mInvalid token provided. Please provide a valid bot token\x1b[0m", error);
|
|
22
117
|
process.exit(1);
|
|
23
118
|
}
|
|
24
119
|
}
|
|
@@ -91,7 +186,7 @@ export async function login(djs: any, options: StarterOptions) {
|
|
|
91
186
|
}
|
|
92
187
|
|
|
93
188
|
|
|
94
|
-
const userChosenType = options.bot.Status
|
|
189
|
+
const userChosenType = options.bot.Status ? options.bot.Status.type : 3;
|
|
95
190
|
if (options.bot.Status?.activities) {
|
|
96
191
|
if (options.bot.Status.activities.length >= 1) {
|
|
97
192
|
const initialActivity = options.bot.Status.activities[0];
|
|
@@ -115,7 +210,7 @@ export async function login(djs: any, options: StarterOptions) {
|
|
|
115
210
|
let delay = 60000;
|
|
116
211
|
if (options.bot.Status.delay !== undefined) {
|
|
117
212
|
if (options.bot.Status.delay < 60000) {
|
|
118
|
-
|
|
213
|
+
logWarning('⚠️ Delay must be at least 1 minute.');
|
|
119
214
|
}
|
|
120
215
|
delay = options.bot.Status.delay;
|
|
121
216
|
}
|
|
@@ -135,8 +230,8 @@ export async function login(djs: any, options: StarterOptions) {
|
|
|
135
230
|
status: options.bot.Status?.state,
|
|
136
231
|
});
|
|
137
232
|
}
|
|
138
|
-
} catch (error) {
|
|
139
|
-
|
|
233
|
+
} catch (error: any) {
|
|
234
|
+
logError("Error setting activity: ${error}", error);
|
|
140
235
|
}
|
|
141
236
|
}, delay);
|
|
142
237
|
}
|
|
@@ -156,5 +251,15 @@ export async function login(djs: any, options: StarterOptions) {
|
|
|
156
251
|
}
|
|
157
252
|
|
|
158
253
|
(djs as any).botData = botData;
|
|
254
|
+
|
|
255
|
+
if (options.slash?.autoLoader?.enable) {
|
|
256
|
+
autoSlashLoader(djs, options.slash?.autoLoader?.DEBOUNCE_DELAY);
|
|
257
|
+
}
|
|
258
|
+
if (options.prefix?.autoLoader?.enable) {
|
|
259
|
+
autoPrefixLoader(djs, options.prefix?.autoLoader?.DEBOUNCE_DELAY);
|
|
260
|
+
}
|
|
261
|
+
if (options.events?.autoLoader?.enable) {
|
|
262
|
+
autoEventLoader(djs, options.events?.autoLoader?.DEBOUNCE_DELAY, options.events);
|
|
263
|
+
}
|
|
159
264
|
});
|
|
160
265
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Collection } from 'discord.js';
|
|
1
|
+
import { Client, Collection } from 'discord.js';
|
|
2
2
|
import { readdir } from 'fs/promises';
|
|
3
3
|
import { join, resolve, extname } from 'path';
|
|
4
4
|
import { commands, aliases, commandNames } from './prefix-register';
|
|
5
5
|
import { readCommands } from './prefix-register';
|
|
6
|
-
import { logError } from '../functions/logger';
|
|
6
|
+
import { logError, logInfo } from '../functions/logger';
|
|
7
7
|
import { botData } from './login';
|
|
8
|
+
import { watch } from 'fs';
|
|
8
9
|
const validExtensions = ['.js', '.ts'];
|
|
9
10
|
|
|
10
11
|
export async function prefixLoader(client: any): Promise<{ commands: Collection<string, any>; success: boolean }> {
|
|
@@ -52,3 +53,31 @@ export async function prefixLoader(client: any): Promise<{ commands: Collection<
|
|
|
52
53
|
return { commands: new Collection(), success: false };
|
|
53
54
|
}
|
|
54
55
|
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
export function autoPrefixLoader(client: Client, DEBOUNCE_DELAY: number = 10000) {
|
|
59
|
+
|
|
60
|
+
const slashPath = botData.get('slashCommandPath') as string;
|
|
61
|
+
const commandPath = resolve(process.cwd(), slashPath);
|
|
62
|
+
|
|
63
|
+
let debounceTimer: NodeJS.Timeout | null = null;
|
|
64
|
+
|
|
65
|
+
const handleReload = async () => {
|
|
66
|
+
if (debounceTimer) {
|
|
67
|
+
clearTimeout(debounceTimer);
|
|
68
|
+
}
|
|
69
|
+
debounceTimer = setTimeout(async () => {
|
|
70
|
+
await prefixLoader(client);
|
|
71
|
+
logInfo('Slash commands successfully reloaded after debounce.');
|
|
72
|
+
}, DEBOUNCE_DELAY);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
watch(commandPath, { recursive: false }, (eventType: any, filename: any) => {
|
|
76
|
+
if (filename && validExtensions.includes(extname(filename))) {
|
|
77
|
+
logInfo(`Detected ${eventType} in ${filename}, waiting for debouncing...`);
|
|
78
|
+
handleReload();
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
logInfo('Started watching for changes in slash commands...');
|
|
83
|
+
}
|
|
@@ -14,7 +14,7 @@ export async function loadSlash(client: any, token: string, options: SlashOption
|
|
|
14
14
|
const interactionCooldowns: Collection<Snowflake, Collection<string, number>> = new Collection();
|
|
15
15
|
|
|
16
16
|
client.on('interactionCreate', async (interaction: Interaction) => {
|
|
17
|
-
if (!interaction.isCommand() || !interaction.
|
|
17
|
+
if (!interaction.isCommand() || !interaction.isChatInputCommand()) {
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -82,12 +82,12 @@ export async function loadSlash(client: any, token: string, options: SlashOption
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
if (options.logsId) {
|
|
85
|
-
const channel = interaction.guild
|
|
85
|
+
const channel = interaction.guild?.channels.cache.get(options.logsId as string) as TextChannel;
|
|
86
86
|
if(channel) {
|
|
87
87
|
const userName = interaction.user.username;
|
|
88
88
|
const userId = interaction.user.id;
|
|
89
|
-
const serverName = interaction.guild
|
|
90
|
-
const serverId = interaction.guild
|
|
89
|
+
const serverName = interaction.guild?.name || 'Unknown Server';
|
|
90
|
+
const serverId = interaction.guild?.id || 'Unknown ID';
|
|
91
91
|
let messageLink = '';
|
|
92
92
|
|
|
93
93
|
if (interaction.channel) {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Collection } from 'discord.js';
|
|
1
|
+
import { Client, Collection } from 'discord.js';
|
|
2
2
|
import { REST } from '@discordjs/rest';
|
|
3
3
|
import { Routes } from 'discord-api-types/v10';
|
|
4
4
|
import { readdir } from 'fs/promises';
|
|
5
5
|
import { resolve, extname } from 'path';
|
|
6
6
|
import { botData } from './login';
|
|
7
7
|
import { logError, logInfo } from '../functions/logger';
|
|
8
|
+
import { watch } from 'fs';
|
|
8
9
|
|
|
9
10
|
const validExtensions = ['.js', '.ts'];
|
|
10
11
|
|
|
@@ -74,3 +75,30 @@ export async function slashLoader(client: any): Promise<{ commands: Collection<s
|
|
|
74
75
|
return { commands: new Collection<string, any>(), success: false };
|
|
75
76
|
}
|
|
76
77
|
}
|
|
78
|
+
|
|
79
|
+
export function autoSlashLoader(client: Client, DEBOUNCE_DELAY: number = 10000) {
|
|
80
|
+
|
|
81
|
+
const slashPath = botData.get('slashCommandPath') as string;
|
|
82
|
+
const commandPath = resolve(process.cwd(), slashPath);
|
|
83
|
+
|
|
84
|
+
let debounceTimer: NodeJS.Timeout | null = null;
|
|
85
|
+
|
|
86
|
+
const handleReload = async () => {
|
|
87
|
+
if (debounceTimer) {
|
|
88
|
+
clearTimeout(debounceTimer);
|
|
89
|
+
}
|
|
90
|
+
debounceTimer = setTimeout(async () => {
|
|
91
|
+
await slashLoader(client);
|
|
92
|
+
logInfo('Slash commands successfully reloaded after debounce.');
|
|
93
|
+
}, DEBOUNCE_DELAY);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
watch(commandPath, { recursive: false }, (eventType: any, filename: any) => {
|
|
97
|
+
if (filename && validExtensions.includes(extname(filename))) {
|
|
98
|
+
logInfo(`Detected ${eventType} in ${filename}, waiting for debouncing...`);
|
|
99
|
+
handleReload();
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
logInfo('Started watching for changes in slash commands...');
|
|
104
|
+
}
|