gralonium 0.2.0 → 0.4.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.
- package/lib/classes/Client.d.ts +9 -11
- package/lib/classes/Client.js +10 -13
- package/lib/classes/Context.d.ts +43 -4
- package/lib/classes/Context.js +251 -12
- package/lib/classes/Cooldowns.d.ts +3 -3
- package/lib/classes/Cooldowns.js +3 -8
- package/lib/classes/HelpCommand.d.ts +55 -13
- package/lib/classes/HelpCommand.js +319 -1
- package/lib/classes/Loader.d.ts +17 -11
- package/lib/classes/Loader.js +43 -42
- package/lib/classes/Utils.d.ts +4 -5
- package/lib/classes/Utils.js +32 -21
- package/lib/classes/builders/CommandBuilder.d.ts +10 -0
- package/lib/classes/builders/CommandBuilder.js +16 -0
- package/lib/classes/builders/ComponentsV2Builder.d.ts +285 -113
- package/lib/classes/builders/ComponentsV2Builder.js +1069 -182
- package/lib/classes/builders/GroupBuilder.d.ts +9 -0
- package/lib/classes/builders/GroupBuilder.js +16 -0
- package/lib/classes/builders/InteractionBuilder.d.ts +40 -25
- package/lib/classes/builders/InteractionBuilder.js +102 -1
- package/lib/classes/builders/components/StyleMapper.d.ts +1 -1
- package/lib/classes/builders/components/StyleMapper.js +2 -1
- package/lib/classes/builders/components/helpers.d.ts +68 -4
- package/lib/classes/builders/components/helpers.js +366 -7
- package/lib/classes/builders/components/templates.d.ts +151 -9
- package/lib/classes/builders/components/templates.js +376 -17
- package/lib/classes/builders/components/text.d.ts +24 -0
- package/lib/classes/builders/components/text.js +91 -0
- package/lib/classes/experiments/Confirmator.d.ts +45 -50
- package/lib/classes/experiments/Confirmator.js +37 -21
- package/lib/classes/experiments/Paginator.d.ts +49 -56
- package/lib/classes/experiments/Paginator.js +48 -19
- package/lib/classes/views/V2Paginator.d.ts +91 -0
- package/lib/classes/views/V2Paginator.js +268 -0
- package/lib/classes/views/V2View.d.ts +113 -0
- package/lib/classes/views/V2View.js +438 -0
- package/lib/experiments.d.ts +2 -0
- package/lib/experiments.js +9 -1
- package/lib/main.d.ts +3 -3
- package/lib/main.js +5 -5
- package/package.json +6 -15
- package/lib/events/interactionCreate.d.ts +0 -4
- package/lib/events/interactionCreate.js +0 -17
- package/lib/events/messageCreate.d.ts +0 -4
- package/lib/events/messageCreate.js +0 -17
- package/lib/events/messageUpdate.d.ts +0 -4
- package/lib/events/messageUpdate.js +0 -17
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ApplicationIntegrationType, InteractionContextType } from "discord.js";
|
|
1
2
|
import { Command, Types } from "../Loader.js";
|
|
2
3
|
|
|
3
4
|
type GroupBuilderOptions = {
|
|
@@ -11,6 +12,8 @@ type GroupBuilderOptions = {
|
|
|
11
12
|
userPermissions?: string[];
|
|
12
13
|
botPermissions?: string[];
|
|
13
14
|
guards?: Array<(ctx: any) => boolean | Promise<boolean>>;
|
|
15
|
+
integrationTypes?: Array<ApplicationIntegrationType | number>;
|
|
16
|
+
contexts?: Array<InteractionContextType | number>;
|
|
14
17
|
};
|
|
15
18
|
|
|
16
19
|
export declare class GroupBuilder {
|
|
@@ -25,6 +28,8 @@ export declare class GroupBuilder {
|
|
|
25
28
|
userPermissions: string[];
|
|
26
29
|
botPermissions: string[];
|
|
27
30
|
guards: Array<(ctx: any) => boolean | Promise<boolean>>;
|
|
31
|
+
integrationTypes?: Array<ApplicationIntegrationType | number>;
|
|
32
|
+
contexts?: Array<InteractionContextType | number>;
|
|
28
33
|
constructor(ops?: GroupBuilderOptions);
|
|
29
34
|
setName(name: string): GroupBuilder;
|
|
30
35
|
setDescription(description: string): GroupBuilder;
|
|
@@ -34,12 +39,16 @@ export declare class GroupBuilder {
|
|
|
34
39
|
setBotPermissions(...permissions: string[]): GroupBuilder;
|
|
35
40
|
allowPrefix(allow: boolean): GroupBuilder;
|
|
36
41
|
allowSlash(allow: boolean): GroupBuilder;
|
|
42
|
+
setIntegrationTypes(...types: Array<ApplicationIntegrationType | number | Array<ApplicationIntegrationType | number>>): GroupBuilder;
|
|
43
|
+
setContexts(...contexts: Array<InteractionContextType | number | Array<InteractionContextType | number>>): GroupBuilder;
|
|
37
44
|
toJSON(): {
|
|
38
45
|
name: string;
|
|
39
46
|
description: string;
|
|
40
47
|
options: any[];
|
|
41
48
|
default_member_permissions: string | null | undefined;
|
|
42
49
|
dm_permission: boolean | undefined;
|
|
50
|
+
integration_types?: Array<ApplicationIntegrationType | number>;
|
|
51
|
+
contexts?: Array<InteractionContextType | number>;
|
|
43
52
|
};
|
|
44
53
|
}
|
|
45
54
|
|
|
@@ -20,6 +20,8 @@ class GroupBuilder {
|
|
|
20
20
|
userPermissions;
|
|
21
21
|
botPermissions;
|
|
22
22
|
guards;
|
|
23
|
+
integrationTypes;
|
|
24
|
+
contexts;
|
|
23
25
|
|
|
24
26
|
constructor(options) {
|
|
25
27
|
this.commands = [];
|
|
@@ -33,6 +35,8 @@ class GroupBuilder {
|
|
|
33
35
|
this.userPermissions = permissionArrayPredicate.parse(options?.userPermissions ?? []);
|
|
34
36
|
this.botPermissions = permissionArrayPredicate.parse(options?.botPermissions ?? []);
|
|
35
37
|
this.guards = options?.guards ?? [];
|
|
38
|
+
this.integrationTypes = options?.integrationTypes;
|
|
39
|
+
this.contexts = options?.contexts;
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
setName(name) {
|
|
@@ -75,6 +79,16 @@ class GroupBuilder {
|
|
|
75
79
|
return this;
|
|
76
80
|
}
|
|
77
81
|
|
|
82
|
+
setIntegrationTypes(...types) {
|
|
83
|
+
this.integrationTypes = types.flat();
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
setContexts(...contexts) {
|
|
88
|
+
this.contexts = contexts.flat();
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
|
|
78
92
|
toJSON() {
|
|
79
93
|
return {
|
|
80
94
|
name: this.name,
|
|
@@ -84,6 +98,8 @@ class GroupBuilder {
|
|
|
84
98
|
? (0, CommandBuilder_js_1.validateDefaultMemberPermissions)(this.defaultMemberPermissions)
|
|
85
99
|
: undefined,
|
|
86
100
|
dm_permission: typeof this.guildOnly === "boolean" ? !this.guildOnly : undefined,
|
|
101
|
+
...(this.integrationTypes !== undefined ? { integration_types: this.integrationTypes } : {}),
|
|
102
|
+
...(this.contexts !== undefined ? { contexts: this.contexts } : {}),
|
|
87
103
|
};
|
|
88
104
|
}
|
|
89
105
|
}
|
|
@@ -1,32 +1,47 @@
|
|
|
1
1
|
export declare enum Interactions {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
AnyInteraction = "anyInteraction",
|
|
3
|
+
Autocomplete = "autocomplete",
|
|
4
|
+
Button = "button",
|
|
5
|
+
ChatInput = "chatInput",
|
|
6
|
+
MessageContextMenu = "messageContextMenu",
|
|
7
|
+
Modal = "modalSubmit",
|
|
8
|
+
UserContextMenu = "userContextMenu",
|
|
9
|
+
ChannelSelectMenu = "channelSelectMenu",
|
|
10
|
+
RoleSelectMenu = "roleSelectMenu",
|
|
11
|
+
StringSelectMenu = "stringSelectMenu",
|
|
12
|
+
UserSelectMenu = "userSelectMenu",
|
|
13
|
+
MentionableSelectMenu = "mentionableSelectMenu"
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
export type InteractionMatcher = RegExp | ((key: string, interaction: any) => boolean);
|
|
17
|
+
|
|
15
18
|
export interface InteractionDataBuilder {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
name?: string;
|
|
20
|
+
type: Interactions;
|
|
21
|
+
description?: string;
|
|
22
|
+
prefix?: string;
|
|
23
|
+
match?: InteractionMatcher;
|
|
19
24
|
}
|
|
25
|
+
|
|
20
26
|
export declare class InteractionBuilder {
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
name?: string;
|
|
28
|
+
type: Interactions;
|
|
29
|
+
description: string;
|
|
30
|
+
prefix?: string;
|
|
31
|
+
match?: InteractionMatcher;
|
|
32
|
+
constructor(options?: InteractionDataBuilder);
|
|
33
|
+
setName(name: string): this;
|
|
34
|
+
setDescription(description: string): this;
|
|
35
|
+
setPrefix(prefix: string): this;
|
|
36
|
+
setMatcher(matcher: InteractionMatcher): this;
|
|
37
|
+
hasPattern(): boolean;
|
|
38
|
+
matches(key: string, interaction?: any): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Returns the interaction data parsed as JSON.
|
|
41
|
+
*/
|
|
42
|
+
toJSON(): {
|
|
43
|
+
name: string | undefined;
|
|
23
44
|
description: string;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* Returns the command data parsed as JSON.
|
|
27
|
-
*/
|
|
28
|
-
toJSON(): {
|
|
29
|
-
name: string | undefined;
|
|
30
|
-
description: string;
|
|
31
|
-
};
|
|
45
|
+
prefix?: string;
|
|
46
|
+
};
|
|
32
47
|
}
|
|
@@ -1 +1,102 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InteractionBuilder = exports.Interactions = void 0;
|
|
4
|
+
|
|
5
|
+
var Interactions;
|
|
6
|
+
(function (Interactions) {
|
|
7
|
+
Interactions.AnyInteraction = "anyInteraction";
|
|
8
|
+
Interactions.Autocomplete = "autocomplete";
|
|
9
|
+
Interactions.Button = "button";
|
|
10
|
+
Interactions.ChatInput = "chatInput";
|
|
11
|
+
Interactions.MessageContextMenu = "messageContextMenu";
|
|
12
|
+
Interactions.Modal = "modalSubmit";
|
|
13
|
+
Interactions.UserContextMenu = "userContextMenu";
|
|
14
|
+
Interactions.ChannelSelectMenu = "channelSelectMenu";
|
|
15
|
+
Interactions.RoleSelectMenu = "roleSelectMenu";
|
|
16
|
+
Interactions.StringSelectMenu = "stringSelectMenu";
|
|
17
|
+
Interactions.UserSelectMenu = "userSelectMenu";
|
|
18
|
+
Interactions.MentionableSelectMenu = "mentionableSelectMenu";
|
|
19
|
+
})(Interactions || (exports.Interactions = Interactions = {}));
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Builder describing an interaction handler loaded by Gralonium.
|
|
23
|
+
* Supports exact `name`/`customId` matching as well as `prefix` and `match` (RegExp or predicate).
|
|
24
|
+
*/
|
|
25
|
+
class InteractionBuilder {
|
|
26
|
+
name;
|
|
27
|
+
type;
|
|
28
|
+
description;
|
|
29
|
+
prefix;
|
|
30
|
+
match;
|
|
31
|
+
|
|
32
|
+
constructor(options) {
|
|
33
|
+
this.name = options?.name;
|
|
34
|
+
this.type = options?.type || Interactions.ChatInput;
|
|
35
|
+
this.description = options?.description || "...";
|
|
36
|
+
this.prefix = options?.prefix;
|
|
37
|
+
this.match = options?.match;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
setName(name) {
|
|
41
|
+
this.name = name;
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
setDescription(description) {
|
|
46
|
+
this.description = description;
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Matches any interaction key (`customId` or `commandName`) starting with `prefix`.
|
|
52
|
+
*/
|
|
53
|
+
setPrefix(prefix) {
|
|
54
|
+
this.prefix = prefix;
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Sets a RegExp or predicate `(key, interaction) => boolean` for dynamic interaction routing.
|
|
60
|
+
*/
|
|
61
|
+
setMatcher(matcher) {
|
|
62
|
+
this.match = matcher;
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Returns true if this builder uses a dynamic prefix, RegExp, or predicate matcher.
|
|
68
|
+
*/
|
|
69
|
+
hasPattern() {
|
|
70
|
+
return Boolean(this.prefix || this.match);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Evaluates whether a given interaction key (`customId` / `commandName`) matches this handler.
|
|
75
|
+
*/
|
|
76
|
+
matches(key, interaction) {
|
|
77
|
+
if (this.name !== undefined && this.name !== null && this.name !== "" && key === this.name) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
if (this.prefix && typeof key === "string" && key.startsWith(this.prefix)) {
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
if (this.match instanceof RegExp) {
|
|
84
|
+
this.match.lastIndex = 0;
|
|
85
|
+
return this.match.test(String(key ?? ""));
|
|
86
|
+
}
|
|
87
|
+
if (typeof this.match === "function") {
|
|
88
|
+
return Boolean(this.match(key, interaction));
|
|
89
|
+
}
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
toJSON() {
|
|
94
|
+
return {
|
|
95
|
+
name: this.name,
|
|
96
|
+
description: this.description,
|
|
97
|
+
...(this.prefix !== undefined ? { prefix: this.prefix } : {}),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
exports.InteractionBuilder = InteractionBuilder;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ButtonStyle } from "discord.js";
|
|
2
2
|
|
|
3
|
-
export type ButtonStyleName = "primary" | "secondary" | "success" | "danger" | "link";
|
|
3
|
+
export type ButtonStyleName = "primary" | "secondary" | "success" | "danger" | "link" | "premium";
|
|
4
4
|
export type ButtonStyleInput = ButtonStyleName | ButtonStyle;
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -10,6 +10,7 @@ const STYLE_MAP = {
|
|
|
10
10
|
success: discord_js_1.ButtonStyle.Success,
|
|
11
11
|
danger: discord_js_1.ButtonStyle.Danger,
|
|
12
12
|
link: discord_js_1.ButtonStyle.Link,
|
|
13
|
+
...(discord_js_1.ButtonStyle.Premium !== undefined ? { premium: discord_js_1.ButtonStyle.Premium } : {}),
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -23,7 +24,7 @@ function mapButtonStyle(style) {
|
|
|
23
24
|
if (typeof style === "number") {
|
|
24
25
|
return style;
|
|
25
26
|
}
|
|
26
|
-
const mapped = STYLE_MAP[style.toLowerCase()];
|
|
27
|
+
const mapped = STYLE_MAP[String(style).toLowerCase()];
|
|
27
28
|
if (mapped === undefined) {
|
|
28
29
|
return discord_js_1.ButtonStyle.Primary;
|
|
29
30
|
}
|
|
@@ -1,18 +1,32 @@
|
|
|
1
|
+
import { APIMessageComponent, APIMessageComponentEmoji, Message, RGBTuple } from "discord.js";
|
|
2
|
+
|
|
3
|
+
export declare const MAX_V2_TEXT_LENGTH = 4000;
|
|
4
|
+
export declare const SAFE_V2_TEXT_LENGTH = 3950;
|
|
5
|
+
export declare const MAX_V2_COMPONENTS = 40;
|
|
6
|
+
export declare const MAX_V2_TOP_LEVEL_COMPONENTS = 10;
|
|
7
|
+
|
|
8
|
+
export type AccentColorInput = number | string | RGBTuple | null | undefined;
|
|
9
|
+
export type EmojiInput = string | APIMessageComponentEmoji | null | undefined;
|
|
10
|
+
|
|
11
|
+
export interface DisableComponentsOptions {
|
|
12
|
+
disableButtons?: boolean;
|
|
13
|
+
disableSelects?: boolean;
|
|
14
|
+
disableLinks?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
1
17
|
/**
|
|
2
18
|
* Validates that text content is non-empty.
|
|
3
|
-
*
|
|
19
|
+
* Returns false if `ignoreEmpty` is true and content is blank.
|
|
4
20
|
*/
|
|
5
|
-
export declare function validateTextContent(content: unknown):
|
|
21
|
+
export declare function validateTextContent(content: unknown, options?: { ignoreEmpty?: boolean }): boolean;
|
|
6
22
|
|
|
7
23
|
/**
|
|
8
24
|
* Validates that a button row does not exceed 5 buttons.
|
|
9
|
-
* Throws a descriptive error if validation fails.
|
|
10
25
|
*/
|
|
11
26
|
export declare function validateButtonCount(count: number): void;
|
|
12
27
|
|
|
13
28
|
/**
|
|
14
29
|
* Validates that a select menu does not exceed 25 options.
|
|
15
|
-
* Throws a descriptive error if validation fails.
|
|
16
30
|
*/
|
|
17
31
|
export declare function validateSelectMenuOptions(count: number): void;
|
|
18
32
|
|
|
@@ -20,3 +34,53 @@ export declare function validateSelectMenuOptions(count: number): void;
|
|
|
20
34
|
* Generates a unique custom ID with an optional prefix.
|
|
21
35
|
*/
|
|
22
36
|
export declare function generateCustomId(prefix?: string): string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Resolves a hex string, RGB tuple, integer, or preset name into a 24-bit color integer.
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolveAccentColor(color?: AccentColorInput, fallback?: AccentColorInput): number | null;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Checks whether a URL is valid for Discord media components (`http://`, `https://`, `attachment://`).
|
|
45
|
+
*/
|
|
46
|
+
export declare function isValidMediaUrl(url: unknown): url is string;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Checks whether a URL is valid for Discord link buttons (`http://`, `https://`, `discord://`).
|
|
50
|
+
*/
|
|
51
|
+
export declare function isValidLinkUrl(url: unknown): url is string;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Parses unicode, `<:name:id>`, `<a:name:id>`, `name:id`, snowflake ID, or emoji object into API emoji shape.
|
|
55
|
+
*/
|
|
56
|
+
export declare function parseEmoji(emoji: EmojiInput): APIMessageComponentEmoji | null;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Clips text to `maxLen`, appending `…` if truncated.
|
|
60
|
+
*/
|
|
61
|
+
export declare function clipText(text: unknown, maxLen?: number, fallback?: string): string;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Returns true if the numeric component type is a Discord Components V2 type.
|
|
65
|
+
*/
|
|
66
|
+
export declare function isV2ComponentType(type: number): boolean;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Counts total characters across all TextDisplay components in a component array.
|
|
70
|
+
*/
|
|
71
|
+
export declare function countTextLength(components: unknown[]): number;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Counts total component nodes (including nested Container, Section, ActionRow, and MediaGallery items).
|
|
75
|
+
*/
|
|
76
|
+
export declare function countComponents(components: unknown[]): number;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Recursively clones and disables buttons/selects in both V1 ActionRows and V2 Containers/Sections.
|
|
80
|
+
*/
|
|
81
|
+
export declare function disableComponents(components: unknown[], options?: DisableComponentsOptions): APIMessageComponent[];
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Edits a Discord message to recursively disable its V1 or V2 interactive components.
|
|
85
|
+
*/
|
|
86
|
+
export declare function disableMessageComponents(message: Message | null | undefined, options?: DisableComponentsOptions): Promise<Message | null>;
|