loopbot-discord-sdk 1.0.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/LICENSE +21 -0
- package/README.md +406 -0
- package/dist/Bot.d.ts +323 -0
- package/dist/Bot.d.ts.map +1 -0
- package/dist/Bot.js +482 -0
- package/dist/Bot.js.map +1 -0
- package/dist/Client.d.ts +309 -0
- package/dist/Client.d.ts.map +1 -0
- package/dist/Client.js +533 -0
- package/dist/Client.js.map +1 -0
- package/dist/builders/ActionRowBuilder.d.ts +11 -0
- package/dist/builders/ActionRowBuilder.d.ts.map +1 -0
- package/dist/builders/ActionRowBuilder.js +28 -0
- package/dist/builders/ActionRowBuilder.js.map +1 -0
- package/dist/builders/ButtonBuilder.d.ts +19 -0
- package/dist/builders/ButtonBuilder.d.ts.map +1 -0
- package/dist/builders/ButtonBuilder.js +46 -0
- package/dist/builders/ButtonBuilder.js.map +1 -0
- package/dist/builders/CommandBuilder.d.ts +51 -0
- package/dist/builders/CommandBuilder.d.ts.map +1 -0
- package/dist/builders/CommandBuilder.js +144 -0
- package/dist/builders/CommandBuilder.js.map +1 -0
- package/dist/builders/ContainerBuilder.d.ts +50 -0
- package/dist/builders/ContainerBuilder.d.ts.map +1 -0
- package/dist/builders/ContainerBuilder.js +67 -0
- package/dist/builders/ContainerBuilder.js.map +1 -0
- package/dist/builders/EmbedBuilder.d.ts +21 -0
- package/dist/builders/EmbedBuilder.d.ts.map +1 -0
- package/dist/builders/EmbedBuilder.js +63 -0
- package/dist/builders/EmbedBuilder.js.map +1 -0
- package/dist/builders/FileBuilder.d.ts +30 -0
- package/dist/builders/FileBuilder.d.ts.map +1 -0
- package/dist/builders/FileBuilder.js +42 -0
- package/dist/builders/FileBuilder.js.map +1 -0
- package/dist/builders/MediaGalleryBuilder.d.ts +33 -0
- package/dist/builders/MediaGalleryBuilder.d.ts.map +1 -0
- package/dist/builders/MediaGalleryBuilder.js +38 -0
- package/dist/builders/MediaGalleryBuilder.js.map +1 -0
- package/dist/builders/ModalBuilder.d.ts +21 -0
- package/dist/builders/ModalBuilder.d.ts.map +1 -0
- package/dist/builders/ModalBuilder.js +46 -0
- package/dist/builders/ModalBuilder.js.map +1 -0
- package/dist/builders/SectionBuilder.d.ts +43 -0
- package/dist/builders/SectionBuilder.d.ts.map +1 -0
- package/dist/builders/SectionBuilder.js +55 -0
- package/dist/builders/SectionBuilder.js.map +1 -0
- package/dist/builders/SelectMenuBuilder.d.ts +16 -0
- package/dist/builders/SelectMenuBuilder.d.ts.map +1 -0
- package/dist/builders/SelectMenuBuilder.js +50 -0
- package/dist/builders/SelectMenuBuilder.js.map +1 -0
- package/dist/builders/SeparatorBuilder.d.ts +31 -0
- package/dist/builders/SeparatorBuilder.d.ts.map +1 -0
- package/dist/builders/SeparatorBuilder.js +34 -0
- package/dist/builders/SeparatorBuilder.js.map +1 -0
- package/dist/builders/TextDisplayBuilder.d.ts +22 -0
- package/dist/builders/TextDisplayBuilder.d.ts.map +1 -0
- package/dist/builders/TextDisplayBuilder.js +32 -0
- package/dist/builders/TextDisplayBuilder.js.map +1 -0
- package/dist/context/BaseContext.d.ts +114 -0
- package/dist/context/BaseContext.d.ts.map +1 -0
- package/dist/context/BaseContext.js +189 -0
- package/dist/context/BaseContext.js.map +1 -0
- package/dist/context/ButtonContext.d.ts +30 -0
- package/dist/context/ButtonContext.d.ts.map +1 -0
- package/dist/context/ButtonContext.js +48 -0
- package/dist/context/ButtonContext.js.map +1 -0
- package/dist/context/CommandContext.d.ts +55 -0
- package/dist/context/CommandContext.d.ts.map +1 -0
- package/dist/context/CommandContext.js +98 -0
- package/dist/context/CommandContext.js.map +1 -0
- package/dist/context/ModalContext.d.ts +24 -0
- package/dist/context/ModalContext.d.ts.map +1 -0
- package/dist/context/ModalContext.js +54 -0
- package/dist/context/ModalContext.js.map +1 -0
- package/dist/context/SelectContext.d.ts +38 -0
- package/dist/context/SelectContext.d.ts.map +1 -0
- package/dist/context/SelectContext.js +60 -0
- package/dist/context/SelectContext.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +63 -0
- package/dist/index.js.map +1 -0
- package/dist/types/commands.d.ts +42 -0
- package/dist/types/commands.d.ts.map +1 -0
- package/dist/types/commands.js +25 -0
- package/dist/types/commands.js.map +1 -0
- package/dist/types/discord.d.ts +76 -0
- package/dist/types/discord.d.ts.map +1 -0
- package/dist/types/discord.js +4 -0
- package/dist/types/discord.js.map +1 -0
- package/dist/types/interactions.d.ts +78 -0
- package/dist/types/interactions.d.ts.map +1 -0
- package/dist/types/interactions.js +22 -0
- package/dist/types/interactions.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ButtonBuilder } from './ButtonBuilder';
|
|
2
|
+
import { TextDisplayBuilder } from './TextDisplayBuilder';
|
|
3
|
+
/**
|
|
4
|
+
* Section Component Builder
|
|
5
|
+
* A section is a top-level layout component that allows you to join text
|
|
6
|
+
* contextually with a button or thumbnail.
|
|
7
|
+
* Requires IS_COMPONENTS_V2 flag (32768) on message
|
|
8
|
+
*/
|
|
9
|
+
interface SectionAccessory {
|
|
10
|
+
type: number;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
13
|
+
export declare class SectionBuilder {
|
|
14
|
+
private component;
|
|
15
|
+
/**
|
|
16
|
+
* Add a text display component
|
|
17
|
+
*/
|
|
18
|
+
addText(content: string): this;
|
|
19
|
+
/**
|
|
20
|
+
* Add a text display builder
|
|
21
|
+
*/
|
|
22
|
+
addTextDisplay(text: TextDisplayBuilder): this;
|
|
23
|
+
/**
|
|
24
|
+
* Set a button as the accessory
|
|
25
|
+
*/
|
|
26
|
+
setButtonAccessory(button: ButtonBuilder): this;
|
|
27
|
+
/**
|
|
28
|
+
* Set a thumbnail as the accessory
|
|
29
|
+
*/
|
|
30
|
+
setThumbnailAccessory(url: string, description?: string): this;
|
|
31
|
+
/**
|
|
32
|
+
* Set an optional identifier
|
|
33
|
+
*/
|
|
34
|
+
setId(id: number): this;
|
|
35
|
+
toJSON(): {
|
|
36
|
+
type: 9;
|
|
37
|
+
id?: number;
|
|
38
|
+
components: any[];
|
|
39
|
+
accessory?: SectionAccessory;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=SectionBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SectionBuilder.d.ts","sourceRoot":"","sources":["../../src/builders/SectionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;;;GAKG;AACH,UAAU,gBAAgB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AAED,qBAAa,cAAc;IACvB,OAAO,CAAC,SAAS,CAKe;IAEhC;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAQ9B;;OAEG;IACH,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI;IAK9C;;OAEG;IACH,kBAAkB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;IAK/C;;OAEG;IACH,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAS9D;;OAEG;IACH,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAKvB,MAAM;cArDI,CAAC;aACF,MAAM;oBACC,GAAG,EAAE;oBACL,gBAAgB;;CAqDnC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SectionBuilder = void 0;
|
|
4
|
+
class SectionBuilder {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.component = { type: 9, components: [] };
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Add a text display component
|
|
10
|
+
*/
|
|
11
|
+
addText(content) {
|
|
12
|
+
this.component.components.push({
|
|
13
|
+
type: 10,
|
|
14
|
+
content,
|
|
15
|
+
});
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Add a text display builder
|
|
20
|
+
*/
|
|
21
|
+
addTextDisplay(text) {
|
|
22
|
+
this.component.components.push(text.toJSON());
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Set a button as the accessory
|
|
27
|
+
*/
|
|
28
|
+
setButtonAccessory(button) {
|
|
29
|
+
this.component.accessory = button.toJSON();
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Set a thumbnail as the accessory
|
|
34
|
+
*/
|
|
35
|
+
setThumbnailAccessory(url, description) {
|
|
36
|
+
this.component.accessory = {
|
|
37
|
+
type: 11, // THUMBNAIL
|
|
38
|
+
media: { url },
|
|
39
|
+
description,
|
|
40
|
+
};
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Set an optional identifier
|
|
45
|
+
*/
|
|
46
|
+
setId(id) {
|
|
47
|
+
this.component.id = id;
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
toJSON() {
|
|
51
|
+
return this.component;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.SectionBuilder = SectionBuilder;
|
|
55
|
+
//# sourceMappingURL=SectionBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SectionBuilder.js","sourceRoot":"","sources":["../../src/builders/SectionBuilder.ts"],"names":[],"mappings":";;;AAcA,MAAa,cAAc;IAA3B;QACY,cAAS,GAKb,EAAE,IAAI,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;IAoDpC,CAAC;IAlDG;;OAEG;IACH,OAAO,CAAC,OAAe;QACnB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC;YAC3B,IAAI,EAAE,EAAE;YACR,OAAO;SACV,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,cAAc,CAAC,IAAwB;QACnC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,kBAAkB,CAAC,MAAqB;QACpC,IAAI,CAAC,SAAS,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QAC3C,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,qBAAqB,CAAC,GAAW,EAAE,WAAoB;QACnD,IAAI,CAAC,SAAS,CAAC,SAAS,GAAG;YACvB,IAAI,EAAE,EAAE,EAAE,YAAY;YACtB,KAAK,EAAE,EAAE,GAAG,EAAE;YACd,WAAW;SACd,CAAC;QACF,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,EAAU;QACZ,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM;QACF,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;CACJ;AA1DD,wCA0DC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DiscordComponent, DiscordSelectOption } from '../types/discord';
|
|
2
|
+
export declare class SelectMenuBuilder {
|
|
3
|
+
private select;
|
|
4
|
+
setCustomId(customId: string): this;
|
|
5
|
+
setPlaceholder(placeholder: string): this;
|
|
6
|
+
setMinValues(min: number): this;
|
|
7
|
+
setMaxValues(max: number): this;
|
|
8
|
+
setDisabled(disabled?: boolean): this;
|
|
9
|
+
addOption(label: string, value: string, description?: string, emoji?: {
|
|
10
|
+
name: string;
|
|
11
|
+
id?: string;
|
|
12
|
+
}, isDefault?: boolean): this;
|
|
13
|
+
addOptions(...options: DiscordSelectOption[]): this;
|
|
14
|
+
toJSON(): DiscordComponent;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=SelectMenuBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectMenuBuilder.d.ts","sourceRoot":"","sources":["../../src/builders/SelectMenuBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEzE,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,MAAM,CAA8C;IAE5D,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAKnC,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAKzC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAK/B,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAK/B,WAAW,CAAC,QAAQ,GAAE,OAAc,GAAG,IAAI;IAK3C,SAAS,CACL,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,MAAM,EACpB,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,EACrC,SAAS,CAAC,EAAE,OAAO,GACpB,IAAI;IAaP,UAAU,CAAC,GAAG,OAAO,EAAE,mBAAmB,EAAE,GAAG,IAAI;IAMnD,MAAM,IAAI,gBAAgB;CAG7B"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SelectMenuBuilder = void 0;
|
|
4
|
+
class SelectMenuBuilder {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.select = { type: 3, options: [] };
|
|
7
|
+
}
|
|
8
|
+
setCustomId(customId) {
|
|
9
|
+
this.select.custom_id = customId;
|
|
10
|
+
return this;
|
|
11
|
+
}
|
|
12
|
+
setPlaceholder(placeholder) {
|
|
13
|
+
this.select.placeholder = placeholder;
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
setMinValues(min) {
|
|
17
|
+
this.select.min_values = min;
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
setMaxValues(max) {
|
|
21
|
+
this.select.max_values = max;
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
setDisabled(disabled = true) {
|
|
25
|
+
this.select.disabled = disabled;
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
addOption(label, value, description, emoji, isDefault) {
|
|
29
|
+
const option = {
|
|
30
|
+
label,
|
|
31
|
+
value,
|
|
32
|
+
description,
|
|
33
|
+
emoji,
|
|
34
|
+
default: isDefault,
|
|
35
|
+
};
|
|
36
|
+
this.select.options = this.select.options || [];
|
|
37
|
+
this.select.options.push(option);
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
addOptions(...options) {
|
|
41
|
+
this.select.options = this.select.options || [];
|
|
42
|
+
this.select.options.push(...options);
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
toJSON() {
|
|
46
|
+
return this.select;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.SelectMenuBuilder = SelectMenuBuilder;
|
|
50
|
+
//# sourceMappingURL=SelectMenuBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectMenuBuilder.js","sourceRoot":"","sources":["../../src/builders/SelectMenuBuilder.ts"],"names":[],"mappings":";;;AAEA,MAAa,iBAAiB;IAA9B;QACY,WAAM,GAAqB,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAuDhE,CAAC;IArDG,WAAW,CAAC,QAAgB;QACxB,IAAI,CAAC,MAAM,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 -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Separator Component Builder
|
|
3
|
+
* Adds vertical padding and visual division between other components
|
|
4
|
+
* Requires IS_COMPONENTS_V2 flag (32768) on message
|
|
5
|
+
*/
|
|
6
|
+
export interface SeparatorOptions {
|
|
7
|
+
divider?: boolean;
|
|
8
|
+
spacing?: 1 | 2;
|
|
9
|
+
}
|
|
10
|
+
export declare class SeparatorBuilder {
|
|
11
|
+
private component;
|
|
12
|
+
/**
|
|
13
|
+
* Set whether a visual divider should be displayed
|
|
14
|
+
*/
|
|
15
|
+
setDivider(divider: boolean): this;
|
|
16
|
+
/**
|
|
17
|
+
* Set the spacing size (1 = small, 2 = large)
|
|
18
|
+
*/
|
|
19
|
+
setSpacing(spacing: 1 | 2): this;
|
|
20
|
+
/**
|
|
21
|
+
* Set an optional identifier
|
|
22
|
+
*/
|
|
23
|
+
setId(id: number): this;
|
|
24
|
+
toJSON(): {
|
|
25
|
+
type: 14;
|
|
26
|
+
id?: number;
|
|
27
|
+
divider?: boolean;
|
|
28
|
+
spacing?: number;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=SeparatorBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SeparatorBuilder.d.ts","sourceRoot":"","sources":["../../src/builders/SeparatorBuilder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;CACnB;AAED,qBAAa,gBAAgB;IACzB,OAAO,CAAC,SAAS,CAKA;IAEjB;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAKlC;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI;IAKhC;;OAEG;IACH,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAKvB,MAAM;cA9BI,EAAE;aACH,MAAM;kBACD,OAAO;kBACP,MAAM;;CA8BvB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SeparatorBuilder = void 0;
|
|
4
|
+
class SeparatorBuilder {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.component = { type: 14 };
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Set whether a visual divider should be displayed
|
|
10
|
+
*/
|
|
11
|
+
setDivider(divider) {
|
|
12
|
+
this.component.divider = divider;
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Set the spacing size (1 = small, 2 = large)
|
|
17
|
+
*/
|
|
18
|
+
setSpacing(spacing) {
|
|
19
|
+
this.component.spacing = spacing;
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Set an optional identifier
|
|
24
|
+
*/
|
|
25
|
+
setId(id) {
|
|
26
|
+
this.component.id = id;
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
toJSON() {
|
|
30
|
+
return this.component;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.SeparatorBuilder = SeparatorBuilder;
|
|
34
|
+
//# sourceMappingURL=SeparatorBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SeparatorBuilder.js","sourceRoot":"","sources":["../../src/builders/SeparatorBuilder.ts"],"names":[],"mappings":";;;AAUA,MAAa,gBAAgB;IAA7B;QACY,cAAS,GAKb,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IA6BrB,CAAC;IA3BG;;OAEG;IACH,UAAU,CAAC,OAAgB;QACvB,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,OAAO,CAAC;QACjC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,OAAc;QACrB,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,OAAO,CAAC;QACjC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,EAAU;QACZ,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM;QACF,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;CACJ;AAnCD,4CAmCC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text Display Component Builder
|
|
3
|
+
* Displays text content in a message
|
|
4
|
+
* Requires IS_COMPONENTS_V2 flag (32768) on message
|
|
5
|
+
*/
|
|
6
|
+
export declare class TextDisplayBuilder {
|
|
7
|
+
private component;
|
|
8
|
+
/**
|
|
9
|
+
* Set the text content (supports markdown)
|
|
10
|
+
*/
|
|
11
|
+
setContent(content: string): this;
|
|
12
|
+
/**
|
|
13
|
+
* Set an optional identifier
|
|
14
|
+
*/
|
|
15
|
+
setId(id: number): this;
|
|
16
|
+
toJSON(): {
|
|
17
|
+
type: 10;
|
|
18
|
+
id?: number;
|
|
19
|
+
content: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=TextDisplayBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextDisplayBuilder.d.ts","sourceRoot":"","sources":["../../src/builders/TextDisplayBuilder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,SAAS,CAIa;IAE9B;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAKjC;;OAEG;IACH,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAKvB,MAAM;cArBI,EAAE;aACH,MAAM;iBACF,MAAM;;CAsBtB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TextDisplayBuilder = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Text Display Component Builder
|
|
6
|
+
* Displays text content in a message
|
|
7
|
+
* Requires IS_COMPONENTS_V2 flag (32768) on message
|
|
8
|
+
*/
|
|
9
|
+
class TextDisplayBuilder {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.component = { type: 10, content: '' };
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Set the text content (supports markdown)
|
|
15
|
+
*/
|
|
16
|
+
setContent(content) {
|
|
17
|
+
this.component.content = content;
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Set an optional identifier
|
|
22
|
+
*/
|
|
23
|
+
setId(id) {
|
|
24
|
+
this.component.id = id;
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
toJSON() {
|
|
28
|
+
return this.component;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.TextDisplayBuilder = TextDisplayBuilder;
|
|
32
|
+
//# sourceMappingURL=TextDisplayBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextDisplayBuilder.js","sourceRoot":"","sources":["../../src/builders/TextDisplayBuilder.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,MAAa,kBAAkB;IAA/B;QACY,cAAS,GAIb,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAqBlC,CAAC;IAnBG;;OAEG;IACH,UAAU,CAAC,OAAe;QACtB,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,OAAO,CAAC;QACjC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,EAAU;QACZ,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM;QACF,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;CACJ;AA1BD,gDA0BC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Client } from '../Client';
|
|
2
|
+
import { Interaction, InteractionResponse } from '../types/interactions';
|
|
3
|
+
import { DiscordEmbed, DiscordComponent, DiscordUser, DiscordMember } from '../types/discord';
|
|
4
|
+
import { EmbedBuilder } from '../builders/EmbedBuilder';
|
|
5
|
+
import { ActionRowBuilder } from '../builders/ActionRowBuilder';
|
|
6
|
+
import { ModalBuilder } from '../builders/ModalBuilder';
|
|
7
|
+
export declare abstract class BaseContext {
|
|
8
|
+
protected interaction: Interaction;
|
|
9
|
+
protected client: Client;
|
|
10
|
+
protected applicationId: string;
|
|
11
|
+
protected response: InteractionResponse | null;
|
|
12
|
+
protected deferred: boolean;
|
|
13
|
+
constructor(interaction: Interaction, client: Client, applicationId: string);
|
|
14
|
+
/**
|
|
15
|
+
* Get the interaction ID
|
|
16
|
+
*/
|
|
17
|
+
get id(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Get the interaction token
|
|
20
|
+
*/
|
|
21
|
+
get token(): string;
|
|
22
|
+
/**
|
|
23
|
+
* Get the user who triggered the interaction
|
|
24
|
+
*/
|
|
25
|
+
get user(): DiscordUser;
|
|
26
|
+
/**
|
|
27
|
+
* Get the member (if in guild)
|
|
28
|
+
*/
|
|
29
|
+
get member(): DiscordMember | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Get the guild ID
|
|
32
|
+
*/
|
|
33
|
+
get guildId(): string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Get the channel ID
|
|
36
|
+
*/
|
|
37
|
+
get channelId(): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Get the locale
|
|
40
|
+
*/
|
|
41
|
+
get locale(): string | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Reply to the interaction
|
|
44
|
+
*/
|
|
45
|
+
reply(options: {
|
|
46
|
+
content?: string;
|
|
47
|
+
embeds?: (DiscordEmbed | EmbedBuilder)[];
|
|
48
|
+
components?: (DiscordComponent | ActionRowBuilder)[];
|
|
49
|
+
ephemeral?: boolean;
|
|
50
|
+
}): void;
|
|
51
|
+
/**
|
|
52
|
+
* Reply with simple text
|
|
53
|
+
*/
|
|
54
|
+
replyText(content: string, ephemeral?: boolean): void;
|
|
55
|
+
/**
|
|
56
|
+
* Reply with Components V2 (Container, MediaGallery, Separator, etc.)
|
|
57
|
+
* This automatically sets the IS_COMPONENTS_V2 flag (32768)
|
|
58
|
+
*/
|
|
59
|
+
replyWithComponents(options: {
|
|
60
|
+
components: any[];
|
|
61
|
+
ephemeral?: boolean;
|
|
62
|
+
}): void;
|
|
63
|
+
/**
|
|
64
|
+
* Update the original message (for button/select interactions)
|
|
65
|
+
* This edits the message that contains the component
|
|
66
|
+
*/
|
|
67
|
+
update(options: {
|
|
68
|
+
content?: string;
|
|
69
|
+
embeds?: (DiscordEmbed | EmbedBuilder)[];
|
|
70
|
+
components?: (DiscordComponent | ActionRowBuilder)[];
|
|
71
|
+
}): void;
|
|
72
|
+
/**
|
|
73
|
+
* Update the original message with Components V2
|
|
74
|
+
* This automatically sets the IS_COMPONENTS_V2 flag (32768)
|
|
75
|
+
*/
|
|
76
|
+
updateWithComponents(options: {
|
|
77
|
+
components: any[];
|
|
78
|
+
}): void;
|
|
79
|
+
/**
|
|
80
|
+
* Defer the update (acknowledges without visible loading state)
|
|
81
|
+
* Use this when you need time to process but want to update the message later
|
|
82
|
+
*/
|
|
83
|
+
deferUpdate(): void;
|
|
84
|
+
/**
|
|
85
|
+
* Defer the response (show "thinking...")
|
|
86
|
+
*/
|
|
87
|
+
defer(ephemeral?: boolean): void;
|
|
88
|
+
/**
|
|
89
|
+
* Show a modal
|
|
90
|
+
*/
|
|
91
|
+
showModal(modal: ModalBuilder): void;
|
|
92
|
+
/**
|
|
93
|
+
* Send a follow-up message (after deferring)
|
|
94
|
+
*/
|
|
95
|
+
followUp(options: {
|
|
96
|
+
content?: string;
|
|
97
|
+
embeds?: (DiscordEmbed | EmbedBuilder)[];
|
|
98
|
+
components?: (DiscordComponent | ActionRowBuilder)[];
|
|
99
|
+
ephemeral?: boolean;
|
|
100
|
+
}): Promise<any>;
|
|
101
|
+
/**
|
|
102
|
+
* Edit the original response
|
|
103
|
+
*/
|
|
104
|
+
editReply(options: {
|
|
105
|
+
content?: string;
|
|
106
|
+
embeds?: (DiscordEmbed | EmbedBuilder)[];
|
|
107
|
+
components?: (DiscordComponent | ActionRowBuilder)[];
|
|
108
|
+
}): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Get the response to send
|
|
111
|
+
*/
|
|
112
|
+
getResponse(): InteractionResponse | null;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=BaseContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseContext.d.ts","sourceRoot":"","sources":["../../src/context/BaseContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAA2B,MAAM,uBAAuB,CAAC;AAClG,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC9F,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,8BAAsB,WAAW;IAC7B,SAAS,CAAC,WAAW,EAAE,WAAW,CAAC;IACnC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,aAAa,EAAE,MAAM,CAAC;IAChC,SAAS,CAAC,QAAQ,EAAE,mBAAmB,GAAG,IAAI,CAAQ;IACtD,SAAS,CAAC,QAAQ,EAAE,OAAO,C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;QAC1B,UAAU,EAAE,GAAG,EAAE,CAAC;KACrB,GAAG,IAAI;IAcR;;;OAGG;IACH,WAAW,IAAI,IAAI;IAOnB;;OAEG;IACH,KAAK,CAAC,SAAS,GAAE,OAAe,GAAG,IAAI;IAUvC;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAYpC;;OAEG;IACG,QAAQ,CAAC,OAAO,EAAE;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,CAAC,YAAY,GAAG,YAAY,CAAC,EAAE,CAAC;QACzC,UAAU,CAAC,EAAE,CAAC,gBAAgB,GAAG,gBAAgB,CAAC,EAAE,CAAC;QACrD,SAAS,CAAC,EAAE,OAAO,CAAC;KACvB,GAAG,OAAO,CAAC,GAAG,CAAC;IAahB;;OAEG;IACG,SAAS,CAAC,OAAO,EAAE;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,CAAC,YAAY,GAAG,YAAY,CAAC,EAAE,CAAC;QACzC,UAAU,CAAC,EAAE,CAAC,gBAAgB,GAAG,gBAAgB,CAAC,EAAE,CAAC;KACxD,GAAG,OAAO,CAAC,IAAI,CAAC;IAYjB;;OAEG;IACH,WAAW,IAAI,mBAAmB,GAAG,IAAI;CAG5C"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseContext = void 0;
|
|
4
|
+
const interactions_1 = require("../types/interactions");
|
|
5
|
+
const EmbedBuilder_1 = require("../builders/EmbedBuilder");
|
|
6
|
+
const ActionRowBuilder_1 = require("../builders/ActionRowBuilder");
|
|
7
|
+
class BaseContext {
|
|
8
|
+
constructor(interaction, client, applicationId) {
|
|
9
|
+
this.response = null;
|
|
10
|
+
this.deferred = false;
|
|
11
|
+
this.interaction = interaction;
|
|
12
|
+
this.client = client;
|
|
13
|
+
this.applicationId = applicationId;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get the interaction ID
|
|
17
|
+
*/
|
|
18
|
+
get id() {
|
|
19
|
+
return this.interaction.id;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get the interaction token
|
|
23
|
+
*/
|
|
24
|
+
get token() {
|
|
25
|
+
return this.interaction.token;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get the user who triggered the interaction
|
|
29
|
+
*/
|
|
30
|
+
get user() {
|
|
31
|
+
return this.interaction.user || this.interaction.member?.user;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get the member (if in guild)
|
|
35
|
+
*/
|
|
36
|
+
get member() {
|
|
37
|
+
return this.interaction.member;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get the guild ID
|
|
41
|
+
*/
|
|
42
|
+
get guildId() {
|
|
43
|
+
return this.interaction.guild_id;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get the channel ID
|
|
47
|
+
*/
|
|
48
|
+
get channelId() {
|
|
49
|
+
return this.interaction.channel_id;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get the locale
|
|
53
|
+
*/
|
|
54
|
+
get locale() {
|
|
55
|
+
return this.interaction.locale;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Reply to the interaction
|
|
59
|
+
*/
|
|
60
|
+
reply(options) {
|
|
61
|
+
this.response = {
|
|
62
|
+
type: interactions_1.InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE,
|
|
63
|
+
data: {
|
|
64
|
+
content: options.content,
|
|
65
|
+
embeds: options.embeds?.map((e) => e instanceof EmbedBuilder_1.EmbedBuilder ? e.toJSON() : e),
|
|
66
|
+
components: options.components?.map((c) => c instanceof ActionRowBuilder_1.ActionRowBuilder ? c.toJSON() : c),
|
|
67
|
+
flags: options.ephemeral ? 64 : undefined,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Reply with simple text
|
|
73
|
+
*/
|
|
74
|
+
replyText(content, ephemeral = false) {
|
|
75
|
+
this.reply({ content, ephemeral });
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Reply with Components V2 (Container, MediaGallery, Separator, etc.)
|
|
79
|
+
* This automatically sets the IS_COMPONENTS_V2 flag (32768)
|
|
80
|
+
*/
|
|
81
|
+
replyWithComponents(options) {
|
|
82
|
+
const components = options.components.map((c) => typeof c.toJSON === 'function' ? c.toJSON() : c);
|
|
83
|
+
// Combine flags: IS_COMPONENTS_V2 (32768) + EPHEMERAL (64) if needed
|
|
84
|
+
let flags = 32768; // IS_COMPONENTS_V2
|
|
85
|
+
if (options.ephemeral) {
|
|
86
|
+
flags |= 64;
|
|
87
|
+
}
|
|
88
|
+
this.response = {
|
|
89
|
+
type: interactions_1.InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE,
|
|
90
|
+
data: {
|
|
91
|
+
components,
|
|
92
|
+
flags,
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Update the original message (for button/select interactions)
|
|
98
|
+
* This edits the message that contains the component
|
|
99
|
+
*/
|
|
100
|
+
update(options) {
|
|
101
|
+
this.response = {
|
|
102
|
+
type: interactions_1.InteractionResponseType.UPDATE_MESSAGE,
|
|
103
|
+
data: {
|
|
104
|
+
content: options.content,
|
|
105
|
+
embeds: options.embeds?.map((e) => e instanceof EmbedBuilder_1.EmbedBuilder ? e.toJSON() : e),
|
|
106
|
+
components: options.components?.map((c) => c instanceof ActionRowBuilder_1.ActionRowBuilder ? c.toJSON() : c),
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Update the original message with Components V2
|
|
112
|
+
* This automatically sets the IS_COMPONENTS_V2 flag (32768)
|
|
113
|
+
*/
|
|
114
|
+
updateWithComponents(options) {
|
|
115
|
+
const components = options.components.map((c) => typeof c.toJSON === 'function' ? c.toJSON() : c);
|
|
116
|
+
this.response = {
|
|
117
|
+
type: interactions_1.InteractionResponseType.UPDATE_MESSAGE,
|
|
118
|
+
data: {
|
|
119
|
+
components,
|
|
120
|
+
flags: 32768, // IS_COMPONENTS_V2
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Defer the update (acknowledges without visible loading state)
|
|
126
|
+
* Use this when you need time to process but want to update the message later
|
|
127
|
+
*/
|
|
128
|
+
deferUpdate() {
|
|
129
|
+
this.deferred = true;
|
|
130
|
+
this.response = {
|
|
131
|
+
type: interactions_1.InteractionResponseType.DEFERRED_UPDATE_MESSAGE,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Defer the response (show "thinking...")
|
|
136
|
+
*/
|
|
137
|
+
defer(ephemeral = false) {
|
|
138
|
+
this.deferred = true;
|
|
139
|
+
this.response = {
|
|
140
|
+
type: interactions_1.InteractionResponseType.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE,
|
|
141
|
+
data: {
|
|
142
|
+
flags: ephemeral ? 64 : undefined,
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Show a modal
|
|
148
|
+
*/
|
|
149
|
+
showModal(modal) {
|
|
150
|
+
const modalData = modal.toJSON();
|
|
151
|
+
this.response = {
|
|
152
|
+
type: interactions_1.InteractionResponseType.MODAL,
|
|
153
|
+
data: {
|
|
154
|
+
custom_id: modalData.custom_id,
|
|
155
|
+
title: modalData.title,
|
|
156
|
+
components: modalData.components,
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Send a follow-up message (after deferring)
|
|
162
|
+
*/
|
|
163
|
+
async followUp(options) {
|
|
164
|
+
return this.client.followUp(this.applicationId, this.token, {
|
|
165
|
+
content: options.content,
|
|
166
|
+
embeds: options.embeds?.map((e) => e instanceof EmbedBuilder_1.EmbedBuilder ? e.toJSON() : e),
|
|
167
|
+
components: options.components?.map((c) => c instanceof ActionRowBuilder_1.ActionRowBuilder ? c.toJSON() : c),
|
|
168
|
+
flags: options.ephemeral ? 64 : undefined,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Edit the original response
|
|
173
|
+
*/
|
|
174
|
+
async editReply(options) {
|
|
175
|
+
return this.client.editOriginal(this.applicationId, this.token, {
|
|
176
|
+
content: options.content,
|
|
177
|
+
embeds: options.embeds?.map((e) => e instanceof EmbedBuilder_1.EmbedBuilder ? e.toJSON() : e),
|
|
178
|
+
components: options.components?.map((c) => c instanceof ActionRowBuilder_1.ActionRowBuilder ? c.toJSON() : c),
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Get the response to send
|
|
183
|
+
*/
|
|
184
|
+
getResponse() {
|
|
185
|
+
return this.response;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
exports.BaseContext = BaseContext;
|
|
189
|
+
//# sourceMappingURL=BaseContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseContext.js","sourceRoot":"","sources":["../../src/context/BaseContext.ts"],"names":[],"mappings":";;;AACA,wDAAkG;AAElG,2DAAwD;AACxD,mEAAgE;AAGhE,MAAsB,WAAW;IAO7B,YAAY,WAAwB,EAAE,MAAc,EAAE,aAAqB;QAHjE,aAAQ,GAA+B,IAAI,CAAC;QAC5C,aAAQ,GAAY,KAAK,CAAC;QAGhC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,IAAI,EAAE;QACF,OAAO,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;IA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,30 @@
|
|
|
1
|
+
import { BaseContext } from './BaseContext';
|
|
2
|
+
import { Client } from '../Client';
|
|
3
|
+
import { Interaction } from '../types/interactions';
|
|
4
|
+
import { DiscordEmbed, DiscordComponent, DiscordMessage } from '../types/discord';
|
|
5
|
+
import { EmbedBuilder } from '../builders/EmbedBuilder';
|
|
6
|
+
import { ActionRowBuilder } from '../builders/ActionRowBuilder';
|
|
7
|
+
export declare class ButtonContext extends BaseContext {
|
|
8
|
+
constructor(interaction: Interaction, client: Client, applicationId: string);
|
|
9
|
+
/**
|
|
10
|
+
* Get the custom ID of the button
|
|
11
|
+
*/
|
|
12
|
+
get customId(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Get the message the button was attached to
|
|
15
|
+
*/
|
|
16
|
+
get message(): DiscordMessage | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Update the message the button is on
|
|
19
|
+
*/
|
|
20
|
+
update(options: {
|
|
21
|
+
content?: string;
|
|
22
|
+
embeds?: (DiscordEmbed | EmbedBuilder)[];
|
|
23
|
+
components?: (DiscordComponent | ActionRowBuilder)[];
|
|
24
|
+
}): void;
|
|
25
|
+
/**
|
|
26
|
+
* Defer the update (show loading on button)
|
|
27
|
+
*/
|
|
28
|
+
deferUpdate(): void;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=ButtonContext.d.ts.map
|