@spatulox/simplediscordbot 1.0.24 → 1.0.25
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/dist/SimpleDiscordBotInfo.d.ts +8 -0
- package/dist/SimpleDiscordBotInfo.d.ts.map +1 -0
- package/dist/SimpleDiscordBotInfo.js +14 -0
- package/dist/bot/Bot.d.ts +35 -0
- package/dist/bot/Bot.d.ts.map +1 -0
- package/dist/bot/Bot.js +92 -0
- package/dist/bot/BotEnv.d.ts +6 -0
- package/dist/bot/BotEnv.d.ts.map +1 -0
- package/dist/bot/BotEnv.js +24 -0
- package/dist/bot/BotInteraction.d.ts +21 -0
- package/dist/bot/BotInteraction.d.ts.map +1 -0
- package/dist/bot/BotInteraction.js +74 -0
- package/dist/bot/BotLog.d.ts +52 -0
- package/dist/bot/BotLog.d.ts.map +1 -0
- package/dist/bot/BotLog.js +134 -0
- package/dist/bot/BotMessage.d.ts +20 -0
- package/dist/bot/BotMessage.d.ts.map +1 -0
- package/dist/bot/BotMessage.js +110 -0
- package/dist/manager/FileManager.d.ts +37 -0
- package/dist/manager/FileManager.d.ts.map +1 -0
- package/dist/manager/FileManager.js +136 -0
- package/dist/manager/builder/SendableComponentBuilder.d.ts +13 -0
- package/dist/manager/builder/SendableComponentBuilder.d.ts.map +1 -0
- package/dist/manager/builder/SendableComponentBuilder.js +62 -0
- package/dist/manager/direct/BasicUserManager.d.ts +28 -0
- package/dist/manager/direct/BasicUserManager.d.ts.map +1 -0
- package/dist/manager/direct/BasicUserManager.js +81 -0
- package/dist/manager/direct/UserManager.d.ts +6 -0
- package/dist/manager/direct/UserManager.d.ts.map +1 -0
- package/dist/manager/direct/UserManager.js +18 -0
- package/dist/manager/guild/ChannelManager/ForumChannelManager.d.ts +9 -0
- package/dist/manager/guild/ChannelManager/ForumChannelManager.d.ts.map +1 -0
- package/dist/manager/guild/ChannelManager/ForumChannelManager.js +33 -0
- package/dist/manager/guild/ChannelManager/GuildChannelList.d.ts +17 -0
- package/dist/manager/guild/ChannelManager/GuildChannelList.d.ts.map +1 -0
- package/dist/manager/guild/ChannelManager/GuildChannelList.js +20 -0
- package/dist/manager/guild/ChannelManager/GuildChannelManager.d.ts +18 -0
- package/dist/manager/guild/ChannelManager/GuildChannelManager.d.ts.map +1 -0
- package/dist/manager/guild/ChannelManager/GuildChannelManager.js +91 -0
- package/dist/manager/guild/ChannelManager/GuildMessageManager.d.ts +23 -0
- package/dist/manager/guild/ChannelManager/GuildMessageManager.d.ts.map +1 -0
- package/dist/manager/guild/ChannelManager/GuildMessageManager.js +93 -0
- package/dist/manager/guild/ChannelManager/GuildTextChannelManager.d.ts +9 -0
- package/dist/manager/guild/ChannelManager/GuildTextChannelManager.d.ts.map +1 -0
- package/dist/manager/guild/ChannelManager/GuildTextChannelManager.js +33 -0
- package/dist/manager/guild/ChannelManager/GuildVoiceChannelManager.d.ts +9 -0
- package/dist/manager/guild/ChannelManager/GuildVoiceChannelManager.d.ts.map +1 -0
- package/dist/manager/guild/ChannelManager/GuildVoiceChannelManager.js +33 -0
- package/dist/manager/guild/ChannelManager/NewsChannelManager.d.ts +9 -0
- package/dist/manager/guild/ChannelManager/NewsChannelManager.d.ts.map +1 -0
- package/dist/manager/guild/ChannelManager/NewsChannelManager.js +33 -0
- package/dist/manager/guild/ChannelManager/StageChannelManager.d.ts +9 -0
- package/dist/manager/guild/ChannelManager/StageChannelManager.d.ts.map +1 -0
- package/dist/manager/guild/ChannelManager/StageChannelManager.js +33 -0
- package/dist/manager/guild/ChannelManager/ThreadChannelManager.d.ts +13 -0
- package/dist/manager/guild/ChannelManager/ThreadChannelManager.d.ts.map +1 -0
- package/dist/manager/guild/ChannelManager/ThreadChannelManager.js +49 -0
- package/dist/manager/guild/GuildManager.d.ts +32 -0
- package/dist/manager/guild/GuildManager.d.ts.map +1 -0
- package/dist/manager/guild/GuildManager.js +144 -0
- package/dist/manager/guild/GuildUserManager.d.ts +49 -0
- package/dist/manager/guild/GuildUserManager.d.ts.map +1 -0
- package/dist/manager/guild/GuildUserManager.js +251 -0
- package/dist/manager/guild/InviteManager.d.ts +21 -0
- package/dist/manager/guild/InviteManager.d.ts.map +1 -0
- package/dist/manager/guild/InviteManager.js +68 -0
- package/dist/manager/guild/InviteManager_old.d.ts +24 -0
- package/dist/manager/guild/InviteManager_old.d.ts.map +1 -0
- package/dist/manager/guild/InviteManager_old.js +89 -0
- package/dist/manager/guild/RoleManager.d.ts +24 -0
- package/dist/manager/guild/RoleManager.d.ts.map +1 -0
- package/dist/manager/guild/RoleManager.js +83 -0
- package/dist/manager/interactions/ModalManager.d.ts +23 -0
- package/dist/manager/interactions/ModalManager.d.ts.map +1 -0
- package/dist/manager/interactions/ModalManager.js +113 -0
- package/dist/manager/interactions/SelectMenuManager.d.ts +58 -0
- package/dist/manager/interactions/SelectMenuManager.d.ts.map +1 -0
- package/dist/manager/interactions/SelectMenuManager.js +123 -0
- package/dist/manager/messages/EmbedManager.d.ts +97 -0
- package/dist/manager/messages/EmbedManager.d.ts.map +1 -0
- package/dist/manager/messages/EmbedManager.js +161 -0
- package/dist/manager/messages/ReactionManager.d.ts +26 -0
- package/dist/manager/messages/ReactionManager.d.ts.map +1 -0
- package/dist/manager/messages/ReactionManager.js +99 -0
- package/dist/manager/messages/WebhookManager.d.ts +33 -0
- package/dist/manager/messages/WebhookManager.d.ts.map +1 -0
- package/dist/manager/messages/WebhookManager.js +108 -0
- package/dist/test/client.d.ts +3 -0
- package/dist/test/client.d.ts.map +1 -0
- package/dist/test/client.js +15 -0
- package/dist/test/index.d.ts +2 -0
- package/dist/test/index.d.ts.map +1 -0
- package/dist/test/index.js +31 -0
- package/dist/test/randomActivityList.d.ts +3 -0
- package/dist/test/randomActivityList.d.ts.map +1 -0
- package/dist/test/randomActivityList.js +9 -0
- package/dist/type/FolderName.d.ts +6 -0
- package/dist/type/FolderName.d.ts.map +1 -0
- package/dist/type/FolderName.js +9 -0
- package/dist/utils/DiscordRegex.d.ts +66 -0
- package/dist/utils/DiscordRegex.d.ts.map +1 -0
- package/dist/utils/DiscordRegex.js +117 -0
- package/dist/utils/Log.d.ts +9 -0
- package/dist/utils/Log.d.ts.map +1 -0
- package/dist/utils/Log.js +28 -0
- package/dist/utils/SimpleMutex.d.ts +16 -0
- package/dist/utils/SimpleMutex.d.ts.map +1 -0
- package/dist/utils/SimpleMutex.js +39 -0
- package/dist/utils/network/InternetChecker.d.ts +10 -0
- package/dist/utils/network/InternetChecker.d.ts.map +1 -0
- package/dist/utils/network/InternetChecker.js +54 -0
- package/dist/utils/times/UnitTime.d.ts +187 -0
- package/dist/utils/times/UnitTime.d.ts.map +1 -0
- package/dist/utils/times/UnitTime.js +85 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileManager.d.ts","sourceRoot":"","sources":["../../src/manager/FileManager.ts"],"names":[],"mappings":"AAOA,qBAAa,WAAW;IACpB;;;;OAIG;WACU,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,GAAG,KAAK,CAAC;IAUjE;;;;OAIG;WACU,eAAe,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC;IAa9E;;;;OAIG;WACU,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC;IAU5E;;;;;OAKG;WACU,SAAS,CAAC,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC;IAoB3F;;;;;;;OAOG;WACU,aAAa,CACtB,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,GAAG,EACT,uBAAuB,GAAE,OAAc,GACxC,OAAO,CAAC,OAAO,CAAC;CA4CtB"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FileManager = void 0;
|
|
7
|
+
// src/filesystem/FileManager.ts
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
10
|
+
const Log_1 = require("../utils/Log");
|
|
11
|
+
const Bot_1 = require("../bot/Bot");
|
|
12
|
+
const EmbedManager_1 = require("./messages/EmbedManager");
|
|
13
|
+
class FileManager {
|
|
14
|
+
/**
|
|
15
|
+
* Reads a JSON file synchronously.
|
|
16
|
+
* @param filePath Full path to the JSON file
|
|
17
|
+
* @returns Parsed JSON object or 'Error' string on failure
|
|
18
|
+
*/
|
|
19
|
+
static async readJsonFile(filePath) {
|
|
20
|
+
try {
|
|
21
|
+
const data = await promises_1.default.readFile(filePath, 'utf8');
|
|
22
|
+
return JSON.parse(data);
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
Log_1.Log.error(`Failed to read JSON file ${filePath}: ${error}`);
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Lists all directories in a given path.
|
|
31
|
+
* @param directoryPath Path to scan for directories
|
|
32
|
+
* @returns Array of directory names or false on error
|
|
33
|
+
*/
|
|
34
|
+
static async listDirectories(directoryPath) {
|
|
35
|
+
try {
|
|
36
|
+
const files = await promises_1.default.readdir(directoryPath, { withFileTypes: true });
|
|
37
|
+
const directories = files
|
|
38
|
+
.filter(file => file.isDirectory())
|
|
39
|
+
.map(dir => dir.name);
|
|
40
|
+
return directories;
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
Log_1.Log.error(`Failed to read directory ${directoryPath}: ${error}`);
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Lists all JSON files in a directory.
|
|
49
|
+
* @param directoryPath Path to scan for JSON files
|
|
50
|
+
* @returns Array of JSON filenames or false on error
|
|
51
|
+
*/
|
|
52
|
+
static async listJsonFiles(directoryPath) {
|
|
53
|
+
try {
|
|
54
|
+
const files = await promises_1.default.readdir(directoryPath);
|
|
55
|
+
return files.filter(file => path_1.default.extname(file) === '.json');
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
Log_1.Log.error(`Failed to read directory ${directoryPath}: ${error}`);
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Lists files with specific extension in a directory.
|
|
64
|
+
* @param directoryPath Path to scan
|
|
65
|
+
* @param extension File extension (with or without dot)
|
|
66
|
+
* @returns Array of matching filenames or 'Error' string on failure
|
|
67
|
+
*/
|
|
68
|
+
static async listFiles(directoryPath, extension) {
|
|
69
|
+
if (typeof directoryPath !== 'string' || typeof extension !== 'string') {
|
|
70
|
+
Log_1.Log.error('Directory path and extension must be strings');
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
let ext = extension;
|
|
75
|
+
if (ext.startsWith('.')) {
|
|
76
|
+
ext = ext.slice(1);
|
|
77
|
+
}
|
|
78
|
+
const files = await promises_1.default.readdir(directoryPath);
|
|
79
|
+
return files.filter(file => path_1.default.extname(file) === `.${ext}`);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
Log_1.Log.error(`Failed to read directory ${directoryPath}: ${error}`);
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Creates directory structure and writes JSON data to file.
|
|
88
|
+
* @param directoryPath Full directory path (creates if missing)
|
|
89
|
+
* @param filename Filename without extension
|
|
90
|
+
* @param data Data to write (JSON serializable)
|
|
91
|
+
* @param sendErrorToErrorChannel Send error to the error channel
|
|
92
|
+
* @returns true on success, false on failure
|
|
93
|
+
*/
|
|
94
|
+
static async writeJsonFile(directoryPath, filename, data, sendErrorToErrorChannel = true) {
|
|
95
|
+
// Skip if data is an Error array
|
|
96
|
+
if (Array.isArray(data) && data.length === 1 && data[0] === 'Error') {
|
|
97
|
+
Log_1.Log.error(`Cannot save data for ${filename}: data contains 'Error'`);
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
// Create directory structure recursively
|
|
102
|
+
const directories = directoryPath.split(path_1.default.sep).filter(Boolean);
|
|
103
|
+
let currentPath = '';
|
|
104
|
+
for (const dir of directories) {
|
|
105
|
+
currentPath = path_1.default.join(currentPath, dir);
|
|
106
|
+
try {
|
|
107
|
+
await promises_1.default.access(currentPath);
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
await promises_1.default.mkdir(currentPath, { recursive: true });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (!filename || filename.trim() === '') {
|
|
114
|
+
Log_1.Log.error('Cannot write JSON file: empty filename');
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
const cleanFilename = filename.replace(/\.json$/i, '');
|
|
118
|
+
const filePath = path_1.default.join(directoryPath, `${cleanFilename}.json`);
|
|
119
|
+
const jsonContent = JSON.stringify(data, null, 2);
|
|
120
|
+
await promises_1.default.writeFile(filePath, jsonContent);
|
|
121
|
+
Log_1.Log.info(`Successfully wrote data to ${filePath}`);
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
const cleanFilename = filename.replace(/\.json$/i, '') || 'unknown';
|
|
126
|
+
if (sendErrorToErrorChannel) {
|
|
127
|
+
await Bot_1.Bot.log.info(EmbedManager_1.EmbedManager.error(`Failed to write file ${directoryPath}/${cleanFilename}.json: ${error}`));
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
Log_1.Log.error(`Failed to write file ${directoryPath}/${cleanFilename}.json: ${error}`);
|
|
131
|
+
}
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.FileManager = FileManager;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ActionRowBuilder, EmbedBuilder, InteractionReplyOptions, InteractionUpdateOptions, MessageCreateOptions, MessageActionRowComponentBuilder } from "discord.js";
|
|
2
|
+
export type SendableComponent = EmbedBuilder | ActionRowBuilder<MessageActionRowComponentBuilder>;
|
|
3
|
+
export declare class SendableComponentBuilder {
|
|
4
|
+
static isSendableComponent(thing: any): boolean;
|
|
5
|
+
private static build;
|
|
6
|
+
static buildInteraction(content: string): InteractionReplyOptions | InteractionUpdateOptions;
|
|
7
|
+
static buildInteraction(component: SendableComponent | SendableComponent[]): InteractionReplyOptions | InteractionUpdateOptions;
|
|
8
|
+
static buildInteraction(content?: string | null, component?: SendableComponent | SendableComponent[] | null, ephemeral?: boolean): InteractionReplyOptions | InteractionUpdateOptions;
|
|
9
|
+
static buildMessage(content: string): MessageCreateOptions;
|
|
10
|
+
static buildMessage(component: SendableComponent | SendableComponent[]): MessageCreateOptions;
|
|
11
|
+
static buildMessage(content: string, component: SendableComponent | SendableComponent[]): MessageCreateOptions;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=SendableComponentBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SendableComponentBuilder.d.ts","sourceRoot":"","sources":["../../../src/manager/builder/SendableComponentBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAChB,YAAY,EACZ,uBAAuB,EACvB,wBAAwB,EAAE,oBAAoB,EAE9C,gCAAgC,EACnC,MAAM,YAAY,CAAC;AASpB,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,gBAAgB,CAAC,gCAAgC,CAAC,CAAC;AAElG,qBAAa,wBAAwB;IAEjC,MAAM,CAAC,mBAAmB,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO;IAI/C,OAAO,CAAC,MAAM,CAAC,KAAK;IAyBpB,MAAM,CAAC,gBAAgB,CAAE,OAAO,EAAE,MAAM,GAAG,uBAAuB,GAAG,wBAAwB;IAC7F,MAAM,CAAC,gBAAgB,CAAE,SAAS,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,GAAG,uBAAuB,GAAG,wBAAwB;IAChI,MAAM,CAAC,gBAAgB,CAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,SAAS,CAAC,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,GAAG,IAAI,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAAG,wBAAwB;IAgCtL,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB;IAC1D,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,GAAG,oBAAoB;IAC7F,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,GAAG,oBAAoB;CA0BjH"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SendableComponentBuilder = void 0;
|
|
4
|
+
const discord_js_1 = require("discord.js");
|
|
5
|
+
class SendableComponentBuilder {
|
|
6
|
+
static isSendableComponent(thing) {
|
|
7
|
+
return thing instanceof discord_js_1.EmbedBuilder || thing instanceof discord_js_1.ActionRowBuilder;
|
|
8
|
+
}
|
|
9
|
+
static build(base, content, components) {
|
|
10
|
+
if (content) {
|
|
11
|
+
base.content = content;
|
|
12
|
+
}
|
|
13
|
+
const comps = Array.isArray(components) ? components : [components].filter(Boolean);
|
|
14
|
+
for (const comp of comps) {
|
|
15
|
+
if (comp instanceof discord_js_1.EmbedBuilder) {
|
|
16
|
+
base.embeds = base.embeds || [];
|
|
17
|
+
base.embeds.push(comp);
|
|
18
|
+
}
|
|
19
|
+
if (comp instanceof discord_js_1.ActionRowBuilder) {
|
|
20
|
+
base.components = base.components || [];
|
|
21
|
+
base.components.push(comp);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return base;
|
|
25
|
+
}
|
|
26
|
+
static buildInteraction(contentOrComponent, component, ephemeral = false) {
|
|
27
|
+
let base = {};
|
|
28
|
+
// Case 1
|
|
29
|
+
if (typeof contentOrComponent === 'string' && !component) {
|
|
30
|
+
base = this.build(base, contentOrComponent);
|
|
31
|
+
}
|
|
32
|
+
// Case 2
|
|
33
|
+
if (typeof contentOrComponent !== 'string' && !component) {
|
|
34
|
+
base = this.build(base, null, contentOrComponent);
|
|
35
|
+
}
|
|
36
|
+
// Cas 3: content and component not null
|
|
37
|
+
if (contentOrComponent && typeof contentOrComponent === 'string' && component) {
|
|
38
|
+
base = this.build(base, contentOrComponent, component);
|
|
39
|
+
}
|
|
40
|
+
if (ephemeral) {
|
|
41
|
+
base.flags = [discord_js_1.MessageFlags.Ephemeral];
|
|
42
|
+
}
|
|
43
|
+
return base;
|
|
44
|
+
}
|
|
45
|
+
static buildMessage(contentOrComponent, component) {
|
|
46
|
+
let base = {};
|
|
47
|
+
// Case 1
|
|
48
|
+
if (typeof contentOrComponent === 'string' && !component) {
|
|
49
|
+
return this.build(base, contentOrComponent);
|
|
50
|
+
}
|
|
51
|
+
// Case 2
|
|
52
|
+
if (typeof contentOrComponent !== 'string' && !component) {
|
|
53
|
+
return this.build(base, null, contentOrComponent);
|
|
54
|
+
}
|
|
55
|
+
// Case 3
|
|
56
|
+
if (typeof contentOrComponent == 'string' && component) {
|
|
57
|
+
return this.build(base, contentOrComponent, component);
|
|
58
|
+
}
|
|
59
|
+
throw new Error("At least content or component need to be defined to build a message");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.SendableComponentBuilder = SendableComponentBuilder;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { GuildMember, Message, MessageCreateOptions, User } from "discord.js";
|
|
2
|
+
import { SendableComponent } from "../builder/SendableComponentBuilder";
|
|
3
|
+
export declare abstract class BasicUserManager {
|
|
4
|
+
/**
|
|
5
|
+
* Find member in specific guild
|
|
6
|
+
*/
|
|
7
|
+
static findInGuild(guildId: string, memberId: string): Promise<GuildMember | null>;
|
|
8
|
+
/**
|
|
9
|
+
* Check if user is still in guild
|
|
10
|
+
*/
|
|
11
|
+
static isInGuild(guildId: string, userId: string): Promise<boolean>;
|
|
12
|
+
/**
|
|
13
|
+
* Overload for send
|
|
14
|
+
*/
|
|
15
|
+
static send(user_id: string, content: string): Promise<Message>;
|
|
16
|
+
static send(user: User, content: string): Promise<Message>;
|
|
17
|
+
static send(user: GuildMember, content: string): Promise<Message>;
|
|
18
|
+
static send(user_id: string, component: SendableComponent | SendableComponent[]): Promise<Message>;
|
|
19
|
+
static send(user: User, component: SendableComponent | SendableComponent[]): Promise<Message>;
|
|
20
|
+
static send(user: GuildMember, component: SendableComponent | SendableComponent[]): Promise<Message>;
|
|
21
|
+
static send(user_id: string, content: string, component: SendableComponent | SendableComponent[]): Promise<Message>;
|
|
22
|
+
static send(user: User, content: string, component: SendableComponent | SendableComponent[]): Promise<Message>;
|
|
23
|
+
static send(user: GuildMember, content: string, component: SendableComponent | SendableComponent[]): Promise<Message>;
|
|
24
|
+
static send(user_id_or_user: string, options: MessageCreateOptions): Promise<Message>;
|
|
25
|
+
static send(user_id_or_user: User, options: MessageCreateOptions): Promise<Message>;
|
|
26
|
+
static send(user_id_or_user: GuildMember, options: MessageCreateOptions): Promise<Message>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=BasicUserManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasicUserManager.d.ts","sourceRoot":"","sources":["../../../src/manager/direct/BasicUserManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,OAAO,EAAE,oBAAoB,EAAE,IAAI,EAAC,MAAM,YAAY,CAAC;AAG5E,OAAO,EAAC,iBAAiB,EAA2B,MAAM,qCAAqC,CAAC;AAEhG,8BAAsB,gBAAgB;IAElC;;OAEG;WACU,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAaxF;;OAEG;WACU,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAYzE;;OAEG;WAEU,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;WACxD,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;WACnD,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;WAE1D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;WAC3F,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;WACtF,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;WAC7F,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;WAC5G,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;WACvG,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;WAE9G,IAAI,CAAC,eAAe,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC;WAC9E,IAAI,CAAC,eAAe,EAAE,IAAI,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC;WAC5E,IAAI,CAAC,eAAe,EAAE,WAAW,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC;CAiDnG"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BasicUserManager = void 0;
|
|
4
|
+
const discord_js_1 = require("discord.js");
|
|
5
|
+
const Bot_1 = require("../../bot/Bot");
|
|
6
|
+
const Log_1 = require("../../utils/Log");
|
|
7
|
+
const SendableComponentBuilder_1 = require("../builder/SendableComponentBuilder");
|
|
8
|
+
class BasicUserManager {
|
|
9
|
+
/**
|
|
10
|
+
* Find member in specific guild
|
|
11
|
+
*/
|
|
12
|
+
static async findInGuild(guildId, memberId) {
|
|
13
|
+
try {
|
|
14
|
+
const guild = Bot_1.Bot.client.guilds.cache.get(guildId);
|
|
15
|
+
if (!guild)
|
|
16
|
+
throw new Error(`Guild ${guildId} not found`);
|
|
17
|
+
const member = await guild.members.fetch({ user: memberId, force: true });
|
|
18
|
+
return member ?? null;
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
Log_1.Log.error(`UserManager: Member ${memberId} not found in ${guildId}`);
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Check if user is still in guild
|
|
27
|
+
*/
|
|
28
|
+
static async isInGuild(guildId, userId) {
|
|
29
|
+
try {
|
|
30
|
+
const guild = Bot_1.Bot.client.guilds.cache.get(guildId);
|
|
31
|
+
if (!guild)
|
|
32
|
+
return false;
|
|
33
|
+
await guild.members.fetch({ user: userId, force: true });
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
return error.code !== 10007; // Unknown Member
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Impl
|
|
42
|
+
*/
|
|
43
|
+
static async send(user_id_or_user, content_or_component_or_options, component) {
|
|
44
|
+
try {
|
|
45
|
+
let user;
|
|
46
|
+
if (typeof user_id_or_user === 'string') {
|
|
47
|
+
user = await Bot_1.Bot.client.users.fetch(user_id_or_user);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
user = user_id_or_user;
|
|
51
|
+
}
|
|
52
|
+
const dmChannel = await user.createDM();
|
|
53
|
+
let payload;
|
|
54
|
+
if (component && typeof content_or_component_or_options == "string") { // component + content
|
|
55
|
+
payload = SendableComponentBuilder_1.SendableComponentBuilder.buildMessage(content_or_component_or_options, component);
|
|
56
|
+
}
|
|
57
|
+
else if (typeof content_or_component_or_options === 'string') { // content only
|
|
58
|
+
payload = SendableComponentBuilder_1.SendableComponentBuilder.buildMessage(content_or_component_or_options);
|
|
59
|
+
}
|
|
60
|
+
else if (SendableComponentBuilder_1.SendableComponentBuilder.isSendableComponent(content_or_component_or_options)) { // component only
|
|
61
|
+
payload = SendableComponentBuilder_1.SendableComponentBuilder.buildMessage(content_or_component_or_options);
|
|
62
|
+
}
|
|
63
|
+
else { // MessageCreationOptionOnly
|
|
64
|
+
payload = content_or_component_or_options;
|
|
65
|
+
}
|
|
66
|
+
const message = await dmChannel.send(payload);
|
|
67
|
+
if (user instanceof discord_js_1.GuildMember) {
|
|
68
|
+
Log_1.Log.info(`Sent DM to ${user.id} (${user.user.username}): "${(payload.content || 'Embed/Component').substring(0, 50)}..."`);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
Log_1.Log.info(`Sent DM to ${user.id} (${user.username}): "${(payload.content || 'Embed/Component').substring(0, 50)}..."`);
|
|
72
|
+
}
|
|
73
|
+
return message;
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
Log_1.Log.error(`Failed to send DM to ${user_id_or_user}: ${error}`);
|
|
77
|
+
throw new Error(`Cannot send DM to ${user_id_or_user}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.BasicUserManager = BasicUserManager;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserManager.d.ts","sourceRoot":"","sources":["../../../src/manager/direct/UserManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAC,IAAI,EAAC,MAAM,YAAY,CAAC;AAGhC,qBAAa,WAAY,SAAQ,gBAAgB;WAChC,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;CAQ1D"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserManager = void 0;
|
|
4
|
+
const BasicUserManager_1 = require("./BasicUserManager");
|
|
5
|
+
const Bot_1 = require("../../bot/Bot");
|
|
6
|
+
const Log_1 = require("../../utils/Log");
|
|
7
|
+
class UserManager extends BasicUserManager_1.BasicUserManager {
|
|
8
|
+
static async find(userId) {
|
|
9
|
+
try {
|
|
10
|
+
return await Bot_1.Bot.client.users.fetch(userId);
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
Log_1.Log.error(`UserManager: Member ${userId} not found`);
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.UserManager = UserManager;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GuildChannelManager } from "./GuildChannelManager";
|
|
2
|
+
import { ForumChannel, GuildChannelCreateOptions } from "discord.js";
|
|
3
|
+
export declare class ForumChannelManager extends GuildChannelManager {
|
|
4
|
+
static findInGuild(guildId: string, channelId: string): Promise<ForumChannel | null>;
|
|
5
|
+
static find(channelId: string): Promise<ForumChannel | null>;
|
|
6
|
+
static findAll(guildId: string): ForumChannel[];
|
|
7
|
+
static create(guildId: string, name: string, options?: Omit<GuildChannelCreateOptions, 'type'>): Promise<ForumChannel>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=ForumChannelManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ForumChannelManager.d.ts","sourceRoot":"","sources":["../../../../src/manager/guild/ChannelManager/ForumChannelManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAc,YAAY,EAAE,yBAAyB,EAAC,MAAM,YAAY,CAAC;AAIhF,qBAAa,mBAAoB,SAAQ,mBAAmB;WAC3C,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;WAK7E,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAKlE,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,EAAE;WAUlC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,yBAAyB,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC;CAO/H"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ForumChannelManager = void 0;
|
|
4
|
+
const GuildChannelManager_1 = require("./GuildChannelManager");
|
|
5
|
+
const discord_js_1 = require("discord.js");
|
|
6
|
+
const Bot_1 = require("../../../bot/Bot");
|
|
7
|
+
const Log_1 = require("../../../utils/Log");
|
|
8
|
+
class ForumChannelManager extends GuildChannelManager_1.GuildChannelManager {
|
|
9
|
+
static async findInGuild(guildId, channelId) {
|
|
10
|
+
const channel = await super.findInGuild(guildId, channelId);
|
|
11
|
+
return channel instanceof discord_js_1.ForumChannel ? channel : null;
|
|
12
|
+
}
|
|
13
|
+
static async find(channelId) {
|
|
14
|
+
const channel = await super.find(channelId);
|
|
15
|
+
return channel instanceof discord_js_1.ForumChannel ? channel : null;
|
|
16
|
+
}
|
|
17
|
+
static findAll(guildId) {
|
|
18
|
+
const guild = Bot_1.Bot.client.guilds.cache.get(guildId);
|
|
19
|
+
if (!guild) {
|
|
20
|
+
Log_1.Log.warn(`Guild ${guildId} not found`);
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
return Array.from(guild.channels.cache.values()).filter(c => c instanceof discord_js_1.ForumChannel);
|
|
24
|
+
}
|
|
25
|
+
static async create(guildId, name, options) {
|
|
26
|
+
return await super._create(guildId, {
|
|
27
|
+
name,
|
|
28
|
+
type: discord_js_1.ChannelType.GuildForum,
|
|
29
|
+
...options
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.ForumChannelManager = ForumChannelManager;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GuildChannelManager } from "./GuildChannelManager";
|
|
2
|
+
import { ForumChannelManager } from "./ForumChannelManager";
|
|
3
|
+
import { NewsChannelManager } from "./NewsChannelManager";
|
|
4
|
+
import { StageChannelManager } from "./StageChannelManager";
|
|
5
|
+
import { GuildTextChannelManager } from "./GuildTextChannelManager";
|
|
6
|
+
import { ThreadChannelManager } from "./ThreadChannelManager";
|
|
7
|
+
import { GuildVoiceChannelManager } from "./GuildVoiceChannelManager";
|
|
8
|
+
export declare class GuildChannelList {
|
|
9
|
+
static readonly forum: typeof ForumChannelManager;
|
|
10
|
+
static readonly any: typeof GuildChannelManager;
|
|
11
|
+
static readonly news: typeof NewsChannelManager;
|
|
12
|
+
static readonly stage: typeof StageChannelManager;
|
|
13
|
+
static readonly text: typeof GuildTextChannelManager;
|
|
14
|
+
static readonly thread: typeof ThreadChannelManager;
|
|
15
|
+
static readonly voice: typeof GuildVoiceChannelManager;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=GuildChannelList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GuildChannelList.d.ts","sourceRoot":"","sources":["../../../../src/manager/guild/ChannelManager/GuildChannelList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAC,uBAAuB,EAAC,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAC,wBAAwB,EAAC,MAAM,4BAA4B,CAAC;AAEpE,qBAAa,gBAAgB;IACzB,gBAAuB,KAAK,6BAAsB;IAClD,gBAAuB,GAAG,6BAAsB;IAChD,gBAAuB,IAAI,4BAAqB;IAChD,gBAAuB,KAAK,6BAAsB;IAClD,gBAAuB,IAAI,iCAA0B;IACrD,gBAAuB,MAAM,8BAAuB;IACpD,gBAAuB,KAAK,kCAA2B;CAC1D"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GuildChannelList = void 0;
|
|
4
|
+
const GuildChannelManager_1 = require("./GuildChannelManager");
|
|
5
|
+
const ForumChannelManager_1 = require("./ForumChannelManager");
|
|
6
|
+
const NewsChannelManager_1 = require("./NewsChannelManager");
|
|
7
|
+
const StageChannelManager_1 = require("./StageChannelManager");
|
|
8
|
+
const GuildTextChannelManager_1 = require("./GuildTextChannelManager");
|
|
9
|
+
const ThreadChannelManager_1 = require("./ThreadChannelManager");
|
|
10
|
+
const GuildVoiceChannelManager_1 = require("./GuildVoiceChannelManager");
|
|
11
|
+
class GuildChannelList {
|
|
12
|
+
}
|
|
13
|
+
exports.GuildChannelList = GuildChannelList;
|
|
14
|
+
GuildChannelList.forum = ForumChannelManager_1.ForumChannelManager;
|
|
15
|
+
GuildChannelList.any = GuildChannelManager_1.GuildChannelManager;
|
|
16
|
+
GuildChannelList.news = NewsChannelManager_1.NewsChannelManager;
|
|
17
|
+
GuildChannelList.stage = StageChannelManager_1.StageChannelManager;
|
|
18
|
+
GuildChannelList.text = GuildTextChannelManager_1.GuildTextChannelManager;
|
|
19
|
+
GuildChannelList.thread = ThreadChannelManager_1.ThreadChannelManager;
|
|
20
|
+
GuildChannelList.voice = GuildVoiceChannelManager_1.GuildVoiceChannelManager;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { GuildBasedChannel, GuildChannelCreateOptions } from 'discord.js';
|
|
2
|
+
import { GuildMessageManager } from "./GuildMessageManager";
|
|
3
|
+
export declare class GuildChannelManager {
|
|
4
|
+
static readonly message: typeof GuildMessageManager;
|
|
5
|
+
/**
|
|
6
|
+
* Recherche un channel par ID dans une guild spécifique
|
|
7
|
+
*/
|
|
8
|
+
static findInGuild(guildId: string, channelId: string): Promise<GuildBasedChannel | null>;
|
|
9
|
+
static find(channelId: string): Promise<GuildBasedChannel | null>;
|
|
10
|
+
static findAll(guildId: string): GuildBasedChannel[];
|
|
11
|
+
/**
|
|
12
|
+
* Recherche channels par nom (insensible à la casse)
|
|
13
|
+
*/
|
|
14
|
+
static findByName(guildId: string, name: string): GuildBasedChannel[];
|
|
15
|
+
protected static _create(guildId: string, options: GuildChannelCreateOptions): Promise<GuildBasedChannel>;
|
|
16
|
+
static delete(channelId: string): Promise<boolean>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=GuildChannelManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GuildChannelManager.d.ts","sourceRoot":"","sources":["../../../../src/manager/guild/ChannelManager/GuildChannelManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,iBAAiB,EAAE,yBAAyB,EAC/C,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAE1D,qBAAa,mBAAmB;IAE5B,MAAM,CAAC,QAAQ,CAAC,OAAO,6BAAsB;IAE7C;;OAEG;WACU,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;WAgBlF,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAavE,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,EAAE;IASpD;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,iBAAiB,EAAE;qBAa9C,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,iBAAiB,CAAC;WAgBlG,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAe3D"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GuildChannelManager = void 0;
|
|
4
|
+
const Bot_1 = require("../../../bot/Bot");
|
|
5
|
+
const Log_1 = require("../../../utils/Log");
|
|
6
|
+
const GuildMessageManager_1 = require("./GuildMessageManager");
|
|
7
|
+
class GuildChannelManager {
|
|
8
|
+
/**
|
|
9
|
+
* Recherche un channel par ID dans une guild spécifique
|
|
10
|
+
*/
|
|
11
|
+
static async findInGuild(guildId, channelId) {
|
|
12
|
+
try {
|
|
13
|
+
const guild = Bot_1.Bot.client.guilds.cache.get(guildId);
|
|
14
|
+
if (!guild) {
|
|
15
|
+
Log_1.Log.warn(`Guild ${guildId} not found`);
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const channel = await guild.channels.fetch(channelId);
|
|
19
|
+
return channel ?? null;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
Log_1.Log.error(`Failed to find channel ${channelId} in guild ${guildId}: ${error}`);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
static async find(channelId) {
|
|
27
|
+
for (const guild of Bot_1.Bot.client.guilds.cache.values()) {
|
|
28
|
+
try {
|
|
29
|
+
const channel = await guild.channels.fetch(channelId);
|
|
30
|
+
if (channel)
|
|
31
|
+
return channel;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
Log_1.Log.warn(`Channel ${channelId} not found in any guild`);
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
static findAll(guildId) {
|
|
40
|
+
const guild = Bot_1.Bot.client.guilds.cache.get(guildId);
|
|
41
|
+
if (!guild) {
|
|
42
|
+
Log_1.Log.warn(`Guild ${guildId} not found`);
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
return Array.from(guild.channels.cache.values());
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Recherche channels par nom (insensible à la casse)
|
|
49
|
+
*/
|
|
50
|
+
static findByName(guildId, name) {
|
|
51
|
+
const guild = Bot_1.Bot.client.guilds.cache.get(guildId);
|
|
52
|
+
if (!guild) {
|
|
53
|
+
Log_1.Log.warn(`Guild ${guildId} not found`);
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
return Array.from(guild.channels.cache.values())
|
|
57
|
+
.filter(channel => channel.name.toLowerCase().includes(name.toLowerCase()));
|
|
58
|
+
}
|
|
59
|
+
static async _create(guildId, options) {
|
|
60
|
+
try {
|
|
61
|
+
const guild = Bot_1.Bot.client.guilds.cache.get(guildId);
|
|
62
|
+
if (!guild) {
|
|
63
|
+
throw new Error(`Guild ${guildId} not found`);
|
|
64
|
+
}
|
|
65
|
+
const channel = await guild.channels.create(options);
|
|
66
|
+
Log_1.Log.info(`Created channel ${channel.name} (${channel.id}) in guild ${guildId}`);
|
|
67
|
+
return channel;
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
Log_1.Log.error(`Failed to create channel in guild ${guildId}: ${error}`);
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
static async delete(channelId) {
|
|
75
|
+
try {
|
|
76
|
+
const channel = await GuildChannelManager.find(channelId);
|
|
77
|
+
if (!channel) {
|
|
78
|
+
throw new Error(`Channel ${channelId} not found`);
|
|
79
|
+
}
|
|
80
|
+
await channel.delete();
|
|
81
|
+
Log_1.Log.info(`Deleted channel ${channelId}`);
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
Log_1.Log.error(`Failed to delete channel ${channelId}: ${error}`);
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.GuildChannelManager = GuildChannelManager;
|
|
91
|
+
GuildChannelManager.message = GuildMessageManager_1.GuildMessageManager;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Message, MessageCreateOptions } from "discord.js";
|
|
2
|
+
import { SendableComponent } from "../../builder/SendableComponentBuilder";
|
|
3
|
+
export declare class GuildMessageManager {
|
|
4
|
+
/**
|
|
5
|
+
* Overloads for send
|
|
6
|
+
*/
|
|
7
|
+
static send(channelId: string, content: string): Promise<Message>;
|
|
8
|
+
static send(channelId: string, component: SendableComponent | SendableComponent[]): Promise<Message>;
|
|
9
|
+
static send(channelId: string, options: MessageCreateOptions): Promise<Message>;
|
|
10
|
+
/**
|
|
11
|
+
* Delete message
|
|
12
|
+
*/
|
|
13
|
+
static delete(channelId: string, messageId: string): Promise<boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* Fetch messages (last X messages, default 10)
|
|
16
|
+
*/
|
|
17
|
+
static fetch(channelId: string, limit?: number): Promise<Message[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Fetch single message
|
|
20
|
+
*/
|
|
21
|
+
static fetchOne(channelId: string, messageId: string): Promise<Message | null>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=GuildMessageManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GuildMessageManager.d.ts","sourceRoot":"","sources":["../../../../src/manager/guild/ChannelManager/GuildMessageManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,oBAAoB,EAAC,MAAM,YAAY,CAAC;AAGzD,OAAO,EAAC,iBAAiB,EAA2B,MAAM,wCAAwC,CAAC;AAEnG,qBAAa,mBAAmB;IAG5B;;OAEG;WACU,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;WAC1D,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;WAC7F,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC;IAmCrF;;OAEG;WACU,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAmB3E;;OAEG;WACU,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,GAAE,MAAW,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAiB7E;;OAEG;WACU,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;CAevF"}
|