gralonium 0.2.0

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.
Files changed (50) hide show
  1. package/README.md +62 -0
  2. package/lib/classes/Client.d.ts +44 -0
  3. package/lib/classes/Client.js +162 -0
  4. package/lib/classes/Context.d.ts +25 -0
  5. package/lib/classes/Context.js +139 -0
  6. package/lib/classes/Cooldowns.d.ts +25 -0
  7. package/lib/classes/Cooldowns.js +72 -0
  8. package/lib/classes/Errors.d.ts +135 -0
  9. package/lib/classes/Errors.js +1 -0
  10. package/lib/classes/HelpCommand.d.ts +15 -0
  11. package/lib/classes/HelpCommand.js +1 -0
  12. package/lib/classes/Loader.d.ts +85 -0
  13. package/lib/classes/Loader.js +359 -0
  14. package/lib/classes/Plugins.d.ts +52 -0
  15. package/lib/classes/Plugins.js +107 -0
  16. package/lib/classes/Utils.d.ts +25 -0
  17. package/lib/classes/Utils.js +705 -0
  18. package/lib/classes/builders/CommandBuilder.d.ts +50 -0
  19. package/lib/classes/builders/CommandBuilder.js +107 -0
  20. package/lib/classes/builders/ComponentsV2Builder.d.ts +125 -0
  21. package/lib/classes/builders/ComponentsV2Builder.js +287 -0
  22. package/lib/classes/builders/EventBuilder.d.ts +19 -0
  23. package/lib/classes/builders/EventBuilder.js +1 -0
  24. package/lib/classes/builders/GroupBuilder.d.ts +46 -0
  25. package/lib/classes/builders/GroupBuilder.js +90 -0
  26. package/lib/classes/builders/InteractionBuilder.d.ts +32 -0
  27. package/lib/classes/builders/InteractionBuilder.js +1 -0
  28. package/lib/classes/builders/ParamsBuilder.d.ts +87 -0
  29. package/lib/classes/builders/ParamsBuilder.js +1 -0
  30. package/lib/classes/builders/components/StyleMapper.d.ts +10 -0
  31. package/lib/classes/builders/components/StyleMapper.js +32 -0
  32. package/lib/classes/builders/components/helpers.d.ts +22 -0
  33. package/lib/classes/builders/components/helpers.js +51 -0
  34. package/lib/classes/builders/components/templates.d.ts +13 -0
  35. package/lib/classes/builders/components/templates.js +41 -0
  36. package/lib/classes/experiments/Confirmator.d.ts +58 -0
  37. package/lib/classes/experiments/Confirmator.js +114 -0
  38. package/lib/classes/experiments/Paginator.d.ts +65 -0
  39. package/lib/classes/experiments/Paginator.js +124 -0
  40. package/lib/events/interactionCreate.d.ts +4 -0
  41. package/lib/events/interactionCreate.js +17 -0
  42. package/lib/events/messageCreate.d.ts +4 -0
  43. package/lib/events/messageCreate.js +17 -0
  44. package/lib/events/messageUpdate.d.ts +4 -0
  45. package/lib/events/messageUpdate.js +17 -0
  46. package/lib/experiments.d.ts +2 -0
  47. package/lib/experiments.js +1 -0
  48. package/lib/main.d.ts +18 -0
  49. package/lib/main.js +25 -0
  50. package/package.json +69 -0
