@spatulox/simplediscordbot 1.0.4 → 1.0.6
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/bot/Bot.d.ts +32 -0
- package/dist/bot/BotEnv.d.ts +5 -0
- package/dist/bot/BotLog.d.ts +51 -0
- package/dist/bot/BotMessage.d.ts +16 -0
- package/dist/cli/BaseCLI.d.ts +25 -0
- package/dist/cli/GenerationCLI/ContextMenuGeneratorCLI.d.ts +6 -0
- package/dist/cli/GenerationCLI/GenerationCLI.d.ts +6 -0
- package/dist/cli/GenerationCLI/ModalGeneratorCLI.d.ts +44 -0
- package/dist/cli/GenerationCLI/SlashCommandsGeneratorCLI.d.ts +12 -0
- package/dist/cli/GuildListManager.d.ts +24 -0
- package/dist/cli/InteractionCLI/InteractionCLI.d.ts +8 -0
- package/dist/cli/InteractionCLI/InteractionCLIManager.d.ts +17 -0
- package/dist/cli/MainCLI.d.ts +12 -0
- package/dist/cli/type/ContextMenuConfig.d.ts +12 -0
- package/dist/cli/type/InteractionType.d.ts +9 -0
- package/dist/cli/type/SlashCommandConfig.d.ts +43 -0
- package/dist/index.d.ts +14 -0
- package/dist/manager/FileManager.d.ts +36 -0
- package/dist/manager/direct/UserManager.d.ts +23 -0
- package/dist/manager/guild/ChannelManager/ForumChannelManager.d.ts +8 -0
- package/dist/manager/guild/ChannelManager/GuildChannelList.d.ts +16 -0
- package/dist/manager/guild/ChannelManager/GuildChannelManager.d.ts +17 -0
- package/dist/manager/guild/ChannelManager/GuildMessageManager.d.ts +21 -0
- package/dist/manager/guild/ChannelManager/GuildTextChannelManager.d.ts +8 -0
- package/dist/manager/guild/ChannelManager/GuildVoiceChannelManager.d.ts +8 -0
- package/dist/manager/guild/ChannelManager/NewsChannelManager.d.ts +8 -0
- package/dist/manager/guild/ChannelManager/StageChannelManager.d.ts +8 -0
- package/dist/manager/guild/ChannelManager/ThreadChannelManager.d.ts +8 -0
- package/dist/manager/guild/GuildManager.d.ts +30 -0
- package/dist/manager/guild/GuildUserManager.d.ts +46 -0
- package/dist/manager/guild/InviteManager.d.ts +20 -0
- package/dist/manager/guild/InviteManager_old.d.ts +23 -0
- package/dist/manager/guild/RoleManager.d.ts +23 -0
- package/dist/manager/handlers/builder/ModalManager.d.ts +22 -0
- package/dist/manager/handlers/interactions/BaseInteractionManager.d.ts +44 -0
- package/dist/manager/handlers/interactions/InteractionManager.d.ts +14 -0
- package/dist/manager/messages/EmbedManager.d.ts +83 -0
- package/dist/manager/messages/ReactionManager.d.ts +25 -0
- package/dist/manager/messages/WebhookManager.d.ts +29 -0
- package/dist/type/FolderName.d.ts +5 -0
- package/dist/utils/DiscordRegex.d.ts +65 -0
- package/dist/utils/Log.d.ts +8 -0
- package/dist/utils/SimpleMutex.d.ts +15 -0
- package/dist/utils/network/InternetChecker.d.ts +9 -0
- package/dist/utils/times/UnitTime.d.ts +186 -0
- package/package.json +4 -2
- package/.env.example +0 -2
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Client, ActivityType } from 'discord.js';
|
|
2
|
+
import { BotLog, ConfigLog } from "./BotLog";
|
|
3
|
+
import { EmbedColor } from "../manager/messages/EmbedManager";
|
|
4
|
+
import { BotMessage } from "./BotMessage";
|
|
5
|
+
export type BotConfig = {
|
|
6
|
+
botIconUrl?: string;
|
|
7
|
+
defaultEmbedColor?: number | EmbedColor;
|
|
8
|
+
botName?: string;
|
|
9
|
+
log?: ConfigLog;
|
|
10
|
+
};
|
|
11
|
+
export type InternalBotConfig = {
|
|
12
|
+
clientId: string;
|
|
13
|
+
} & BotConfig;
|
|
14
|
+
export type RandomBotActivity = {
|
|
15
|
+
type: ActivityType;
|
|
16
|
+
message: string;
|
|
17
|
+
}[];
|
|
18
|
+
export declare class Bot {
|
|
19
|
+
static _client: Client;
|
|
20
|
+
static readonly log: typeof BotLog;
|
|
21
|
+
static readonly message: BotMessage;
|
|
22
|
+
private static criticConfig;
|
|
23
|
+
private static _config;
|
|
24
|
+
get config(): InternalBotConfig;
|
|
25
|
+
get client(): Client;
|
|
26
|
+
static get client(): Client;
|
|
27
|
+
static get config(): InternalBotConfig;
|
|
28
|
+
constructor(client: Client, config: BotConfig);
|
|
29
|
+
login(maxTries?: number): Promise<boolean>;
|
|
30
|
+
static setActivity(message: string, type: ActivityType): void;
|
|
31
|
+
static setRandomActivity(randomActivity: RandomBotActivity, intervalMs?: number | null): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { EmbedBuilder, Message } from 'discord.js';
|
|
2
|
+
export type ConfigLog = {
|
|
3
|
+
logChannelId: string;
|
|
4
|
+
errorChannelId: string;
|
|
5
|
+
info: {
|
|
6
|
+
console: boolean;
|
|
7
|
+
discord: boolean;
|
|
8
|
+
};
|
|
9
|
+
error: {
|
|
10
|
+
console: boolean;
|
|
11
|
+
discord: boolean;
|
|
12
|
+
};
|
|
13
|
+
warn: {
|
|
14
|
+
console: boolean;
|
|
15
|
+
discord: boolean;
|
|
16
|
+
};
|
|
17
|
+
debug: {
|
|
18
|
+
console: boolean;
|
|
19
|
+
discord: boolean;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export declare class BotLog {
|
|
23
|
+
private static logChannel;
|
|
24
|
+
private static errorChannel;
|
|
25
|
+
constructor();
|
|
26
|
+
static config(): ConfigLog | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Initialize Discord logging channels and update Bot.log references
|
|
29
|
+
*/
|
|
30
|
+
static initDiscordLogging(): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Send content to specific Discord channel
|
|
33
|
+
*/
|
|
34
|
+
private static _sendToChannel;
|
|
35
|
+
/**
|
|
36
|
+
* Send INFO log - TEXT or EMBED ! Respecte config.log.info
|
|
37
|
+
*/
|
|
38
|
+
static sendLog(content: string | EmbedBuilder): Promise<Message | void>;
|
|
39
|
+
/**
|
|
40
|
+
* Send ERROR log - TEXT or EMBED ! Respecte config.log.error
|
|
41
|
+
*/
|
|
42
|
+
static sendError(content: string | EmbedBuilder): Promise<Message | void>;
|
|
43
|
+
/**
|
|
44
|
+
* Send WARNING log - TEXT or EMBED ! Respecte config.log.warn
|
|
45
|
+
*/
|
|
46
|
+
static sendWarn(content: string | EmbedBuilder): Promise<Message | void>;
|
|
47
|
+
/**
|
|
48
|
+
* Send DEBUG log - TEXT or EMBED ! Respecte config.log.debug
|
|
49
|
+
*/
|
|
50
|
+
static sendDebug(content: string | EmbedBuilder): Promise<Message | void>;
|
|
51
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TextChannel, DMChannel, ThreadChannel, EmbedBuilder, Message, User, GuildMember } from 'discord.js';
|
|
2
|
+
export declare class BotMessage {
|
|
3
|
+
/**
|
|
4
|
+
* Send message to any text-based channel
|
|
5
|
+
*/
|
|
6
|
+
send(channel: TextChannel | DMChannel | ThreadChannel | string, content: string | EmbedBuilder): Promise<Message | boolean>;
|
|
7
|
+
sendDM(user: User | GuildMember | string, content: string | EmbedBuilder): Promise<Message | boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Quick success message
|
|
10
|
+
*/
|
|
11
|
+
success(channel: TextChannel | DMChannel | ThreadChannel | User | GuildMember, message: string): Promise<Message | boolean>;
|
|
12
|
+
/**
|
|
13
|
+
* Quick error message
|
|
14
|
+
*/
|
|
15
|
+
error(channel: TextChannel | DMChannel | ThreadChannel | User | GuildMember, message: string): Promise<Message | boolean>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import readline from "readline";
|
|
3
|
+
export type MenuSelectionCLI = {
|
|
4
|
+
label: string;
|
|
5
|
+
action: () => BaseCLI | Promise<any> | null;
|
|
6
|
+
}[];
|
|
7
|
+
/**
|
|
8
|
+
* --- BaseCLI ---
|
|
9
|
+
*/
|
|
10
|
+
export declare abstract class BaseCLI {
|
|
11
|
+
protected parent?: BaseCLI | undefined;
|
|
12
|
+
private static _rl;
|
|
13
|
+
protected get rl(): readline.Interface;
|
|
14
|
+
constructor(parent?: BaseCLI | undefined);
|
|
15
|
+
protected abstract readonly menuSelection: MenuSelectionCLI;
|
|
16
|
+
protected abstract execute(): Promise<void>;
|
|
17
|
+
protected getTitle(): string;
|
|
18
|
+
protected showMainMenu(): Promise<void>;
|
|
19
|
+
protected prompt(question: string): Promise<string>;
|
|
20
|
+
protected requireInput(message: string, validator?: (val: string) => boolean, canBeEmpty?: boolean): Promise<string>;
|
|
21
|
+
protected yesNoInput(message: string): Promise<boolean>;
|
|
22
|
+
protected showHelp(): Promise<void>;
|
|
23
|
+
protected goBack(): Promise<void>;
|
|
24
|
+
protected saveFile<T>(folderName: string, filename: string, data: T): Promise<void>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ModalBuilder } from "discord.js";
|
|
2
|
+
import { BaseCLI, MenuSelectionCLI } from "../BaseCLI";
|
|
3
|
+
export interface ModalCreateOption {
|
|
4
|
+
title: string;
|
|
5
|
+
customId: string;
|
|
6
|
+
label: string;
|
|
7
|
+
fields: ModalField[];
|
|
8
|
+
}
|
|
9
|
+
export interface ModalField {
|
|
10
|
+
title: string;
|
|
11
|
+
customId: string;
|
|
12
|
+
style: ModalFieldStyle;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
minLength?: number;
|
|
16
|
+
maxLength?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface SimpleModalCreateOption {
|
|
19
|
+
customId: string;
|
|
20
|
+
title: string;
|
|
21
|
+
label: string;
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare enum ModalFieldStyle {
|
|
25
|
+
Short = 1,
|
|
26
|
+
Paragraph = 2,
|
|
27
|
+
Number = "Number",
|
|
28
|
+
Phone = "Phone",
|
|
29
|
+
Date = "Date"
|
|
30
|
+
}
|
|
31
|
+
export declare class ModalGeneratorCLI extends BaseCLI {
|
|
32
|
+
protected getTitle(): string;
|
|
33
|
+
protected readonly menuSelection: MenuSelectionCLI;
|
|
34
|
+
protected execute(): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Create modal from declarative config - SIMPLE API !
|
|
37
|
+
*/
|
|
38
|
+
static create(options: ModalCreateOption): ModalBuilder;
|
|
39
|
+
private static buildInput;
|
|
40
|
+
/**
|
|
41
|
+
* Quick helpers
|
|
42
|
+
*/
|
|
43
|
+
static simple(option: SimpleModalCreateOption): ModalBuilder;
|
|
44
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseCLI, MenuSelectionCLI } from "../BaseCLI";
|
|
2
|
+
export declare class SlashCommandGeneratorCLI extends BaseCLI {
|
|
3
|
+
protected getTitle(): string;
|
|
4
|
+
protected readonly menuSelection: MenuSelectionCLI;
|
|
5
|
+
protected execute(): Promise<void>;
|
|
6
|
+
private addCommandStructure;
|
|
7
|
+
private addSubCommands;
|
|
8
|
+
private addSubCommandOptions;
|
|
9
|
+
private addChoices;
|
|
10
|
+
private addChannelTypes;
|
|
11
|
+
private addSimpleOptions;
|
|
12
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BaseCLI, MenuSelectionCLI } from "./BaseCLI";
|
|
2
|
+
import { REST } from "@discordjs/rest";
|
|
3
|
+
import { GuildFeature } from 'discord-api-types/v10';
|
|
4
|
+
export type Guild = {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
icon: string | null;
|
|
8
|
+
banner: string | null;
|
|
9
|
+
owner: boolean;
|
|
10
|
+
permissions: string;
|
|
11
|
+
features: GuildFeature[];
|
|
12
|
+
};
|
|
13
|
+
export declare class GuildListManager extends BaseCLI {
|
|
14
|
+
protected guilds: Guild[];
|
|
15
|
+
protected clientId: string;
|
|
16
|
+
protected token: string;
|
|
17
|
+
protected rest: REST;
|
|
18
|
+
constructor(clientId: string, token: string);
|
|
19
|
+
protected getTitle(): string;
|
|
20
|
+
protected readonly menuSelection: MenuSelectionCLI;
|
|
21
|
+
protected execute(): Promise<void>;
|
|
22
|
+
list(printResult?: boolean): Promise<Guild[]>;
|
|
23
|
+
chooseGuild(): Promise<Guild | null>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseCLI, MenuSelectionCLI } from "../BaseCLI";
|
|
2
|
+
export declare class InteractionCLI extends BaseCLI {
|
|
3
|
+
private managers;
|
|
4
|
+
protected getTitle(): string;
|
|
5
|
+
protected readonly menuSelection: MenuSelectionCLI;
|
|
6
|
+
constructor(parent?: BaseCLI);
|
|
7
|
+
protected execute(): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseCLI, MenuSelectionCLI } from "../BaseCLI";
|
|
2
|
+
import { BaseInteractionManager } from "../../manager/handlers/interactions/BaseInteractionManager";
|
|
3
|
+
export declare class InteractionManagerCLI extends BaseCLI {
|
|
4
|
+
protected readonly manager: BaseInteractionManager;
|
|
5
|
+
protected readonly managerKey: string;
|
|
6
|
+
protected getTitle(): string;
|
|
7
|
+
protected readonly menuSelection: MenuSelectionCLI;
|
|
8
|
+
constructor(parent: BaseCLI, manager: BaseInteractionManager, managerKey: string);
|
|
9
|
+
protected execute(): Promise<void>;
|
|
10
|
+
private listRemote;
|
|
11
|
+
private guildListRemote;
|
|
12
|
+
private guildListAllRemote;
|
|
13
|
+
private handleDeploy;
|
|
14
|
+
private handleUpdate;
|
|
15
|
+
private handleDelete;
|
|
16
|
+
private selectCommands;
|
|
17
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { BaseCLI, MenuSelectionCLI } from "./BaseCLI";
|
|
3
|
+
/**
|
|
4
|
+
* --- MainCLI ---
|
|
5
|
+
* Main controller for sub menu
|
|
6
|
+
*/
|
|
7
|
+
export declare class MainCLI extends BaseCLI {
|
|
8
|
+
protected getTitle(): string;
|
|
9
|
+
constructor();
|
|
10
|
+
protected readonly menuSelection: MenuSelectionCLI;
|
|
11
|
+
protected execute(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PermissionFlagsBits } from "discord.js";
|
|
2
|
+
import { InteractionContextType, InteractionIntegrationType } from "./InteractionType";
|
|
3
|
+
export interface ContextMenuConfig {
|
|
4
|
+
name: string;
|
|
5
|
+
type: 2 | 3;
|
|
6
|
+
type_comment?: Array<string>;
|
|
7
|
+
default_member_permissions?: Array<(keyof typeof PermissionFlagsBits)>;
|
|
8
|
+
dm_permission: boolean;
|
|
9
|
+
integration_types: InteractionIntegrationType[];
|
|
10
|
+
contexts?: InteractionContextType[];
|
|
11
|
+
guildID?: Array<string>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { PermissionFlagsBits } from "discord.js";
|
|
2
|
+
import { InteractionContextType, InteractionIntegrationType } from "./InteractionType";
|
|
3
|
+
export type DiscordCommandType = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11;
|
|
4
|
+
export type PermissionString = keyof typeof PermissionFlagsBits | string;
|
|
5
|
+
export interface Choice {
|
|
6
|
+
name: string;
|
|
7
|
+
value: string;
|
|
8
|
+
}
|
|
9
|
+
export interface Option {
|
|
10
|
+
type: DiscordCommandType;
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
required?: boolean;
|
|
14
|
+
choices?: Choice[];
|
|
15
|
+
min_length?: number;
|
|
16
|
+
max_length?: number;
|
|
17
|
+
min_value?: number;
|
|
18
|
+
max_value?: number;
|
|
19
|
+
channel_types?: number[];
|
|
20
|
+
autocomplete?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface CommandOption extends Option {
|
|
23
|
+
options?: CommandOption[];
|
|
24
|
+
}
|
|
25
|
+
export interface SlashCommandConfig {
|
|
26
|
+
name: string;
|
|
27
|
+
description: string;
|
|
28
|
+
type: 1;
|
|
29
|
+
options?: CommandOption[];
|
|
30
|
+
default_member_permissions?: PermissionString[];
|
|
31
|
+
default_member_permissions_string?: PermissionString[];
|
|
32
|
+
dm_permission: boolean;
|
|
33
|
+
integration_types: InteractionIntegrationType[];
|
|
34
|
+
contexts: InteractionContextType[];
|
|
35
|
+
guildID?: string[];
|
|
36
|
+
}
|
|
37
|
+
export interface ServerManagementCommandConfig {
|
|
38
|
+
name: string;
|
|
39
|
+
type: 1;
|
|
40
|
+
description: string;
|
|
41
|
+
permissions?: PermissionString[];
|
|
42
|
+
options: CommandOption[];
|
|
43
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { Bot } from "./bot/Bot";
|
|
2
|
+
export { BotEnv } from "./bot/BotEnv";
|
|
3
|
+
export { FileManager } from './manager/FileManager';
|
|
4
|
+
export { EmbedManager, EmbedColor } from './manager/messages/EmbedManager';
|
|
5
|
+
export { WebhookManager } from './manager/messages/WebhookManager';
|
|
6
|
+
export { ReactionManager } from "./manager/messages/ReactionManager";
|
|
7
|
+
export { GuildManager } from "./manager/guild/GuildManager";
|
|
8
|
+
export { UserManager } from './manager/direct/UserManager';
|
|
9
|
+
export { ModalManager } from "./manager/handlers/builder/ModalManager";
|
|
10
|
+
export { Time } from "./utils/times/UnitTime";
|
|
11
|
+
export { Log } from "./utils/Log";
|
|
12
|
+
export { SimpleMutex } from "./utils/SimpleMutex";
|
|
13
|
+
export { DiscordRegex } from "./utils/DiscordRegex";
|
|
14
|
+
export type { BotConfig, RandomBotActivity } from './bot/Bot';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare class FileManager {
|
|
2
|
+
/**
|
|
3
|
+
* Reads a JSON file synchronously.
|
|
4
|
+
* @param filePath Full path to the JSON file
|
|
5
|
+
* @returns Parsed JSON object or 'Error' string on failure
|
|
6
|
+
*/
|
|
7
|
+
static readJsonFile(filePath: string): Promise<any | false>;
|
|
8
|
+
/**
|
|
9
|
+
* Lists all directories in a given path.
|
|
10
|
+
* @param directoryPath Path to scan for directories
|
|
11
|
+
* @returns Array of directory names or false on error
|
|
12
|
+
*/
|
|
13
|
+
static listDirectories(directoryPath: string): Promise<string[] | false>;
|
|
14
|
+
/**
|
|
15
|
+
* Lists all JSON files in a directory.
|
|
16
|
+
* @param directoryPath Path to scan for JSON files
|
|
17
|
+
* @returns Array of JSON filenames or false on error
|
|
18
|
+
*/
|
|
19
|
+
static listJsonFiles(directoryPath: string): Promise<string[] | false>;
|
|
20
|
+
/**
|
|
21
|
+
* Lists files with specific extension in a directory.
|
|
22
|
+
* @param directoryPath Path to scan
|
|
23
|
+
* @param extension File extension (with or without dot)
|
|
24
|
+
* @returns Array of matching filenames or 'Error' string on failure
|
|
25
|
+
*/
|
|
26
|
+
static listFiles(directoryPath: string, extension: string): Promise<string[] | false>;
|
|
27
|
+
/**
|
|
28
|
+
* Creates directory structure and writes JSON data to file.
|
|
29
|
+
* @param directoryPath Full directory path (creates if missing)
|
|
30
|
+
* @param filename Filename without extension
|
|
31
|
+
* @param data Data to write (JSON serializable)
|
|
32
|
+
* @param sendErrorToErrorChannel Send error to the error channel
|
|
33
|
+
* @returns true on success, false on failure
|
|
34
|
+
*/
|
|
35
|
+
static writeJsonFile(directoryPath: string, filename: string, data: any, sendErrorToErrorChannel?: boolean): Promise<boolean>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EmbedBuilder, GuildMember, Message, MessageCreateOptions, User } from "discord.js";
|
|
2
|
+
export declare class UserManager {
|
|
3
|
+
/**
|
|
4
|
+
* Find a member
|
|
5
|
+
*/
|
|
6
|
+
static find(userId: string): Promise<User | null>;
|
|
7
|
+
/**
|
|
8
|
+
* Find member in specific guild
|
|
9
|
+
*/
|
|
10
|
+
static findInGuild(guildId: string, memberId: string): Promise<GuildMember | null>;
|
|
11
|
+
/**
|
|
12
|
+
* Check if user is still in guild
|
|
13
|
+
*/
|
|
14
|
+
static isInGuild(guildId: string, userId: string): Promise<boolean>;
|
|
15
|
+
/**
|
|
16
|
+
* Overload for send
|
|
17
|
+
*/
|
|
18
|
+
static send(user_id: string, content: string): Promise<Message>;
|
|
19
|
+
static send(user: User, content: string): Promise<Message>;
|
|
20
|
+
static send(user_id: string, embed: EmbedBuilder): Promise<Message>;
|
|
21
|
+
static send(user: User, embed: EmbedBuilder): Promise<Message>;
|
|
22
|
+
static send(user_id_or_user: string | User, options: MessageCreateOptions): Promise<Message>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { EmbedBuilder, Message, MessageCreateOptions } from "discord.js";
|
|
2
|
+
export declare class GuildMessageManager {
|
|
3
|
+
/**
|
|
4
|
+
* Overloads for send
|
|
5
|
+
*/
|
|
6
|
+
static send(channelId: string, content: string): Promise<Message>;
|
|
7
|
+
static send(channelId: string, embed: EmbedBuilder): Promise<Message>;
|
|
8
|
+
static send(channelId: string, options: MessageCreateOptions): Promise<Message>;
|
|
9
|
+
/**
|
|
10
|
+
* Delete message
|
|
11
|
+
*/
|
|
12
|
+
static delete(channelId: string, messageId: string): Promise<boolean>;
|
|
13
|
+
/**
|
|
14
|
+
* Fetch messages (last X messages, default 10)
|
|
15
|
+
*/
|
|
16
|
+
static fetch(channelId: string, limit?: number): Promise<Message[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Fetch single message
|
|
19
|
+
*/
|
|
20
|
+
static fetchOne(channelId: string, messageId: string): Promise<Message | null>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TextChannel, GuildChannelCreateOptions } from "discord.js";
|
|
2
|
+
import { GuildChannelManager } from "./GuildChannelManager";
|
|
3
|
+
export declare class GuildTextChannelManager extends GuildChannelManager {
|
|
4
|
+
static findInGuild(guildId: string, channelId: string): Promise<TextChannel | null>;
|
|
5
|
+
static find(channelId: string): Promise<TextChannel | null>;
|
|
6
|
+
static findAll(guildId: string): TextChannel[];
|
|
7
|
+
static create(guildId: string, name: string, options?: Omit<GuildChannelCreateOptions, 'type'>): Promise<TextChannel>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GuildChannelCreateOptions, VoiceChannel } from "discord.js";
|
|
2
|
+
import { GuildChannelManager } from "./GuildChannelManager";
|
|
3
|
+
export declare class GuildVoiceChannelManager extends GuildChannelManager {
|
|
4
|
+
static findInGuild(guildId: string, channelId: string): Promise<VoiceChannel | null>;
|
|
5
|
+
static find(channelId: string): Promise<VoiceChannel | null>;
|
|
6
|
+
static findAll(guildId: string): VoiceChannel[];
|
|
7
|
+
static create(guildId: string, name: string, options?: Omit<GuildChannelCreateOptions, 'type'>): Promise<VoiceChannel>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GuildChannelCreateOptions, NewsChannel } from "discord.js";
|
|
2
|
+
import { GuildChannelManager } from "./GuildChannelManager";
|
|
3
|
+
export declare class NewsChannelManager extends GuildChannelManager {
|
|
4
|
+
static findInGuild(guildId: string, channelId: string): Promise<NewsChannel | null>;
|
|
5
|
+
static find(channelId: string): Promise<NewsChannel | null>;
|
|
6
|
+
static findAll(guildId: string): NewsChannel[];
|
|
7
|
+
static create(guildId: string, name: string, options?: Omit<GuildChannelCreateOptions, 'type'>): Promise<NewsChannel>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GuildChannelCreateOptions, StageChannel } from "discord.js";
|
|
2
|
+
import { GuildChannelManager } from "./GuildChannelManager";
|
|
3
|
+
export declare class StageChannelManager extends GuildChannelManager {
|
|
4
|
+
static findInGuild(guildId: string, channelId: string): Promise<StageChannel | null>;
|
|
5
|
+
static find(channelId: string): Promise<StageChannel | null>;
|
|
6
|
+
static findAll(guildId: string): StageChannel[];
|
|
7
|
+
static create(guildId: string, name: string, options?: Omit<GuildChannelCreateOptions, 'type'>): Promise<StageChannel>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Message, StartThreadOptions, ThreadChannel } from "discord.js";
|
|
2
|
+
export declare class ThreadChannelManager {
|
|
3
|
+
static findInGuild(guildId: string, channelId: string): Promise<ThreadChannel | null>;
|
|
4
|
+
static find(channelId: string): Promise<ThreadChannel | null>;
|
|
5
|
+
static findAll(guildId: string): ThreadChannel[];
|
|
6
|
+
static createFromChannel(parentId: string, options: StartThreadOptions): Promise<ThreadChannel>;
|
|
7
|
+
static createFromMessage(message: Message, options: StartThreadOptions): Promise<ThreadChannel>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { GuildMember, Collection, Guild, GuildBan, Channel } from 'discord.js';
|
|
2
|
+
import { GuildUserManager } from "./GuildUserManager";
|
|
3
|
+
import { RoleManager } from "./RoleManager";
|
|
4
|
+
import { GuildChannelList } from "./ChannelManager/GuildChannelList";
|
|
5
|
+
import { InviteManager } from "./InviteManager";
|
|
6
|
+
export declare class GuildManager {
|
|
7
|
+
static readonly role: typeof RoleManager;
|
|
8
|
+
static readonly user: typeof GuildUserManager;
|
|
9
|
+
static readonly channel: typeof GuildChannelList;
|
|
10
|
+
static readonly invite: typeof InviteManager;
|
|
11
|
+
static list(): Guild[];
|
|
12
|
+
/**
|
|
13
|
+
* Search channel by ID (TextChannel, DMChannel, ThreadChannel)
|
|
14
|
+
*/
|
|
15
|
+
static searchChannel(guildId: string, channelId: string): Promise<Channel | null>;
|
|
16
|
+
/**
|
|
17
|
+
* Search guild member by ID
|
|
18
|
+
*/
|
|
19
|
+
static searchMember(memberId: string, guildId: string): Promise<GuildMember | null>;
|
|
20
|
+
/**
|
|
21
|
+
* Check if member is still in guild
|
|
22
|
+
*/
|
|
23
|
+
static isMemberInGuild(memberId: string, guildId: string): Promise<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* Fetch all members with retry (heavy operation)
|
|
26
|
+
*/
|
|
27
|
+
static fetchAllMembers(guildId: string, MAX_ATTEMPTS?: number, RETRY_DELAY?: number): Promise<Collection<string, GuildMember>>;
|
|
28
|
+
static listban(guildId: string, limit?: number): Promise<GuildBan[]>;
|
|
29
|
+
static moveMember(memberId: string, fromChannelId: string, toChannelId: string): Promise<boolean>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { UserManager } from "../direct/UserManager";
|
|
2
|
+
import { BanOptions } from "discord.js";
|
|
3
|
+
export declare class GuildUserManager extends UserManager {
|
|
4
|
+
/**
|
|
5
|
+
* Check if user is banned from guild
|
|
6
|
+
*/
|
|
7
|
+
static isBanned(guildId: string, userId: string): Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Deconnect a member from a voice
|
|
10
|
+
*/
|
|
11
|
+
static deconnectFromVoice(guildId: string, memberId: string): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Check if a member is in voice
|
|
14
|
+
*/
|
|
15
|
+
static isInVoice(memberId: string, guildId: string): Promise<boolean>;
|
|
16
|
+
/**
|
|
17
|
+
* Mute a member
|
|
18
|
+
*/
|
|
19
|
+
static mute(guildId: string, memberId: string, reason?: string): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Unmute a member
|
|
22
|
+
*/
|
|
23
|
+
static unmute(guildId: string, memberId: string, reason?: string): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Deafen a member
|
|
26
|
+
*/
|
|
27
|
+
static deafen(guildId: string, memberId: string, reason?: string): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Undeafen member voice
|
|
30
|
+
*/
|
|
31
|
+
static undeafen(guildId: string, memberId: string, reason?: string): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Timeout a member
|
|
34
|
+
*/
|
|
35
|
+
static timeout(guildId: string, memberId: string, duration: number, reason?: string): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Remove the timeout of a member
|
|
38
|
+
*/
|
|
39
|
+
static untimeout(guildId: string, memberId: string, reason?: string): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Kick a member
|
|
42
|
+
*/
|
|
43
|
+
static kick(guildId: string, memberId: string, reason?: string): Promise<void>;
|
|
44
|
+
static ban(guildId: string, userId: string, banOption?: BanOptions): Promise<void>;
|
|
45
|
+
static unban(guildId: string, userId: string, reason?: string): Promise<void>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Invite } from 'discord.js';
|
|
2
|
+
export declare class InviteManager {
|
|
3
|
+
/**
|
|
4
|
+
* Create an invite for a channel
|
|
5
|
+
*/
|
|
6
|
+
static create(channelId: string, options?: {
|
|
7
|
+
maxAge?: number;
|
|
8
|
+
maxUses?: number;
|
|
9
|
+
reason?: string;
|
|
10
|
+
temporary?: boolean;
|
|
11
|
+
}): Promise<Invite>;
|
|
12
|
+
/**
|
|
13
|
+
* Delete an invitation
|
|
14
|
+
*/
|
|
15
|
+
static delete(invite: Invite): Promise<boolean>;
|
|
16
|
+
/**
|
|
17
|
+
* List every invitation from a guild
|
|
18
|
+
*/
|
|
19
|
+
static list(guildId: string): Promise<Invite[]>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Invite, Collection } from 'discord.js';
|
|
2
|
+
export declare class InviteManager {
|
|
3
|
+
/**
|
|
4
|
+
* Check if invite is old (more than 1 hour)
|
|
5
|
+
*/
|
|
6
|
+
static isOld(invite: Invite, excludedInvite?: string[]): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Delete single invite
|
|
9
|
+
*/
|
|
10
|
+
static delete(invite: Invite): Promise<boolean>;
|
|
11
|
+
/**
|
|
12
|
+
* Delete all old invites from guild
|
|
13
|
+
*/
|
|
14
|
+
static cleanupGuild(guildId: string): Promise<number>;
|
|
15
|
+
/**
|
|
16
|
+
* Get all invites from guild
|
|
17
|
+
*/
|
|
18
|
+
static fetchGuildInvites(guildId: string): Promise<Collection<string, Invite>>;
|
|
19
|
+
/**
|
|
20
|
+
* Get old invites only
|
|
21
|
+
*/
|
|
22
|
+
static getOldInvites(invites: Collection<string, Invite>): Invite[];
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { GuildMember, Snowflake } from 'discord.js';
|
|
2
|
+
export declare class RoleManager {
|
|
3
|
+
/**
|
|
4
|
+
* Add role - CACHE ONLY
|
|
5
|
+
* @param member - GuildMember ALREADY FETCHED
|
|
6
|
+
* @param roleId - Role ID (string)
|
|
7
|
+
*/
|
|
8
|
+
static add(member: GuildMember, roleId: Snowflake): Promise<boolean>;
|
|
9
|
+
/**
|
|
10
|
+
* Remove role - CACHE ONLY
|
|
11
|
+
* @param member - GuildMember ALREADY FETCHED
|
|
12
|
+
* @param roleIdOrName - Role ID or name
|
|
13
|
+
*/
|
|
14
|
+
static remove(member: GuildMember, roleIdOrName: Snowflake | string): Promise<boolean>;
|
|
15
|
+
/**
|
|
16
|
+
* Toggle role (add/remove)
|
|
17
|
+
*/
|
|
18
|
+
static toggle(member: GuildMember, roleIdOrName: Snowflake | string): Promise<'added' | 'removed'>;
|
|
19
|
+
/**
|
|
20
|
+
* Check if member has role
|
|
21
|
+
*/
|
|
22
|
+
static hasRole(member: GuildMember, roleIdOrName: Snowflake | string): boolean;
|
|
23
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ModalBuilder } from "discord.js";
|
|
2
|
+
export interface ModalJson {
|
|
3
|
+
title: string;
|
|
4
|
+
customId: string;
|
|
5
|
+
label: string;
|
|
6
|
+
fields: any[];
|
|
7
|
+
}
|
|
8
|
+
export declare class ModalManager {
|
|
9
|
+
/**
|
|
10
|
+
* Load modal from JSON file and return ModalBuilder
|
|
11
|
+
*/
|
|
12
|
+
static load(filename: string): Promise<ModalBuilder | false>;
|
|
13
|
+
/**
|
|
14
|
+
* List all modal files
|
|
15
|
+
*/
|
|
16
|
+
static list(): Promise<string[] | false>;
|
|
17
|
+
private static jsonToBuilder;
|
|
18
|
+
private static fieldJsonToInput;
|
|
19
|
+
static parseNumber(value: string): number | null;
|
|
20
|
+
static parsePhone(value: string): string | null;
|
|
21
|
+
static parseDate(value: string): Date | null;
|
|
22
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { REST } from '@discordjs/rest';
|
|
3
|
+
import { Guild } from "../../../cli/GuildListManager";
|
|
4
|
+
export interface Command {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
options?: any[];
|
|
8
|
+
default_member_permissions?: string | bigint | number;
|
|
9
|
+
default_member_permissions_string?: string[];
|
|
10
|
+
guildID?: string[];
|
|
11
|
+
type: CommandType;
|
|
12
|
+
id?: string;
|
|
13
|
+
filename?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare enum CommandType {
|
|
16
|
+
SLASH = 1,
|
|
17
|
+
USER_CONTEXT_MENU = 2,
|
|
18
|
+
MESSAGE_CONTEXT_MENU = 3
|
|
19
|
+
}
|
|
20
|
+
export declare abstract class BaseInteractionManager {
|
|
21
|
+
abstract folderPath: string | undefined;
|
|
22
|
+
abstract commandType: number[];
|
|
23
|
+
protected clientId: string;
|
|
24
|
+
protected token: string;
|
|
25
|
+
protected rest: REST;
|
|
26
|
+
constructor(clientId: string, token: string);
|
|
27
|
+
listFromFile(): Promise<Command[]>;
|
|
28
|
+
private fetchCommands;
|
|
29
|
+
list(): Promise<Command[]>;
|
|
30
|
+
listGuild(guildID: string): Promise<Command[]>;
|
|
31
|
+
listAllGuilds(guilds: Guild[]): Promise<{
|
|
32
|
+
guild: string;
|
|
33
|
+
commands: Command[];
|
|
34
|
+
}[]>;
|
|
35
|
+
deploy(commands: Command[]): Promise<void>;
|
|
36
|
+
delete(commands: Command[]): Promise<void>;
|
|
37
|
+
update(commands: Command[]): Promise<void>;
|
|
38
|
+
private deploySingleInteraction;
|
|
39
|
+
private readInteraction;
|
|
40
|
+
private saveInteraction;
|
|
41
|
+
private removeLocalIdFromFile;
|
|
42
|
+
private permissionsToBitfield;
|
|
43
|
+
private bitfieldToPermissions;
|
|
44
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
declare class UnitTime {
|
|
2
|
+
private readonly val;
|
|
3
|
+
constructor(val: number);
|
|
4
|
+
toMilliseconds(): number;
|
|
5
|
+
toSeconds(): number;
|
|
6
|
+
toMinutes(): number;
|
|
7
|
+
toHours(): number;
|
|
8
|
+
toDays(): number;
|
|
9
|
+
toString(): string;
|
|
10
|
+
valueOf(): number;
|
|
11
|
+
value(): number;
|
|
12
|
+
}
|
|
13
|
+
export declare const Time: {
|
|
14
|
+
milisecond: {
|
|
15
|
+
MS_100: UnitTime;
|
|
16
|
+
MS_200: UnitTime;
|
|
17
|
+
MS_500: UnitTime;
|
|
18
|
+
MS_800: UnitTime;
|
|
19
|
+
MS_1000: UnitTime;
|
|
20
|
+
};
|
|
21
|
+
second: {
|
|
22
|
+
SEC_01: UnitTime;
|
|
23
|
+
SEC_02: UnitTime;
|
|
24
|
+
SEC_03: UnitTime;
|
|
25
|
+
SEC_04: UnitTime;
|
|
26
|
+
SEC_05: UnitTime;
|
|
27
|
+
SEC_06: UnitTime;
|
|
28
|
+
SEC_07: UnitTime;
|
|
29
|
+
SEC_08: UnitTime;
|
|
30
|
+
SEC_09: UnitTime;
|
|
31
|
+
SEC_10: UnitTime;
|
|
32
|
+
SEC_11: UnitTime;
|
|
33
|
+
SEC_12: UnitTime;
|
|
34
|
+
SEC_13: UnitTime;
|
|
35
|
+
SEC_14: UnitTime;
|
|
36
|
+
SEC_15: UnitTime;
|
|
37
|
+
SEC_16: UnitTime;
|
|
38
|
+
SEC_17: UnitTime;
|
|
39
|
+
SEC_18: UnitTime;
|
|
40
|
+
SEC_19: UnitTime;
|
|
41
|
+
SEC_20: UnitTime;
|
|
42
|
+
SEC_21: UnitTime;
|
|
43
|
+
SEC_22: UnitTime;
|
|
44
|
+
SEC_23: UnitTime;
|
|
45
|
+
SEC_24: UnitTime;
|
|
46
|
+
SEC_25: UnitTime;
|
|
47
|
+
SEC_26: UnitTime;
|
|
48
|
+
SEC_27: UnitTime;
|
|
49
|
+
SEC_28: UnitTime;
|
|
50
|
+
SEC_29: UnitTime;
|
|
51
|
+
SEC_30: UnitTime;
|
|
52
|
+
SEC_31: UnitTime;
|
|
53
|
+
SEC_32: UnitTime;
|
|
54
|
+
SEC_33: UnitTime;
|
|
55
|
+
SEC_34: UnitTime;
|
|
56
|
+
SEC_35: UnitTime;
|
|
57
|
+
SEC_36: UnitTime;
|
|
58
|
+
SEC_37: UnitTime;
|
|
59
|
+
SEC_38: UnitTime;
|
|
60
|
+
SEC_39: UnitTime;
|
|
61
|
+
SEC_40: UnitTime;
|
|
62
|
+
SEC_41: UnitTime;
|
|
63
|
+
SEC_42: UnitTime;
|
|
64
|
+
SEC_43: UnitTime;
|
|
65
|
+
SEC_44: UnitTime;
|
|
66
|
+
SEC_45: UnitTime;
|
|
67
|
+
SEC_46: UnitTime;
|
|
68
|
+
SEC_47: UnitTime;
|
|
69
|
+
SEC_48: UnitTime;
|
|
70
|
+
SEC_49: UnitTime;
|
|
71
|
+
SEC_50: UnitTime;
|
|
72
|
+
SEC_51: UnitTime;
|
|
73
|
+
SEC_52: UnitTime;
|
|
74
|
+
SEC_53: UnitTime;
|
|
75
|
+
SEC_54: UnitTime;
|
|
76
|
+
SEC_55: UnitTime;
|
|
77
|
+
SEC_56: UnitTime;
|
|
78
|
+
SEC_57: UnitTime;
|
|
79
|
+
SEC_58: UnitTime;
|
|
80
|
+
SEC_59: UnitTime;
|
|
81
|
+
SEC_60: UnitTime;
|
|
82
|
+
};
|
|
83
|
+
minute: {
|
|
84
|
+
MIN_01: UnitTime;
|
|
85
|
+
MIN_02: UnitTime;
|
|
86
|
+
MIN_03: UnitTime;
|
|
87
|
+
MIN_04: UnitTime;
|
|
88
|
+
MIN_05: UnitTime;
|
|
89
|
+
MIN_06: UnitTime;
|
|
90
|
+
MIN_07: UnitTime;
|
|
91
|
+
MIN_08: UnitTime;
|
|
92
|
+
MIN_09: UnitTime;
|
|
93
|
+
MIN_10: UnitTime;
|
|
94
|
+
MIN_11: UnitTime;
|
|
95
|
+
MIN_12: UnitTime;
|
|
96
|
+
MIN_13: UnitTime;
|
|
97
|
+
MIN_14: UnitTime;
|
|
98
|
+
MIN_15: UnitTime;
|
|
99
|
+
MIN_16: UnitTime;
|
|
100
|
+
MIN_17: UnitTime;
|
|
101
|
+
MIN_18: UnitTime;
|
|
102
|
+
MIN_19: UnitTime;
|
|
103
|
+
MIN_20: UnitTime;
|
|
104
|
+
MIN_21: UnitTime;
|
|
105
|
+
MIN_22: UnitTime;
|
|
106
|
+
MIN_23: UnitTime;
|
|
107
|
+
MIN_24: UnitTime;
|
|
108
|
+
MIN_25: UnitTime;
|
|
109
|
+
MIN_26: UnitTime;
|
|
110
|
+
MIN_27: UnitTime;
|
|
111
|
+
MIN_28: UnitTime;
|
|
112
|
+
MIN_29: UnitTime;
|
|
113
|
+
MIN_30: UnitTime;
|
|
114
|
+
MIN_31: UnitTime;
|
|
115
|
+
MIN_32: UnitTime;
|
|
116
|
+
MIN_33: UnitTime;
|
|
117
|
+
MIN_34: UnitTime;
|
|
118
|
+
MIN_35: UnitTime;
|
|
119
|
+
MIN_36: UnitTime;
|
|
120
|
+
MIN_37: UnitTime;
|
|
121
|
+
MIN_38: UnitTime;
|
|
122
|
+
MIN_39: UnitTime;
|
|
123
|
+
MIN_40: UnitTime;
|
|
124
|
+
MIN_41: UnitTime;
|
|
125
|
+
MIN_42: UnitTime;
|
|
126
|
+
MIN_43: UnitTime;
|
|
127
|
+
MIN_44: UnitTime;
|
|
128
|
+
MIN_45: UnitTime;
|
|
129
|
+
MIN_46: UnitTime;
|
|
130
|
+
MIN_47: UnitTime;
|
|
131
|
+
MIN_48: UnitTime;
|
|
132
|
+
MIN_49: UnitTime;
|
|
133
|
+
MIN_50: UnitTime;
|
|
134
|
+
MIN_51: UnitTime;
|
|
135
|
+
MIN_52: UnitTime;
|
|
136
|
+
MIN_53: UnitTime;
|
|
137
|
+
MIN_54: UnitTime;
|
|
138
|
+
MIN_55: UnitTime;
|
|
139
|
+
MIN_56: UnitTime;
|
|
140
|
+
MIN_57: UnitTime;
|
|
141
|
+
MIN_58: UnitTime;
|
|
142
|
+
MIN_59: UnitTime;
|
|
143
|
+
MIN_60: UnitTime;
|
|
144
|
+
};
|
|
145
|
+
hour: {
|
|
146
|
+
HOUR_01: UnitTime;
|
|
147
|
+
HOUR_02: UnitTime;
|
|
148
|
+
HOUR_03: UnitTime;
|
|
149
|
+
HOUR_04: UnitTime;
|
|
150
|
+
HOUR_05: UnitTime;
|
|
151
|
+
HOUR_06: UnitTime;
|
|
152
|
+
HOUR_07: UnitTime;
|
|
153
|
+
HOUR_08: UnitTime;
|
|
154
|
+
HOUR_09: UnitTime;
|
|
155
|
+
HOUR_10: UnitTime;
|
|
156
|
+
HOUR_11: UnitTime;
|
|
157
|
+
HOUR_12: UnitTime;
|
|
158
|
+
HOUR_13: UnitTime;
|
|
159
|
+
HOUR_14: UnitTime;
|
|
160
|
+
HOUR_15: UnitTime;
|
|
161
|
+
HOUR_16: UnitTime;
|
|
162
|
+
HOUR_17: UnitTime;
|
|
163
|
+
HOUR_18: UnitTime;
|
|
164
|
+
HOUR_19: UnitTime;
|
|
165
|
+
HOUR_20: UnitTime;
|
|
166
|
+
HOUR_21: UnitTime;
|
|
167
|
+
HOUR_22: UnitTime;
|
|
168
|
+
HOUR_23: UnitTime;
|
|
169
|
+
HOUR_24: UnitTime;
|
|
170
|
+
};
|
|
171
|
+
day: {
|
|
172
|
+
DAY_01: UnitTime;
|
|
173
|
+
DAY_02: UnitTime;
|
|
174
|
+
DAY_03: UnitTime;
|
|
175
|
+
DAY_04: UnitTime;
|
|
176
|
+
DAY_05: UnitTime;
|
|
177
|
+
DAY_06: UnitTime;
|
|
178
|
+
DAY_07: UnitTime;
|
|
179
|
+
DAY_08: UnitTime;
|
|
180
|
+
DAY_09: UnitTime;
|
|
181
|
+
DAY_10: UnitTime;
|
|
182
|
+
};
|
|
183
|
+
readonly DAY: boolean;
|
|
184
|
+
readonly NIGHT: boolean;
|
|
185
|
+
};
|
|
186
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spatulox/simplediscordbot",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"author": "Spatulox",
|
|
5
5
|
"description": "Simple discord bot framework to set up a bot under 30 secondes",
|
|
6
|
-
"
|
|
6
|
+
"exports": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": ["dist"],
|
|
7
9
|
"bin": {
|
|
8
10
|
"sdb": "dist/cli/MainCLI.js"
|
|
9
11
|
},
|
package/.env.example
DELETED