@spatulox/simplediscordbot 1.0.6 → 1.0.8
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/LICENSE.md +21 -21
- package/README.md +44 -44
- package/dist/bot/BotMessage.js +54 -28
- package/dist/index.js +6 -2
- package/dist/manager/builder/SendableComponentBuilder.js +62 -0
- package/dist/manager/direct/UserManager.js +16 -5
- package/dist/manager/guild/ChannelManager/GuildMessageManager.js +12 -4
- package/dist/manager/guild/ChannelManager/ThreadChannelManager.js +15 -0
- package/dist/manager/interactions/InteractionManager.js +68 -0
- package/dist/manager/{handlers/builder → interactions}/ModalManager.js +2 -2
- package/dist/manager/interactions/SelectMenuManager.js +123 -0
- package/dist/manager/messages/WebhookManager.js +8 -5
- package/dist/test/client.js +15 -0
- package/dist/test/index.js +26 -0
- package/dist/test/randomActivityList.js +9 -0
- package/package.json +40 -42
- package/dist/bot/Bot.d.ts +0 -32
- package/dist/bot/BotEnv.d.ts +0 -5
- package/dist/bot/BotLog.d.ts +0 -51
- package/dist/bot/BotMessage.d.ts +0 -16
- package/dist/cli/BaseCLI.d.ts +0 -25
- package/dist/cli/BaseCLI.js +0 -166
- package/dist/cli/GenerationCLI/ContextMenuGeneratorCLI.d.ts +0 -6
- package/dist/cli/GenerationCLI/ContextMenuGeneratorCLI.js +0 -109
- package/dist/cli/GenerationCLI/GenerationCLI.d.ts +0 -6
- package/dist/cli/GenerationCLI/GenerationCLI.js +0 -25
- package/dist/cli/GenerationCLI/ModalGeneratorCLI.d.ts +0 -44
- package/dist/cli/GenerationCLI/ModalGeneratorCLI.js +0 -166
- package/dist/cli/GenerationCLI/SlashCommandsGeneratorCLI.d.ts +0 -12
- package/dist/cli/GenerationCLI/SlashCommandsGeneratorCLI.js +0 -221
- package/dist/cli/GuildListManager.d.ts +0 -24
- package/dist/cli/GuildListManager.js +0 -61
- package/dist/cli/InteractionCLI/InteractionCLI.d.ts +0 -8
- package/dist/cli/InteractionCLI/InteractionCLI.js +0 -30
- package/dist/cli/InteractionCLI/InteractionCLIManager.d.ts +0 -17
- package/dist/cli/InteractionCLI/InteractionCLIManager.js +0 -80
- package/dist/cli/MainCLI.d.ts +0 -12
- package/dist/cli/MainCLI.js +0 -32
- package/dist/cli/type/ContextMenuConfig.d.ts +0 -12
- package/dist/cli/type/ContextMenuConfig.js +0 -2
- package/dist/cli/type/InteractionType.d.ts +0 -9
- package/dist/cli/type/InteractionType.js +0 -14
- package/dist/cli/type/SlashCommandConfig.d.ts +0 -43
- package/dist/cli/type/SlashCommandConfig.js +0 -2
- package/dist/index.d.ts +0 -14
- package/dist/manager/FileManager.d.ts +0 -36
- package/dist/manager/direct/UserManager.d.ts +0 -23
- package/dist/manager/guild/ChannelManager/ForumChannelManager.d.ts +0 -8
- package/dist/manager/guild/ChannelManager/GuildChannelList.d.ts +0 -16
- package/dist/manager/guild/ChannelManager/GuildChannelManager.d.ts +0 -17
- package/dist/manager/guild/ChannelManager/GuildMessageManager.d.ts +0 -21
- package/dist/manager/guild/ChannelManager/GuildTextChannelManager.d.ts +0 -8
- package/dist/manager/guild/ChannelManager/GuildVoiceChannelManager.d.ts +0 -8
- package/dist/manager/guild/ChannelManager/NewsChannelManager.d.ts +0 -8
- package/dist/manager/guild/ChannelManager/StageChannelManager.d.ts +0 -8
- package/dist/manager/guild/ChannelManager/ThreadChannelManager.d.ts +0 -8
- package/dist/manager/guild/GuildManager.d.ts +0 -30
- package/dist/manager/guild/GuildUserManager.d.ts +0 -46
- package/dist/manager/guild/InviteManager.d.ts +0 -20
- package/dist/manager/guild/InviteManager_old.d.ts +0 -23
- package/dist/manager/guild/RoleManager.d.ts +0 -23
- package/dist/manager/handlers/builder/ModalManager.d.ts +0 -22
- package/dist/manager/handlers/interactions/BaseInteractionManager.d.ts +0 -44
- package/dist/manager/handlers/interactions/BaseInteractionManager.js +0 -338
- package/dist/manager/handlers/interactions/InteractionManager.d.ts +0 -14
- package/dist/manager/handlers/interactions/InteractionManager.js +0 -29
- package/dist/manager/messages/EmbedManager.d.ts +0 -83
- package/dist/manager/messages/ReactionManager.d.ts +0 -25
- package/dist/manager/messages/WebhookManager.d.ts +0 -29
- package/dist/type/FolderName.d.ts +0 -5
- package/dist/utils/DiscordRegex.d.ts +0 -65
- package/dist/utils/Log.d.ts +0 -8
- package/dist/utils/SimpleMutex.d.ts +0 -15
- package/dist/utils/network/InternetChecker.d.ts +0 -9
- package/dist/utils/times/UnitTime.d.ts +0 -186
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
-
var ownKeys = function(o) {
|
|
21
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
-
var ar = [];
|
|
23
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
-
return ar;
|
|
25
|
-
};
|
|
26
|
-
return ownKeys(o);
|
|
27
|
-
};
|
|
28
|
-
return function (mod) {
|
|
29
|
-
if (mod && mod.__esModule) return mod;
|
|
30
|
-
var result = {};
|
|
31
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
-
__setModuleDefault(result, mod);
|
|
33
|
-
return result;
|
|
34
|
-
};
|
|
35
|
-
})();
|
|
36
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.BaseInteractionManager = exports.CommandType = void 0;
|
|
38
|
-
const rest_1 = require("@discordjs/rest");
|
|
39
|
-
const v10_1 = require("discord-api-types/v10");
|
|
40
|
-
const discord_js_1 = require("discord.js");
|
|
41
|
-
const fs = __importStar(require("fs/promises"));
|
|
42
|
-
const FileManager_1 = require("../../FileManager");
|
|
43
|
-
const Log_1 = require("../../../utils/Log");
|
|
44
|
-
var CommandType;
|
|
45
|
-
(function (CommandType) {
|
|
46
|
-
CommandType[CommandType["SLASH"] = 1] = "SLASH";
|
|
47
|
-
CommandType[CommandType["USER_CONTEXT_MENU"] = 2] = "USER_CONTEXT_MENU";
|
|
48
|
-
CommandType[CommandType["MESSAGE_CONTEXT_MENU"] = 3] = "MESSAGE_CONTEXT_MENU";
|
|
49
|
-
})(CommandType || (exports.CommandType = CommandType = {}));
|
|
50
|
-
class BaseInteractionManager {
|
|
51
|
-
constructor(clientId, token) {
|
|
52
|
-
this.clientId = clientId;
|
|
53
|
-
this.token = token;
|
|
54
|
-
this.rest = new rest_1.REST({ version: '10' }).setToken(token);
|
|
55
|
-
}
|
|
56
|
-
async listFromFile() {
|
|
57
|
-
console.log(`Listing Handlers (${this.folderPath}) not deployed on discord`);
|
|
58
|
-
try {
|
|
59
|
-
const files = await FileManager_1.FileManager.listJsonFiles(`./handlers/${this.folderPath}`);
|
|
60
|
-
if (!files || files.length === 0) {
|
|
61
|
-
console.log('No files found');
|
|
62
|
-
return [];
|
|
63
|
-
}
|
|
64
|
-
const commandList = [];
|
|
65
|
-
for (const [index, file] of files.entries()) {
|
|
66
|
-
const cmd = await this.readInteraction(`./handlers/${this.folderPath}/${file}`);
|
|
67
|
-
if (!cmd || cmd.id)
|
|
68
|
-
continue;
|
|
69
|
-
const commandWithIndex = {
|
|
70
|
-
...cmd,
|
|
71
|
-
index: index,
|
|
72
|
-
filename: file
|
|
73
|
-
};
|
|
74
|
-
commandList.push(commandWithIndex);
|
|
75
|
-
}
|
|
76
|
-
console.log(`✅ ${commandList.length} local ${this.folderPath}(s) not deployed\n`);
|
|
77
|
-
console.table(commandList.map((cmd) => ({
|
|
78
|
-
'#': cmd.index,
|
|
79
|
-
Nom: cmd.name,
|
|
80
|
-
Type: cmd.type === CommandType.SLASH ? 'Slash' :
|
|
81
|
-
cmd.type === CommandType.USER_CONTEXT_MENU ? 'User' : 'Message',
|
|
82
|
-
Description: cmd.description,
|
|
83
|
-
Fichier: cmd.filename
|
|
84
|
-
})));
|
|
85
|
-
return commandList;
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
Log_1.Log.error(`${error.message}`);
|
|
89
|
-
return [];
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
async fetchCommands(endpoint, scope, guildId, printResult = true) {
|
|
93
|
-
const scopeLabel = scope === 'global' ? 'global' : `guild ${scope}`;
|
|
94
|
-
console.log(`Handlers ${this.folderPath} on Discord (${scopeLabel})...`);
|
|
95
|
-
try {
|
|
96
|
-
const rawCmds = await this.rest.get(endpoint);
|
|
97
|
-
const commands = rawCmds.filter(cmd => this.commandType.includes(cmd.type));
|
|
98
|
-
const commandList = commands.map((cmd, index) => ({
|
|
99
|
-
index: index,
|
|
100
|
-
name: cmd.name,
|
|
101
|
-
type: cmd.type,
|
|
102
|
-
description: cmd.description || 'N/A',
|
|
103
|
-
default_member_permissions: cmd.default_member_permissions,
|
|
104
|
-
default_member_permissions_string: this.bitfieldToPermissions(cmd.default_member_permissions),
|
|
105
|
-
id: cmd.id,
|
|
106
|
-
...(guildId && { guildID: [guildId] })
|
|
107
|
-
}));
|
|
108
|
-
if (printResult) {
|
|
109
|
-
console.log(`✅ ${commandList.length} ${this.folderPath}(s) found\n`);
|
|
110
|
-
console.table(commandList.map((cmd) => ({
|
|
111
|
-
Nom: cmd.name,
|
|
112
|
-
Type: cmd.type === CommandType.SLASH ? 'Slash' :
|
|
113
|
-
cmd.type === CommandType.USER_CONTEXT_MENU ? 'User Context Menu' : 'Message Context Menu',
|
|
114
|
-
Description: cmd.description,
|
|
115
|
-
Permissions: cmd.default_member_permissions_string?.join(", "),
|
|
116
|
-
ID: cmd.id
|
|
117
|
-
})));
|
|
118
|
-
}
|
|
119
|
-
return commandList;
|
|
120
|
-
}
|
|
121
|
-
catch (error) {
|
|
122
|
-
const errorMsg = scope === 'global'
|
|
123
|
-
? `❌ Error: ${error.message}`
|
|
124
|
-
: `❌ Guild error ${scope}: ${error.message}`;
|
|
125
|
-
Log_1.Log.error(errorMsg);
|
|
126
|
-
return [];
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
async list() {
|
|
130
|
-
return this.fetchCommands(v10_1.Routes.applicationCommands(this.clientId), 'global');
|
|
131
|
-
}
|
|
132
|
-
async listGuild(guildID) {
|
|
133
|
-
return this.fetchCommands(v10_1.Routes.applicationGuildCommands(this.clientId, guildID), guildID, guildID);
|
|
134
|
-
}
|
|
135
|
-
async listAllGuilds(guilds) {
|
|
136
|
-
console.log("📡 Getting all guilds...\n");
|
|
137
|
-
console.log(`📋 ${guilds.length} guild(s) found\n`);
|
|
138
|
-
if (!guilds.length)
|
|
139
|
-
return [];
|
|
140
|
-
const guildCommandPromises = guilds.map(async (guild) => {
|
|
141
|
-
try {
|
|
142
|
-
const commands = await this.fetchCommands(v10_1.Routes.applicationGuildCommands(this.clientId, guild.id), guild.id, guild.id, false);
|
|
143
|
-
return {
|
|
144
|
-
guild: `${guild.name} (${guild.id})`,
|
|
145
|
-
guildId: guild.id,
|
|
146
|
-
commands,
|
|
147
|
-
count: commands.length
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
catch (error) {
|
|
151
|
-
console.error(`⚠️ Guild ${guild.id}: ${error.message}`);
|
|
152
|
-
return {
|
|
153
|
-
guild: `${guild.name} (${guild.id})`,
|
|
154
|
-
guildId: guild.id,
|
|
155
|
-
commands: [],
|
|
156
|
-
count: 0
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
const results = await Promise.all(guildCommandPromises);
|
|
161
|
-
console.log("\n📊 INTERACTION PER GUILD :\n");
|
|
162
|
-
console.table(results.map(r => ({
|
|
163
|
-
"Guild": r.guild,
|
|
164
|
-
"Interactions": r.count,
|
|
165
|
-
"Total": r.commands.length
|
|
166
|
-
})));
|
|
167
|
-
return results.filter(r => r.count > 0);
|
|
168
|
-
}
|
|
169
|
-
async deploy(commands) {
|
|
170
|
-
console.log(`Deploying ${commands.length} ${this.folderPath}(s)...`);
|
|
171
|
-
let updatedCount = 0;
|
|
172
|
-
for (const cmd of commands) {
|
|
173
|
-
const file = cmd.filename;
|
|
174
|
-
if (!file) {
|
|
175
|
-
Log_1.Log.error(`${cmd.name}: Not linked to a file (wtf)`);
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
try {
|
|
179
|
-
await this.deploySingleInteraction(cmd, file);
|
|
180
|
-
updatedCount++;
|
|
181
|
-
}
|
|
182
|
-
catch (error) {
|
|
183
|
-
Log_1.Log.error(`Error ${file}: ${error.message}`);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
console.log(`✅ ${updatedCount}/${commands.length} deployed`);
|
|
187
|
-
}
|
|
188
|
-
async delete(commands) {
|
|
189
|
-
console.log(`Deleting ${commands.length} ${this.folderPath}(s)...`);
|
|
190
|
-
const IDList = [];
|
|
191
|
-
for (const cmd of commands) {
|
|
192
|
-
if (!cmd.id) {
|
|
193
|
-
Log_1.Log.error(`${cmd.name}: No Discord ID, cannot delete the ${this.folderPath}`);
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
IDList.push(cmd.id);
|
|
197
|
-
try {
|
|
198
|
-
await this.rest.delete(v10_1.Routes.applicationCommand(this.clientId, cmd.id));
|
|
199
|
-
console.log(`${cmd.name} (${cmd.id.slice(-8)}) deleted`);
|
|
200
|
-
}
|
|
201
|
-
catch (error) {
|
|
202
|
-
Log_1.Log.error(`${cmd.name} (${cmd.id.slice(-8)}): ${error.message}`);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
await this.removeLocalIdFromFile(IDList);
|
|
206
|
-
}
|
|
207
|
-
async update(commands) {
|
|
208
|
-
console.log(`Updating ${commands.length} ${this.folderPath}(s)...`);
|
|
209
|
-
for (const cmd of commands) {
|
|
210
|
-
if (!cmd.id) {
|
|
211
|
-
Log_1.Log.error(`${cmd.name}: No Discord ID, cannot update the ${this.folderPath}`);
|
|
212
|
-
continue;
|
|
213
|
-
}
|
|
214
|
-
try {
|
|
215
|
-
await this.rest.patch(v10_1.Routes.applicationCommand(this.clientId, cmd.id), {
|
|
216
|
-
body: { description: `${cmd.description} (Updated ${new Date().toISOString()})` }
|
|
217
|
-
});
|
|
218
|
-
console.log(`${cmd.name} updated`);
|
|
219
|
-
}
|
|
220
|
-
catch (error) {
|
|
221
|
-
Log_1.Log.error(`${cmd.name}: ${error.message}`);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
async deploySingleInteraction(cmd, file) {
|
|
226
|
-
const deployToGuilds = cmd.guildID?.length ? cmd.guildID : [];
|
|
227
|
-
const dataToSend = { ...cmd };
|
|
228
|
-
delete dataToSend.guildID;
|
|
229
|
-
if (cmd.default_member_permissions_string && Array.isArray(cmd.default_member_permissions_string)) {
|
|
230
|
-
const bitfield = this.permissionsToBitfield(cmd.default_member_permissions_string);
|
|
231
|
-
if (bitfield !== undefined) {
|
|
232
|
-
dataToSend.default_member_permissions = bitfield;
|
|
233
|
-
cmd.default_member_permissions = bitfield;
|
|
234
|
-
}
|
|
235
|
-
else {
|
|
236
|
-
delete dataToSend.default_member_permissions;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
if (cmd.type === CommandType.MESSAGE_CONTEXT_MENU || cmd.type === CommandType.USER_CONTEXT_MENU) {
|
|
240
|
-
delete dataToSend.options;
|
|
241
|
-
}
|
|
242
|
-
// Guild deployment
|
|
243
|
-
if (deployToGuilds.length > 0) {
|
|
244
|
-
for (const guildId of deployToGuilds) {
|
|
245
|
-
try {
|
|
246
|
-
const guildCmds = await this.rest.get(v10_1.Routes.applicationGuildCommands(this.clientId, guildId));
|
|
247
|
-
const found = guildCmds.find((c) => c.name === cmd.name);
|
|
248
|
-
if (!cmd.id || !found) {
|
|
249
|
-
const resp = await this.rest.post(v10_1.Routes.applicationGuildCommands(this.clientId, guildId), { body: dataToSend });
|
|
250
|
-
cmd.id = resp.id;
|
|
251
|
-
await this.saveInteraction(file, cmd);
|
|
252
|
-
}
|
|
253
|
-
else {
|
|
254
|
-
await this.rest.patch(v10_1.Routes.applicationGuildCommand(this.clientId, guildId, found.id), { body: dataToSend });
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
catch (error) {
|
|
258
|
-
console.error(`⚠️ Guild ${guildId}: ${error.message}`);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
// Global deployment
|
|
264
|
-
try {
|
|
265
|
-
const globalCmds = await this.rest.get(v10_1.Routes.applicationCommands(this.clientId));
|
|
266
|
-
const found = globalCmds.find((c) => c.name === cmd.name);
|
|
267
|
-
if (!cmd.id || !found) {
|
|
268
|
-
const resp = await this.rest.post(v10_1.Routes.applicationCommands(this.clientId), { body: dataToSend });
|
|
269
|
-
cmd.id = resp.id;
|
|
270
|
-
await this.saveInteraction(file, cmd);
|
|
271
|
-
}
|
|
272
|
-
else {
|
|
273
|
-
await this.rest.patch(v10_1.Routes.applicationCommand(this.clientId, found.id), { body: dataToSend });
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
catch (error) {
|
|
277
|
-
console.error(`⚠️ Global: ${error.message}`);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
async readInteraction(filePath) {
|
|
282
|
-
try {
|
|
283
|
-
const data = await fs.readFile(filePath, 'utf8');
|
|
284
|
-
return JSON.parse(data);
|
|
285
|
-
}
|
|
286
|
-
catch {
|
|
287
|
-
return null;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
async saveInteraction(fileName, cmd) {
|
|
291
|
-
delete cmd.filename;
|
|
292
|
-
const filePath = `./handlers/${this.folderPath}/${fileName}`;
|
|
293
|
-
await fs.writeFile(filePath, JSON.stringify(cmd, null, 2));
|
|
294
|
-
}
|
|
295
|
-
async removeLocalIdFromFile(idListToDelete) {
|
|
296
|
-
const files = await FileManager_1.FileManager.listJsonFiles(`./handlers/${this.folderPath}`);
|
|
297
|
-
if (!files || files.length === 0) {
|
|
298
|
-
console.log('No local files to clean');
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
for (const file of files) {
|
|
302
|
-
const filePath = `./handlers/${this.folderPath}/${file}`;
|
|
303
|
-
const localCmd = await this.readInteraction(filePath);
|
|
304
|
-
if (localCmd && localCmd.id && idListToDelete.includes(localCmd.id)) {
|
|
305
|
-
delete localCmd.id;
|
|
306
|
-
await this.saveInteraction(file, localCmd);
|
|
307
|
-
break;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
permissionsToBitfield(perms) {
|
|
312
|
-
if (!perms || perms.length === 0)
|
|
313
|
-
return undefined;
|
|
314
|
-
let bits = 0n;
|
|
315
|
-
for (const name of perms) {
|
|
316
|
-
const value = discord_js_1.PermissionFlagsBits[name];
|
|
317
|
-
if (!value) {
|
|
318
|
-
console.warn(`Unknow permission in default_member_permissions: ${name}`);
|
|
319
|
-
continue;
|
|
320
|
-
}
|
|
321
|
-
bits |= value;
|
|
322
|
-
}
|
|
323
|
-
return bits.toString();
|
|
324
|
-
}
|
|
325
|
-
bitfieldToPermissions(bitfield) {
|
|
326
|
-
if (!bitfield)
|
|
327
|
-
return [];
|
|
328
|
-
const bits = BigInt(bitfield);
|
|
329
|
-
const result = [];
|
|
330
|
-
for (const [name, value] of Object.entries(discord_js_1.PermissionFlagsBits)) {
|
|
331
|
-
if ((bits & value) === value) {
|
|
332
|
-
result.push(name);
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
return result;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
exports.BaseInteractionManager = BaseInteractionManager;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { BaseInteractionManager } from "./BaseInteractionManager";
|
|
2
|
-
import { FolderName } from "../../../type/FolderName";
|
|
3
|
-
export declare class CommandManager extends BaseInteractionManager {
|
|
4
|
-
commandType: number[];
|
|
5
|
-
folderPath: FolderName;
|
|
6
|
-
}
|
|
7
|
-
export declare class ContextMenuManager extends BaseInteractionManager {
|
|
8
|
-
commandType: number[];
|
|
9
|
-
folderPath: FolderName;
|
|
10
|
-
}
|
|
11
|
-
export declare class AllInteractionManager extends BaseInteractionManager {
|
|
12
|
-
commandType: number[];
|
|
13
|
-
folderPath: undefined;
|
|
14
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AllInteractionManager = exports.ContextMenuManager = exports.CommandManager = void 0;
|
|
4
|
-
const BaseInteractionManager_1 = require("./BaseInteractionManager");
|
|
5
|
-
const FolderName_1 = require("../../../type/FolderName");
|
|
6
|
-
class CommandManager extends BaseInteractionManager_1.BaseInteractionManager {
|
|
7
|
-
constructor() {
|
|
8
|
-
super(...arguments);
|
|
9
|
-
this.commandType = [BaseInteractionManager_1.CommandType.SLASH];
|
|
10
|
-
this.folderPath = FolderName_1.FolderName.SLASH_COMMANDS;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.CommandManager = CommandManager;
|
|
14
|
-
class ContextMenuManager extends BaseInteractionManager_1.BaseInteractionManager {
|
|
15
|
-
constructor() {
|
|
16
|
-
super(...arguments);
|
|
17
|
-
this.commandType = [BaseInteractionManager_1.CommandType.USER_CONTEXT_MENU, BaseInteractionManager_1.CommandType.MESSAGE_CONTEXT_MENU];
|
|
18
|
-
this.folderPath = FolderName_1.FolderName.CONTEXT_MENU;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.ContextMenuManager = ContextMenuManager;
|
|
22
|
-
class AllInteractionManager extends BaseInteractionManager_1.BaseInteractionManager {
|
|
23
|
-
constructor() {
|
|
24
|
-
super(...arguments);
|
|
25
|
-
this.commandType = [BaseInteractionManager_1.CommandType.SLASH, BaseInteractionManager_1.CommandType.USER_CONTEXT_MENU, BaseInteractionManager_1.CommandType.MESSAGE_CONTEXT_MENU];
|
|
26
|
-
this.folderPath = undefined;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.AllInteractionManager = AllInteractionManager;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { EmbedBuilder, InteractionDeferReplyOptions } from "discord.js";
|
|
2
|
-
export declare enum EmbedColor {
|
|
3
|
-
error = 8912917,
|
|
4
|
-
success = 65280,
|
|
5
|
-
black = 0,
|
|
6
|
-
white = 16777215,
|
|
7
|
-
red = 16711680,
|
|
8
|
-
green = 65280,
|
|
9
|
-
blue = 255,
|
|
10
|
-
yellow = 16776960,
|
|
11
|
-
cyan = 65535,
|
|
12
|
-
magenta = 16711935,
|
|
13
|
-
gray = 8421504,
|
|
14
|
-
lightgray = 13882323,
|
|
15
|
-
darkgray = 11119017,
|
|
16
|
-
orange = 16753920,
|
|
17
|
-
purple = 8388736,
|
|
18
|
-
pink = 16761035,
|
|
19
|
-
brown = 10824234,
|
|
20
|
-
lime = 65280,
|
|
21
|
-
navy = 128,
|
|
22
|
-
teal = 32896,
|
|
23
|
-
olive = 8421376,
|
|
24
|
-
gold = 16766720,
|
|
25
|
-
silver = 12632256,
|
|
26
|
-
coral = 16744272,
|
|
27
|
-
salmon = 16416882,
|
|
28
|
-
khaki = 15787660,
|
|
29
|
-
plum = 14524637,
|
|
30
|
-
lavender = 15132410,
|
|
31
|
-
beige = 16119260,
|
|
32
|
-
mint = 10026904,
|
|
33
|
-
peach = 16767673,
|
|
34
|
-
chocolate = 13789470,
|
|
35
|
-
crimson = 14423100,
|
|
36
|
-
youtube = 16718362,
|
|
37
|
-
default = 6064856,
|
|
38
|
-
minecraft = 25600
|
|
39
|
-
}
|
|
40
|
-
export declare class EmbedManager {
|
|
41
|
-
private static get BOT_ICON();
|
|
42
|
-
private static get DEFAULT_COLOR();
|
|
43
|
-
/**
|
|
44
|
-
* Creates base embed - SAME SIMPLE API !
|
|
45
|
-
*/
|
|
46
|
-
static create(color?: EmbedColor | null): EmbedBuilder;
|
|
47
|
-
/**
|
|
48
|
-
* Creates simple embed with just description
|
|
49
|
-
*/
|
|
50
|
-
static simple(description: string, color?: EmbedColor | null): EmbedBuilder;
|
|
51
|
-
/**
|
|
52
|
-
* Creates error embed
|
|
53
|
-
*/
|
|
54
|
-
static error(description: string): EmbedBuilder;
|
|
55
|
-
/**
|
|
56
|
-
* Creates success embed
|
|
57
|
-
*/
|
|
58
|
-
static success(description: string): EmbedBuilder;
|
|
59
|
-
/**
|
|
60
|
-
* Creates success embed
|
|
61
|
-
*/
|
|
62
|
-
static description(description: string): EmbedBuilder;
|
|
63
|
-
/**
|
|
64
|
-
* Creates debug embed
|
|
65
|
-
*/
|
|
66
|
-
static debug(description: string): EmbedBuilder;
|
|
67
|
-
/**
|
|
68
|
-
* Defer ephemeral reply
|
|
69
|
-
*/
|
|
70
|
-
static deferEphemeral(): InteractionDeferReplyOptions;
|
|
71
|
-
/**
|
|
72
|
-
* Quick field adder
|
|
73
|
-
*/
|
|
74
|
-
static field(embed: EmbedBuilder, name: string, value: string, inline?: boolean): EmbedBuilder;
|
|
75
|
-
/**
|
|
76
|
-
* Fluent API shortcuts
|
|
77
|
-
*/
|
|
78
|
-
static title(embed: EmbedBuilder, title: string): EmbedBuilder;
|
|
79
|
-
static desc(embed: EmbedBuilder, description: string): EmbedBuilder;
|
|
80
|
-
static thumb(embed: EmbedBuilder, url: string): EmbedBuilder;
|
|
81
|
-
static image(embed: EmbedBuilder, url: string): EmbedBuilder;
|
|
82
|
-
static footer(embed: EmbedBuilder, text: string): EmbedBuilder;
|
|
83
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { User, EmojiResolvable } from 'discord.js';
|
|
2
|
-
export declare class ReactionManager {
|
|
3
|
-
/**
|
|
4
|
-
* Add a reaction to a message
|
|
5
|
-
*/
|
|
6
|
-
static add(channelId: string, messageId: string, emoji: string | EmojiResolvable): Promise<void>;
|
|
7
|
-
/**
|
|
8
|
-
* Delete a reaction from a user
|
|
9
|
-
*/
|
|
10
|
-
static remove(channelId: string, messageId: string, emoji: string, userId: string): Promise<void>;
|
|
11
|
-
/**
|
|
12
|
-
* Get all reaction of a message
|
|
13
|
-
*/
|
|
14
|
-
static getAll(channelId: string, messageId: string): Promise<Reaction[]>;
|
|
15
|
-
/**
|
|
16
|
-
* Delete all reaction
|
|
17
|
-
*/
|
|
18
|
-
static clear(channelId: string, messageId: string): Promise<void>;
|
|
19
|
-
}
|
|
20
|
-
interface Reaction {
|
|
21
|
-
emoji: any;
|
|
22
|
-
count: number;
|
|
23
|
-
users: User[];
|
|
24
|
-
}
|
|
25
|
-
export {};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { TextChannel, EmbedBuilder, Message, ThreadChannel, MessageCreateOptions } from 'discord.js';
|
|
2
|
-
export declare class WebhookManager {
|
|
3
|
-
private readonly channel;
|
|
4
|
-
private readonly name;
|
|
5
|
-
private readonly avatarURL?;
|
|
6
|
-
private webhook;
|
|
7
|
-
constructor(channel: TextChannel | ThreadChannel, name?: string, avatarURL?: string | undefined);
|
|
8
|
-
private get textChannel();
|
|
9
|
-
/**
|
|
10
|
-
* Get or create webhook (lazy initialization)
|
|
11
|
-
*/
|
|
12
|
-
private getWebhook;
|
|
13
|
-
/**
|
|
14
|
-
* Send message/text/embed - EmbedBuilder NATIVE !
|
|
15
|
-
*/
|
|
16
|
-
send(content: string | EmbedBuilder | MessageCreateOptions): Promise<Message | null>;
|
|
17
|
-
/**
|
|
18
|
-
* Quick success embed
|
|
19
|
-
*/
|
|
20
|
-
success(message: string): Promise<Message | null>;
|
|
21
|
-
/**
|
|
22
|
-
* Quick error embed
|
|
23
|
-
*/
|
|
24
|
-
error(message: string): Promise<Message | null>;
|
|
25
|
-
/**
|
|
26
|
-
* Delete webhook
|
|
27
|
-
*/
|
|
28
|
-
delete(reason?: string): Promise<void>;
|
|
29
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Classe utilitaire pour valider tous les formats Discord avec regex
|
|
3
|
-
*/
|
|
4
|
-
export declare class DiscordRegex {
|
|
5
|
-
static readonly SPACE = "\u200B";
|
|
6
|
-
static readonly URL_REGEX: RegExp;
|
|
7
|
-
static readonly USER_REGEX: RegExp;
|
|
8
|
-
static readonly BOT_REGEX: RegExp;
|
|
9
|
-
static readonly CHANNEL_REGEX: RegExp;
|
|
10
|
-
static readonly ROLE_REGEX: RegExp;
|
|
11
|
-
/**
|
|
12
|
-
* Mention a User
|
|
13
|
-
* Mention a Role
|
|
14
|
-
*/
|
|
15
|
-
static readonly DISCORD_PING_REGEX: RegExp;
|
|
16
|
-
/**
|
|
17
|
-
* Mention a User
|
|
18
|
-
* Mention a Role
|
|
19
|
-
* Mention a Channel
|
|
20
|
-
*/
|
|
21
|
-
static readonly DISCORD_MENTION_REGEX: RegExp;
|
|
22
|
-
static readonly USER_ID: RegExp;
|
|
23
|
-
static readonly CHANNEL_ID: RegExp;
|
|
24
|
-
static readonly GUILD_ID: RegExp;
|
|
25
|
-
static readonly BOT_ID: RegExp;
|
|
26
|
-
static readonly USERNAME: RegExp;
|
|
27
|
-
static readonly USERNAME_DISCRIM: RegExp;
|
|
28
|
-
static readonly CHANNEL_MENTION: RegExp;
|
|
29
|
-
static readonly USER_MENTION: RegExp;
|
|
30
|
-
static readonly ROLE_MENTION: RegExp;
|
|
31
|
-
static readonly INVITE: RegExp;
|
|
32
|
-
static readonly EMOJI: RegExp;
|
|
33
|
-
/**
|
|
34
|
-
* Validate Discord ID Discord (18)
|
|
35
|
-
*/
|
|
36
|
-
static isDiscordId(id: string): boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Validate a bot ID (19)
|
|
39
|
-
*/
|
|
40
|
-
static isBotMention(mention: string): boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Validate a User ping
|
|
43
|
-
*/
|
|
44
|
-
static isUserMention(mention: string): boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Validate a Discord username
|
|
47
|
-
*/
|
|
48
|
-
static isUsername(username: string): boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Type guard for Discord ID
|
|
51
|
-
*/
|
|
52
|
-
static isDiscordIdType(id: string): id is string;
|
|
53
|
-
/**
|
|
54
|
-
* Any Discord URL
|
|
55
|
-
*/
|
|
56
|
-
static isDiscordUrl(url: string): boolean;
|
|
57
|
-
/**
|
|
58
|
-
* Any discord mention
|
|
59
|
-
*/
|
|
60
|
-
static isAnyMention(text: string): boolean;
|
|
61
|
-
/**
|
|
62
|
-
* List all regex
|
|
63
|
-
*/
|
|
64
|
-
static listAll(): Record<string, RegExp | string>;
|
|
65
|
-
}
|
package/dist/utils/Log.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare class SimpleMutex {
|
|
2
|
-
private _locked;
|
|
3
|
-
private queue;
|
|
4
|
-
constructor();
|
|
5
|
-
/**
|
|
6
|
-
* Verrouille le mutex. Si le mutex est déjà verrouillé, la méthode retourne une promesse qui sera résolue une fois que le mutex sera disponible.
|
|
7
|
-
* @returns Une promesse résolue lorsque le mutex est verrouillé.
|
|
8
|
-
*/
|
|
9
|
-
lock(): Promise<void>;
|
|
10
|
-
/**
|
|
11
|
-
* Déverrouille le mutex. Si une file d'attente existe, débloque le prochain élément dans la file.
|
|
12
|
-
*/
|
|
13
|
-
unlock(): void;
|
|
14
|
-
get locked(): boolean;
|
|
15
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare class InternetChecker {
|
|
2
|
-
private static readonly TARGET;
|
|
3
|
-
private static readonly RETRY_TIME;
|
|
4
|
-
/**
|
|
5
|
-
* Check internet connection towards 1.1.1.1 (Cloudflare DNS)
|
|
6
|
-
* @param tries Number of attempts (0 = infini)
|
|
7
|
-
*/
|
|
8
|
-
static checkConnection(tries?: number): Promise<boolean>;
|
|
9
|
-
}
|