package/README.md ADDED
@@ -0,0 +1,62 @@
1
+ ## Install
2
+ ```bash
3
+ npm install gralonium
4
+ ```
5
+
6
+ ## Features
7
+
8
+ * Unified command pipeline for prefix and slash commands
9
+ * Modular command/event/interaction loaders
10
+ * Guards and plugin hooks
11
+ * Built-in cooldowns and permission gates
12
+ * Centralized framework error events (`frameworkError`)
13
+ * Optional debug mode and rate-limit retry for send operations
14
+
15
+ ## Example
16
+
17
+ ```js
18
+ const { Gralonium, GatewayIntentBits, Partials } = require("gralonium");
19
+
20
+ const client = new Gralonium({
21
+ intents: [
22
+ GatewayIntentBits.Guilds,
23
+ GatewayIntentBits.GuildMessages,
24
+ GatewayIntentBits.MessageContent
25
+ ],
26
+ partials: [Partials.Channel],
27
+ prefix: ".",
28
+ debug: true,
29
+ bindProcessHandlers: true,
30
+ retryOnRateLimit: true
31
+ });
32
+
33
+ await client.load("./files");
34
+
35
+ client.on("frameworkError", (err, ctx) => {
36
+ console.error(err, ctx?.command?.data?.name);
37
+ });
38
+
39
+ client.login("TOKEN");
40
+ ```
41
+
42
+ ## Breaking changes
43
+ * Client construction now validates required framework/runtime options (`intents`, `prefix`).
44
+ * Prefix parsing now resolves routing first and then parses args from raw message content, improving quote/space fidelity.
45
+ * Component utilities (`Paginator`, `Confirmator`) now require `setMessage()` and use message-scoped collectors.
46
+ * `Context#send()` now blocks autocomplete replies and supports optional bounded retry for 429 responses.
47
+
48
+ ## Migration notes
49
+
50
+ * Prefer `const { Gralonium } = require("gralonium")`.
51
+ * Ensure your client options always include `intents` and `prefix`.
52
+ * If you use `Paginator`/`Confirmator`, always call `.setMessage(sentMessage)` before `.start()`.
53
+ * Use `retryOnRateLimit: true` only when you want bounded automatic retries for send operations.
54
+
55
+ ## Notes
56
+
57
+ * Unified execution for slash and prefix command handlers is implemented in `Utils.executeCommand()`.
58
+ * Use `frameworkError` to centralize framework/runtime errors.
59
+
60
+ ## Disclaimer
61
+
62
+ Not affiliated with Discord or discord.js.
@@ -0,0 +1,44 @@
1
+ import { Client, ClientOptions, CommandInteraction, Message, Snowflake } from "discord.js";
2
+ import { Context } from "./Context.js";
3
+ import { Loader, Plugin } from "./Loader.js";
4
+ import { HelpCommand } from "./HelpCommand.js";
5
+ import { Cooldowns } from "./Cooldowns.js";
6
+
7
+ export interface EnireRestrictions {
8
+ userIDs: Set<Snowflake>;
9
+ guildIDs: Set<Snowflake>;
10
+ }
11
+
12
+ type MaybePromise<T> = T | Promise<T>;
13
+
14
+ export interface EnireOptions extends ClientOptions {
15
+ autoSync?: boolean;
16
+ context?: typeof Context;
17
+ guildOnly?: boolean;
18
+ owners?: Snowflake[];
19
+ prefix: string | string[] | ((ctx: Context) => MaybePromise<string | string[]>);
20
+ replyOnEdit?: boolean;
21
+ helpCommand?: typeof HelpCommand;
22
+ restrictions?: EnireRestrictions;
23
+ debug?: boolean;
24
+ bindProcessHandlers?: boolean;
25
+ retryOnRateLimit?: boolean;
26
+ }
27
+
28
+ export declare class RedBot extends Client {
29
+ cooldowns: Cooldowns;
30
+ loader: Loader;
31
+ ops: EnireOptions;
32
+ constructor(options: EnireOptions);
33
+ addGlobalPlugins(plugins: Plugin[]): this;
34
+ getContext(data: CommandInteraction | Message): Context;
35
+ load(dir: string, reload?: boolean): Promise<import("./Loader.js").ModuleData<import("./builders/InteractionBuilder.js").InteractionBuilder | import("./builders/CommandBuilder.js").CommandBuilder | import("./builders/EventBuilder.js").EventBuilder | import("./builders/GroupBuilder.js").GroupBuilder, any[]>[]>;
36
+ sync(guildIDs?: string[]): Promise<void>;
37
+ handleFrameworkError(error: unknown, ctx?: Context | null): void;
38
+ login(token: string): Promise<string>;
39
+ destroy(): this;
40
+ }
41
+
42
+ export { RedBot as Enire };
43
+ export { RedBot as Erine };
44
+ export { RedBot as Gralonium };
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Gralonium = exports.Erine = exports.Enire = exports.RedBot = void 0;
4
+
5
+ const discord_js_1 = require("discord.js");
6
+ const Context_js_1 = require("./Context.js");
7
+ const Loader_js_1 = require("./Loader.js");
8
+ const Cooldowns_js_1 = require("./Cooldowns.js");
9
+ const Utils_js_1 = require("./Utils.js");
10
+
11
+ class RedBot extends discord_js_1.Client {
12
+ static #processHandlersBound = false;
13
+ static #boundClients = new Set();
14
+
15
+ cooldowns = new Cooldowns_js_1.Cooldowns(this);
16
+ loader = new Loader_js_1.Loader({ client: this });
17
+ ops;
18
+ #coreListenersBound = false;
19
+
20
+ constructor(options) {
21
+ if (!options || typeof options !== "object") {
22
+ throw new TypeError("Client options are required.");
23
+ }
24
+
25
+ if (options.intents === undefined) {
26
+ throw new TypeError("Missing required client option: intents.");
27
+ }
28
+
29
+ if (!("prefix" in options)) {
30
+ throw new TypeError("Missing required framework option: prefix.");
31
+ }
32
+
33
+ super(options);
34
+ this.ops = options;
35
+
36
+ if (this.ops.guildOnly === undefined) this.ops.guildOnly = true;
37
+ if (typeof this.ops.debug !== "boolean") this.ops.debug = false;
38
+ }
39
+
40
+ addGlobalPlugins(plugins) {
41
+ this.loader.globalPlugins.push(...plugins);
42
+ return this;
43
+ }
44
+
45
+ getContext(data) {
46
+ return new (this.ops.context || Context_js_1.Context)(this, data);
47
+ }
48
+
49
+ async load(dir, reload = false) {
50
+ if (!dir) throw new SyntaxError("Missing module path in Gralonium#load!");
51
+ return this.loader.load(dir, reload);
52
+ }
53
+
54
+ async sync(guildIDs) {
55
+ await this.loader.sync(guildIDs);
56
+ }
57
+
58
+ #debug(message) {
59
+ if (!this.ops.debug) return;
60
+ this.emit("debug", `[gralonium] ${message}`);
61
+ }
62
+
63
+ handleFrameworkError(error, ctx = null) {
64
+ const normalized = error instanceof Error ? error : new Error(String(error));
65
+ const summary = `${normalized.name}: ${normalized.message}`;
66
+ this.#debug(summary);
67
+
68
+ this.emit("frameworkError", normalized, ctx);
69
+ if (this.listenerCount("error") > 0) {
70
+ this.emit("error", normalized);
71
+ }
72
+ }
73
+
74
+ #bindCoreListeners() {
75
+ if (this.#coreListenersBound) return;
76
+
77
+ this.on("messageCreate", async (message) => {
78
+ try {
79
+ await Utils_js_1.Utils.handleMessage(this, message, false);
80
+ } catch (error) {
81
+ this.handleFrameworkError(error, error?.ctx ?? null);
82
+ }
83
+ });
84
+
85
+ if (this.ops.replyOnEdit === true) {
86
+ this.on("messageUpdate", async (_oldMessage, newMessage) => {
87
+ try {
88
+ await Utils_js_1.Utils.handleMessage(this, newMessage, true);
89
+ } catch (error) {
90
+ this.handleFrameworkError(error, error?.ctx ?? null);
91
+ }
92
+ });
93
+ }
94
+
95
+ this.on("interactionCreate", async (interaction) => {
96
+ try {
97
+ await Utils_js_1.Utils.handleInteraction(this, interaction);
98
+ } catch (error) {
99
+ this.handleFrameworkError(error, error?.ctx ?? null);
100
+ }
101
+ });
102
+
103
+ this.#coreListenersBound = true;
104
+ }
105
+
106
+ static #bindProcessHandlers() {
107
+ if (RedBot.#processHandlersBound) return;
108
+
109
+ const dispatch = (error) => {
110
+ for (const client of RedBot.#boundClients) {
111
+ client.handleFrameworkError(error);
112
+ }
113
+ };
114
+
115
+ process.on("uncaughtException", dispatch);
116
+ process.on("unhandledRejection", dispatch);
117
+
118
+ RedBot.#processHandlersBound = true;
119
+ }
120
+
121
+ #registerHelpCommand() {
122
+ if (!this.ops.helpCommand) return;
123
+
124
+ const help = new this.ops.helpCommand();
125
+ if (!this.loader.commands.normal) this.loader.commands.normal = new discord_js_1.Collection();
126
+
127
+ this.loader.commands.normal.set("help", {
128
+ data: help.data,
129
+ params: help.params,
130
+ plugins: help.plugins,
131
+ code: help.code.bind(help),
132
+ });
133
+ }
134
+
135
+ async login(token) {
136
+ if (this.ops.bindProcessHandlers !== false) {
137
+ RedBot.#bindProcessHandlers();
138
+ RedBot.#boundClients.add(this);
139
+ }
140
+
141
+ this.#bindCoreListeners();
142
+ this.#registerHelpCommand();
143
+
144
+ if (this.ops.debug) {
145
+ this.rest.on("rateLimited", (details) => {
146
+ this.#debug(`Rate limited: ${JSON.stringify(details)}`);
147
+ });
148
+ }
149
+
150
+ return super.login(token);
151
+ }
152
+
153
+ destroy() {
154
+ RedBot.#boundClients.delete(this);
155
+ return super.destroy();
156
+ }
157
+ }
158
+
159
+ exports.RedBot = RedBot;
160
+ exports.Enire = RedBot;
161
+ exports.Erine = RedBot;
162
+ exports.Gralonium = RedBot;
@@ -0,0 +1,25 @@
1
+ import { Command, Types } from "../classes/Loader.js";
2
+ import * as P from "./builders/ParamsBuilder.js";
3
+ import { Enire } from "./Client.js";
4
+ import * as DJS from "discord.js";
5
+
6
+ export declare class Context {
7
+ bot: Enire;
8
+ args: string[] | null;
9
+ data: DJS.Message | DJS.CommandInteraction;
10
+ prefix: string;
11
+ isEditedMessage: boolean;
12
+ command: Command<Types.Normal> | null;
13
+ parent: Command<Types.Group> | null;
14
+ params: P.BaseParam[] | null;
15
+ constructor(bot: Enire, data: DJS.Message | DJS.CommandInteraction);
16
+ get message(): DJS.Message | null;
17
+ get interaction(): DJS.CommandInteraction | null;
18
+ get author(): DJS.User;
19
+ get channel(): DJS.TextBasedChannel | null;
20
+ get member(): DJS.GuildMember | DJS.APIInteractionGuildMember | null;
21
+ get guild(): DJS.Guild | null;
22
+ send(payload: string | DJS.MessagePayload | DJS.MessageCreateOptions | DJS.InteractionReplyOptions | DJS.InteractionEditReplyOptions): Promise<DJS.Message<boolean>>;
23
+ react(...emojis: string[]): Promise<DJS.MessageReaction | undefined>;
24
+ get<T>(param: string): T | null;
25
+ }
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Context = void 0;
4
+
5
+ const tslib_1 = require("tslib");
6
+ const DJS = tslib_1.__importStar(require("discord.js"));
7
+
8
+ class Context {
9
+ bot;
10
+ args;
11
+ data;
12
+ prefix = "";
13
+ isEditedMessage = false;
14
+ command;
15
+ parent = null;
16
+ params;
17
+
18
+ constructor(bot, data) {
19
+ this.bot = bot;
20
+ this.data = data;
21
+ this.command = null;
22
+ this.params = this.data instanceof DJS.Message ? [] : [];
23
+ this.args = this.data instanceof DJS.Message ? [] : null;
24
+ }
25
+
26
+ get message() {
27
+ return this.data instanceof DJS.Message ? this.data : null;
28
+ }
29
+
30
+ get interaction() {
31
+ return this.data instanceof DJS.Message ? null : this.data;
32
+ }
33
+
34
+ get author() {
35
+ return this.data instanceof DJS.Message ? this.data.author : this.data.user;
36
+ }
37
+
38
+ get channel() {
39
+ return this.data.channel || null;
40
+ }
41
+
42
+ get member() {
43
+ return this.data.member || null;
44
+ }
45
+
46
+ get guild() {
47
+ return this.data.guild || null;
48
+ }
49
+
50
+ static #isRateLimitError(error) {
51
+ if (!error) return false;
52
+ if (error?.code === 429) return true;
53
+ if (error?.status === 429) return true;
54
+ return false;
55
+ }
56
+
57
+ static #extractRetryAfter(error) {
58
+ const retryAfterHeader = Number(error?.rawError?.retry_after ?? error?.retry_after ?? error?.data?.retry_after);
59
+ if (Number.isFinite(retryAfterHeader) && retryAfterHeader > 0) {
60
+ return Math.ceil(retryAfterHeader * 1000);
61
+ }
62
+
63
+ const resetAfter = Number(error?.requestBody?.json?.retry_after);
64
+ if (Number.isFinite(resetAfter) && resetAfter > 0) {
65
+ return Math.ceil(resetAfter * 1000);
66
+ }
67
+
68
+ return 0;
69
+ }
70
+
71
+ async #sendWithOptionalRetry(callable) {
72
+ try {
73
+ return await callable();
74
+ } catch (error) {
75
+ if (!this.bot.ops?.retryOnRateLimit || !Context.#isRateLimitError(error)) {
76
+ throw error;
77
+ }
78
+
79
+ const retryMs = Context.#extractRetryAfter(error);
80
+ // Bound retries to short windows to avoid hanging command execution paths.
81
+ if (!retryMs || retryMs > 10_000) {
82
+ throw error;
83
+ }
84
+
85
+ await new Promise((resolve) => setTimeout(resolve, retryMs));
86
+ return callable();
87
+ }
88
+ }
89
+
90
+ async send(payload) {
91
+ if (this.data instanceof DJS.Message) {
92
+ return this.#sendWithOptionalRetry(() => this.data.channel.send(payload));
93
+ }
94
+
95
+ if (this.data.isAutocomplete?.()) {
96
+ throw new Error("Autocomplete interactions cannot send message replies. Use interaction.respond() instead.");
97
+ }
98
+
99
+ const replyPayload =
100
+ typeof payload === "string"
101
+ ? { content: payload }
102
+ : payload && typeof payload === "object"
103
+ ? payload
104
+ : { content: String(payload ?? "") };
105
+
106
+ if (this.data.deferred || this.data.replied) {
107
+ return this.#sendWithOptionalRetry(() => this.data.editReply(replyPayload));
108
+ }
109
+
110
+ return this.#sendWithOptionalRetry(() => this.data.reply(replyPayload));
111
+ }
112
+
113
+ async react(...emojis) {
114
+ if (!(this.data instanceof DJS.Message)) return undefined;
115
+
116
+ let lastReaction;
117
+ for (const emoji of emojis) {
118
+ lastReaction = await this.data.react(emoji);
119
+ }
120
+
121
+ return lastReaction;
122
+ }
123
+
124
+ get(param) {
125
+ const lowered = param.toLowerCase();
126
+
127
+ if (this.params?.length) {
128
+ return this.params.find((entry) => entry.name.toLowerCase() === lowered)?.value ?? null;
129
+ }
130
+
131
+ if (this.data instanceof DJS.Message) return null;
132
+
133
+ const option = this.data.options?.data?.find((entry) => entry.name.toLowerCase() === lowered);
134
+ if (!option) return null;
135
+
136
+ return option.attachment ?? option.member ?? option.channel ?? option.role ?? option.user ?? option.value ?? null;
137
+ }
138
+ }
139
+ exports.Context = Context;
@@ -0,0 +1,25 @@
1
+ import { Erine } from "./Client";
2
+ import { Collection } from "discord.js";
3
+ export declare enum Bucket {
4
+ Member = "MEMBER",
5
+ User = "USER",
6
+ Guild = "GUILD",
7
+ Channel = "CHANNEL"
8
+ }
9
+ export declare class Cooldowns {
10
+ bot: Erine;
11
+ track: Collection<string, {
12
+ startedAt: number;
13
+ expiresAt: number;
14
+ }>;
15
+ constructor(bot: Erine);
16
+ getCooldownSource(command: string, id: string, bucket: Bucket): Promise<number | undefined>;
17
+ setCooldownSource(command: string, id: string, bucket: Bucket, time: number): Promise<void>;
18
+ check(command: string, id: string, cooldown: number, bucket: Bucket): Promise<{
19
+ command: string;
20
+ id: string;
21
+ time: number;
22
+ bucket: Bucket;
23
+ left: number;
24
+ } | null>;
25
+ }
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Cooldowns = exports.Bucket = void 0;
4
+ const discord_js_1 = require("discord.js");
5
+
6
+ var Bucket;
7
+ (function (Bucket) {
8
+ Bucket["Member"] = "MEMBER";
9
+ Bucket["User"] = "USER";
10
+ Bucket["Guild"] = "GUILD";
11
+ Bucket["Channel"] = "CHANNEL";
12
+ })(Bucket || (exports.Bucket = Bucket = {}));
13
+
14
+ class Cooldowns {
15
+ bot;
16
+ track = new discord_js_1.Collection();
17
+
18
+ constructor(bot) {
19
+ this.bot = bot;
20
+ }
21
+
22
+ #key(command, id, bucket) {
23
+ return `${command}#${bucket}#${id}`;
24
+ }
25
+
26
+ async getCooldownSource(command, id, bucket) {
27
+ const key = this.#key(command, id, bucket);
28
+ const tracked = this.track.get(key);
29
+ if (!tracked) return undefined;
30
+
31
+ if (Date.now() >= tracked.expiresAt) {
32
+ this.track.delete(key);
33
+ return undefined;
34
+ }
35
+
36
+ return tracked.startedAt;
37
+ }
38
+
39
+ async setCooldownSource(command, id, bucket, time) {
40
+ const now = Date.now();
41
+ this.track.set(this.#key(command, id, bucket), {
42
+ startedAt: now,
43
+ expiresAt: now + time,
44
+ });
45
+ }
46
+
47
+ async check(command, id, cooldown, bucket) {
48
+ const key = this.#key(command, id, bucket);
49
+ const tracked = this.track.get(key);
50
+ if (!tracked) return null;
51
+
52
+ if (Date.now() >= tracked.expiresAt) {
53
+ this.track.delete(key);
54
+ return null;
55
+ }
56
+
57
+ const elapsed = Date.now() - tracked.startedAt;
58
+ if (elapsed >= cooldown) {
59
+ this.track.delete(key);
60
+ return null;
61
+ }
62
+
63
+ return {
64
+ command,
65
+ id,
66
+ time: cooldown,
67
+ bucket,
68
+ left: cooldown - elapsed,
69
+ };
70
+ }
71
+ }
72
+ exports.Cooldowns = Cooldowns;
@@ -0,0 +1,135 @@
1
+ import { Channel, ChannelType, Guild, PermissionResolvable, User } from "discord.js";
2
+ import { BaseParam, ChannelParam } from "./builders/ParamsBuilder.js";
3
+ import { Context } from "./Context.js";
4
+ declare class GuildOnly extends Error {
5
+ ctx: Context;
6
+ constructor(context: Context, message?: string);
7
+ get user(): User;
8
+ }
9
+ declare class NotOwner extends Error {
10
+ ctx: Context;
11
+ constructor(context: Context, message?: string);
12
+ get user(): User;
13
+ }
14
+ declare class CommandNotFound extends Error {
15
+ ctx: Context;
16
+ provided: string;
17
+ constructor(context: Context, provided: string, message?: string);
18
+ }
19
+ declare class UnknownCommandError extends Error {
20
+ ctx: Context;
21
+ error: any;
22
+ constructor(context: Context, error: any, message?: string);
23
+ }
24
+ declare class MissingRequiredParam extends Error {
25
+ ctx: Context;
26
+ param: BaseParam;
27
+ constructor(context: Context, param: BaseParam, message?: string);
28
+ }
29
+ declare class InvalidParam extends Error {
30
+ ctx: Context;
31
+ metadata: Record<string, any>;
32
+ constructor(context: Context, message?: string, metadata?: Record<string, any>);
33
+ }
34
+ declare class InvalidParamNumber extends Error {
35
+ ctx: Context;
36
+ param: BaseParam;
37
+ constructor(context: Context, param: BaseParam, message?: string);
38
+ }
39
+ declare class InvalidParamBoolean extends Error {
40
+ ctx: Context;
41
+ param: BaseParam;
42
+ constructor(context: Context, param: BaseParam, message?: string);
43
+ }
44
+ declare class InvalidParamChoice extends Error {
45
+ ctx: Context;
46
+ param: BaseParam;
47
+ choices: {
48
+ name: string;
49
+ value: any;
50
+ }[];
51
+ constructor(context: Context, param: BaseParam, choices: {
52
+ name: string;
53
+ value: any;
54
+ }[], message?: string);
55
+ }
56
+ declare class InvalidParamMember extends Error {
57
+ ctx: Context;
58
+ param: BaseParam;
59
+ constructor(context: Context, param: BaseParam, message?: string);
60
+ }
61
+ declare class InvalidParamChannel extends Error {
62
+ ctx: Context;
63
+ param: BaseParam;
64
+ constructor(context: Context, param: BaseParam, message?: string);
65
+ }
66
+ declare class InvalidParamRole extends Error {
67
+ ctx: Context;
68
+ param: BaseParam;
69
+ constructor(context: Context, param: BaseParam, message?: string);
70
+ }
71
+ declare class InvalidChannelType extends Error {
72
+ ctx: Context;
73
+ param: ChannelParam;
74
+ provided: ChannelType;
75
+ expected: ChannelType[];
76
+ constructor(context: Context, param: ChannelParam, provided: ChannelType, expected: ChannelType[], message?: string);
77
+ }
78
+ declare class InvalidParamAttachment extends Error {
79
+ ctx: Context;
80
+ param: BaseParam;
81
+ constructor(context: Context, param: BaseParam, message?: string);
82
+ }
83
+ declare class MissingPermission extends Error {
84
+ ctx: Context;
85
+ permissions: PermissionResolvable[];
86
+ constructor(context: Context, perms: PermissionResolvable[], message?: string);
87
+ }
88
+ declare class MissingChannelPermission extends Error {
89
+ ctx: Context;
90
+ permissions: PermissionResolvable[];
91
+ channel: Channel;
92
+ constructor(context: Context, perms: PermissionResolvable[], channel: Channel, message?: string);
93
+ }
94
+ declare class MissingBotPermission extends Error {
95
+ ctx: Context;
96
+ permissions: PermissionResolvable[];
97
+ constructor(context: Context, perms: PermissionResolvable[], message?: string);
98
+ }
99
+ declare class MissingBotChannelPermission extends Error {
100
+ ctx: Context;
101
+ permissions: PermissionResolvable[];
102
+ channel: Channel;
103
+ constructor(context: Context, perms: PermissionResolvable[], channel: Channel, message?: string);
104
+ }
105
+ declare class NotNSFW extends Error {
106
+ ctx: Context;
107
+ constructor(context: Context, message?: string);
108
+ }
109
+ declare class NotInChannelType extends Error {
110
+ ctx: Context;
111
+ types: ChannelType[];
112
+ channel: Channel;
113
+ constructor(ctx: Context, types: ChannelType[], channel: Channel, message?: string);
114
+ }
115
+ declare class OnlyForIDs extends Error {
116
+ ctx: Context;
117
+ snowflakes: string[];
118
+ constructor(context: Context, snowflakes: string[], message?: string);
119
+ }
120
+ declare class CommandInCooldown extends Error {
121
+ ctx: Context;
122
+ timeLeft: number;
123
+ constructor(context: Context, timeLeft: number, message?: string);
124
+ }
125
+ declare class RestrictedUser extends Error {
126
+ ctx: Context;
127
+ user: User;
128
+ constructor(ctx: Context, user: User, message?: string);
129
+ }
130
+ declare class RestrictedGuild extends Error {
131
+ ctx: Context;
132
+ guild: Guild;
133
+ constructor(ctx: Context, guild: Guild, message?: string);
134
+ }
135
+ export { InvalidParam, GuildOnly, NotOwner, CommandNotFound, UnknownCommandError, MissingRequiredParam, InvalidParamNumber, InvalidParamChoice, MissingPermission, MissingChannelPermission, MissingBotPermission, MissingBotChannelPermission, InvalidParamBoolean, InvalidParamMember, InvalidParamChannel, InvalidParamRole, InvalidChannelType, InvalidParamAttachment, NotNSFW, NotInChannelType, OnlyForIDs, CommandInCooldown, RestrictedUser, RestrictedGuild };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RestrictedGuild=exports.RestrictedUser=exports.CommandInCooldown=exports.OnlyForIDs=exports.NotInChannelType=exports.NotNSFW=exports.InvalidParamAttachment=exports.InvalidChannelType=exports.InvalidParamRole=exports.InvalidParamChannel=exports.InvalidParamMember=exports.InvalidParamBoolean=exports.MissingBotChannelPermission=exports.MissingBotPermission=exports.MissingChannelPermission=exports.MissingPermission=exports.InvalidParamChoice=exports.InvalidParamNumber=exports.MissingRequiredParam=exports.UnknownCommandError=exports.CommandNotFound=exports.NotOwner=exports.GuildOnly=exports.InvalidParam=void 0;class GuildOnly extends Error{ctx;constructor(s,e="This command is only available in guilds."){super(e),this.ctx=s}get user(){return this.ctx.author}}exports.GuildOnly=GuildOnly;class NotOwner extends Error{ctx;constructor(s,e="Someone that is not register as owner tried to use this command."){super(e),this.ctx=s}get user(){return this.ctx.author}}exports.NotOwner=NotOwner;class CommandNotFound extends Error{ctx;provided;constructor(s,e,r="That command doesn't exist."){super(r),this.ctx=s,this.provided=e}}exports.CommandNotFound=CommandNotFound;class UnknownCommandError extends Error{ctx;error;constructor(s,e,r="An unknown error"){super(r),this.ctx=s,this.error=e}}exports.UnknownCommandError=UnknownCommandError;class MissingRequiredParam extends Error{ctx;param;constructor(s,e,r="You have to provide all required parameters."){super(r),this.ctx=s,this.param=e}}exports.MissingRequiredParam=MissingRequiredParam;class InvalidParam extends Error{ctx;metadata;constructor(s,e="Some parameter is invalid in arguments provided.",r={}){super(e),this.ctx=s,this.metadata=r}}exports.InvalidParam=InvalidParam;class InvalidParamNumber extends Error{ctx;param;constructor(s,e,r="Some parameter in that command isn't a valid number."){super(r),this.ctx=s,this.param=e}}exports.InvalidParamNumber=InvalidParamNumber;class InvalidParamBoolean extends Error{ctx;param;constructor(s,e,r="Some parameter in that command isn't boolean."){super(r),this.ctx=s,this.param=e}}exports.InvalidParamBoolean=InvalidParamBoolean;class InvalidParamChoice extends Error{ctx;param;choices;constructor(s,e,r,t="Some parameter in that command isn't a valid choice."){super(t),this.ctx=s,this.param=e,this.choices=r}}exports.InvalidParamChoice=InvalidParamChoice;class InvalidParamMember extends Error{ctx;param;constructor(s,e,r="Some parameter in that command isn't a valid member."){super(r),this.ctx=s,this.param=e}}exports.InvalidParamMember=InvalidParamMember;class InvalidParamChannel extends Error{ctx;param;constructor(s,e,r="Some parameter in that command isn't a valid channel."){super(r),this.ctx=s,this.param=e}}exports.InvalidParamChannel=InvalidParamChannel;class InvalidParamRole extends Error{ctx;param;constructor(s,e,r="Some parameter in that command isn't a valid role."){super(r),this.ctx=s,this.param=e}}exports.InvalidParamRole=InvalidParamRole;class InvalidChannelType extends Error{ctx;param;provided;expected;constructor(s,e,r,t,n="Some parameter in that command isn't a valid channel type allowed."){super(n),this.ctx=s,this.param=e,this.provided=r,this.expected=t}}exports.InvalidChannelType=InvalidChannelType;class InvalidParamAttachment extends Error{ctx;param;constructor(s,e,r="Some parameter in that command isn't a valid attachment."){super(r),this.ctx=s,this.param=e}}exports.InvalidParamAttachment=InvalidParamAttachment;class MissingPermission extends Error{ctx;permissions;constructor(s,e,r="The command author doesn't have permissions enough to execute this command."){super(r),this.ctx=s,this.permissions=e}}exports.MissingPermission=MissingPermission;class MissingChannelPermission extends Error{ctx;permissions;channel;constructor(s,e,r,t="The command author doesn't have permissions enough in a channel to execute this command."){super(t),this.ctx=s,this.permissions=e,this.channel=r}}exports.MissingChannelPermission=MissingChannelPermission;class MissingBotPermission extends Error{ctx;permissions;constructor(s,e,r="I don't have permissions enough to execute this command."){super(r),this.ctx=s,this.permissions=e}}exports.MissingBotPermission=MissingBotPermission;class MissingBotChannelPermission extends Error{ctx;permissions;channel;constructor(s,e,r,t="I don't have permissions enough in that channel to execute this command."){super(t),this.ctx=s,this.permissions=e,this.channel=r}}exports.MissingBotChannelPermission=MissingBotChannelPermission;class NotNSFW extends Error{ctx;constructor(s,e="This command can only be executed in a NSFW channel."){super(e),this.ctx=s}}exports.NotNSFW=NotNSFW;class NotInChannelType extends Error{ctx;types;channel;constructor(s,e,r,t="This command can only be executed in certain channel types."){super(t),this.ctx=s,this.types=e,this.channel=r}}exports.NotInChannelType=NotInChannelType;class OnlyForIDs extends Error{ctx;snowflakes;constructor(s,e,r="This command can only be used by specified users."){super(r),this.ctx=s,this.snowflakes=e}}exports.OnlyForIDs=OnlyForIDs;class CommandInCooldown extends Error{ctx;timeLeft;constructor(s,e,r="This command is in cooldown."){super(r),this.ctx=s,this.timeLeft=e}}exports.CommandInCooldown=CommandInCooldown;class RestrictedUser extends Error{ctx;user;constructor(s,e,r="Looks like this user is restricted from bot."){super(r),this.ctx=s,this.user=e}}exports.RestrictedUser=RestrictedUser;class RestrictedGuild extends Error{ctx;guild;constructor(s,e,r="Looks like this guild is restricted from bot."){super(r),this.ctx=s,this.guild=e}}exports.RestrictedGuild=RestrictedGuild;
@@ -0,0 +1,15 @@
1
+ import { type Plugin, CommandBuilder, Context, CommandHelpingObject, GroupHelpingObject, ParamsBuilder } from "../main.js";
2
+ export declare class HelpCommand {
3
+ data: CommandBuilder;
4
+ plugins: Plugin[];
5
+ params: ParamsBuilder;
6
+ code(ctx: Context): Promise<void>;
7
+ sendEmpty(ctx: Context): Promise<void>;
8
+ sendNotFound(ctx: Context): Promise<void>;
9
+ sendCommand(ctx: Context, command: CommandHelpingObject): Promise<void>;
10
+ sendGroup(ctx: Context, group: GroupHelpingObject): Promise<void>;
11
+ getCommand(ctx: Context, q: string): CommandHelpingObject | null;
12
+ getGroup(ctx: Context, q: string): GroupHelpingObject | null;
13
+ private doEmbed;
14
+ private c;
15
+ }