@buape/carbon 0.11.0 → 0.12.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 (101) hide show
  1. package/README.md +1 -1
  2. package/dist/package.json +3 -3
  3. package/dist/src/abstracts/AnySelectMenu.d.ts +7 -0
  4. package/dist/src/abstracts/AnySelectMenu.d.ts.map +1 -1
  5. package/dist/src/abstracts/AnySelectMenu.js +8 -0
  6. package/dist/src/abstracts/AnySelectMenu.js.map +1 -1
  7. package/dist/src/abstracts/BaseListener.d.ts +3 -3
  8. package/dist/src/abstracts/BaseListener.d.ts.map +1 -1
  9. package/dist/src/abstracts/BaseListener.js.map +1 -1
  10. package/dist/src/classes/Client.d.ts +5 -0
  11. package/dist/src/classes/Client.d.ts.map +1 -1
  12. package/dist/src/classes/Client.js +7 -1
  13. package/dist/src/classes/Client.js.map +1 -1
  14. package/dist/src/classes/CommandWithSubcommandGroups.d.ts.map +1 -1
  15. package/dist/src/classes/CommandWithSubcommandGroups.js +4 -8
  16. package/dist/src/classes/CommandWithSubcommandGroups.js.map +1 -1
  17. package/dist/src/classes/CommandWithSubcommands.d.ts.map +1 -1
  18. package/dist/src/classes/CommandWithSubcommands.js +2 -4
  19. package/dist/src/classes/CommandWithSubcommands.js.map +1 -1
  20. package/dist/src/classes/Modal.d.ts +2 -1
  21. package/dist/src/classes/Modal.d.ts.map +1 -1
  22. package/dist/src/classes/Modal.js.map +1 -1
  23. package/dist/src/classes/components/Label.d.ts +3 -3
  24. package/dist/src/classes/components/Label.d.ts.map +1 -1
  25. package/dist/src/classes/components/Label.js +6 -2
  26. package/dist/src/classes/components/Label.js.map +1 -1
  27. package/dist/src/classes/components/ModalChannelSelectMenu.d.ts +62 -0
  28. package/dist/src/classes/components/ModalChannelSelectMenu.d.ts.map +1 -0
  29. package/dist/src/classes/components/ModalChannelSelectMenu.js +73 -0
  30. package/dist/src/classes/components/ModalChannelSelectMenu.js.map +1 -0
  31. package/dist/src/classes/components/ModalMentionableSelectMenu.d.ts +58 -0
  32. package/dist/src/classes/components/ModalMentionableSelectMenu.d.ts.map +1 -0
  33. package/dist/src/classes/components/ModalMentionableSelectMenu.js +68 -0
  34. package/dist/src/classes/components/ModalMentionableSelectMenu.js.map +1 -0
  35. package/dist/src/classes/components/ModalRoleSelectMenu.d.ts +58 -0
  36. package/dist/src/classes/components/ModalRoleSelectMenu.d.ts.map +1 -0
  37. package/dist/src/classes/components/ModalRoleSelectMenu.js +68 -0
  38. package/dist/src/classes/components/ModalRoleSelectMenu.js.map +1 -0
  39. package/dist/src/classes/components/ModalStringSelectMenu.d.ts +56 -8
  40. package/dist/src/classes/components/ModalStringSelectMenu.d.ts.map +1 -1
  41. package/dist/src/classes/components/ModalStringSelectMenu.js +59 -10
  42. package/dist/src/classes/components/ModalStringSelectMenu.js.map +1 -1
  43. package/dist/src/classes/components/ModalUserSelectMenu.d.ts +58 -0
  44. package/dist/src/classes/components/ModalUserSelectMenu.d.ts.map +1 -0
  45. package/dist/src/classes/components/ModalUserSelectMenu.js +68 -0
  46. package/dist/src/classes/components/ModalUserSelectMenu.js.map +1 -0
  47. package/dist/src/internals/ComponentHandler.d.ts.map +1 -1
  48. package/dist/src/internals/ComponentHandler.js +7 -3
  49. package/dist/src/internals/ComponentHandler.js.map +1 -1
  50. package/dist/src/internals/EmojiHandler.d.ts +19 -0
  51. package/dist/src/internals/EmojiHandler.d.ts.map +1 -0
  52. package/dist/src/internals/EmojiHandler.js +35 -0
  53. package/dist/src/internals/EmojiHandler.js.map +1 -0
  54. package/dist/src/internals/EventHandler.d.ts +2 -2
  55. package/dist/src/internals/EventHandler.d.ts.map +1 -1
  56. package/dist/src/internals/EventHandler.js +3 -1
  57. package/dist/src/internals/EventHandler.js.map +1 -1
  58. package/dist/src/internals/FieldsHandler.d.ts +46 -16
  59. package/dist/src/internals/FieldsHandler.d.ts.map +1 -1
  60. package/dist/src/internals/FieldsHandler.js +87 -26
  61. package/dist/src/internals/FieldsHandler.js.map +1 -1
  62. package/dist/src/internals/ModalHandler.d.ts.map +1 -1
  63. package/dist/src/internals/ModalHandler.js +7 -1
  64. package/dist/src/internals/ModalHandler.js.map +1 -1
  65. package/dist/src/internals/OptionsHandler.d.ts +17 -11
  66. package/dist/src/internals/OptionsHandler.d.ts.map +1 -1
  67. package/dist/src/internals/OptionsHandler.js +38 -13
  68. package/dist/src/internals/OptionsHandler.js.map +1 -1
  69. package/dist/src/plugins/gateway/GatewayPlugin.d.ts.map +1 -1
  70. package/dist/src/plugins/gateway/GatewayPlugin.js +1 -1
  71. package/dist/src/plugins/gateway/GatewayPlugin.js.map +1 -1
  72. package/dist/src/plugins/gateway/index.d.ts +1 -0
  73. package/dist/src/plugins/gateway/index.d.ts.map +1 -1
  74. package/dist/src/plugins/gateway/index.js +1 -0
  75. package/dist/src/plugins/gateway/index.js.map +1 -1
  76. package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.d.ts +4 -0
  77. package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.d.ts.map +1 -1
  78. package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.js +2 -0
  79. package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.js.map +1 -1
  80. package/dist/src/structures/Emoji.d.ts +64 -0
  81. package/dist/src/structures/Emoji.d.ts.map +1 -0
  82. package/dist/src/structures/Emoji.js +136 -0
  83. package/dist/src/structures/Emoji.js.map +1 -0
  84. package/dist/src/structures/Guild.d.ts +13 -2
  85. package/dist/src/structures/Guild.d.ts.map +1 -1
  86. package/dist/src/structures/Guild.js +25 -1
  87. package/dist/src/structures/Guild.js.map +1 -1
  88. package/dist/src/structures/GuildMember.d.ts +15 -0
  89. package/dist/src/structures/GuildMember.d.ts.map +1 -1
  90. package/dist/src/structures/GuildMember.js +14 -0
  91. package/dist/src/structures/GuildMember.js.map +1 -1
  92. package/dist/src/types/index.d.ts +4 -0
  93. package/dist/src/types/index.d.ts.map +1 -1
  94. package/dist/src/types/index.js.map +1 -1
  95. package/dist/src/types/listeners.d.ts +3 -0
  96. package/dist/src/types/listeners.d.ts.map +1 -1
  97. package/dist/src/utils/payload.d.ts.map +1 -1
  98. package/dist/src/utils/payload.js +20 -5
  99. package/dist/src/utils/payload.js.map +1 -1
  100. package/dist/tsconfig.tsbuildinfo +1 -1
  101. package/package.json +3 -3
@@ -0,0 +1,68 @@
1
+ import { ComponentType } from "discord-api-types/v10";
2
+ import { BaseModalComponent } from "../../abstracts/BaseModalComponent.js";
3
+ import { parseCustomId } from "../../utils/customIdParser.js";
4
+ export class ModalMentionableSelectMenu extends BaseModalComponent {
5
+ type = ComponentType.MentionableSelect;
6
+ isV2 = false;
7
+ /**
8
+ * This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
9
+ * By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
10
+ * It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
11
+ *
12
+ * You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
13
+ * - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
14
+ * - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
15
+ *
16
+ * @param id - The custom ID of the component as received from an interaction event
17
+ * @returns The base key and the data object
18
+ */
19
+ customIdParser = parseCustomId;
20
+ /**
21
+ * The minimum number of values that must be selected
22
+ */
23
+ minValues;
24
+ /**
25
+ * The maximum number of values that can be selected
26
+ */
27
+ maxValues;
28
+ /**
29
+ * Whether this component is required (defaults to true in modals)
30
+ */
31
+ required;
32
+ /**
33
+ * The placeholder text for the select menu
34
+ */
35
+ placeholder;
36
+ /**
37
+ * Default values for the select menu
38
+ */
39
+ defaultValues;
40
+ serialize = () => {
41
+ const data = {
42
+ type: this.type,
43
+ custom_id: this.customId,
44
+ placeholder: this.placeholder,
45
+ min_values: this.minValues,
46
+ max_values: this.maxValues,
47
+ default_values: this.defaultValues
48
+ };
49
+ // In modals, required defaults to true
50
+ if (this.required !== undefined) {
51
+ data.required = this.required;
52
+ }
53
+ return data;
54
+ };
55
+ /**
56
+ * The disabled field is not allowed on modal select components
57
+ * @throws Error when trying to set disabled to true
58
+ */
59
+ set disabled(value) {
60
+ if (value === true) {
61
+ throw new Error("The 'disabled' field is not allowed on modal select components");
62
+ }
63
+ }
64
+ get disabled() {
65
+ return undefined;
66
+ }
67
+ }
68
+ //# sourceMappingURL=ModalMentionableSelectMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModalMentionableSelectMenu.js","sourceRoot":"","sources":["../../../../src/classes/components/ModalMentionableSelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAI1E,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAE7D,MAAM,OAAgB,0BAA2B,SAAQ,kBAAkB;IACjE,IAAI,GAAG,aAAa,CAAC,iBAA0B,CAAA;IAC/C,IAAI,GAAG,KAAK,CAAA;IAUrB;;;;;;;;;;;OAWG;IACH,cAAc,GAA0C,aAAa,CAAA;IAErE;;OAEG;IACH,SAAS,CAAS;IAElB;;OAEG;IACH,SAAS,CAAS;IAElB;;OAEG;IACH,QAAQ,CAAU;IAElB;;OAEG;IACH,WAAW,CAAS;IAEpB;;OAEG;IACH,aAAa,CAAkD;IAO/D,SAAS,GAAG,GAAkC,EAAE;QAC/C,MAAM,IAAI,GAAkC;YAC3C,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,QAAQ;YACxB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,cAAc,EAAE,IAAI,CAAC,aAAa;SAClC,CAAA;QAED,uCAAuC;QACvC,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC9B,CAAC;QAED,OAAO,IAAI,CAAA;IACZ,CAAC,CAAA;IAED;;;OAGG;IACH,IAAI,QAAQ,CAAC,KAA0B;QACtC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CACd,gEAAgE,CAChE,CAAA;QACF,CAAC;IACF,CAAC;IAED,IAAI,QAAQ;QACX,OAAO,SAAS,CAAA;IACjB,CAAC;CACD"}
@@ -0,0 +1,58 @@
1
+ import { type APIRoleSelectComponent, ComponentType } from "discord-api-types/v10";
2
+ import { BaseModalComponent } from "../../abstracts/BaseModalComponent.js";
3
+ import type { RoleSelectMenuInteraction } from "../../internals/RoleSelectMenuInteraction.js";
4
+ import type { ComponentParserResult } from "../../types/index.js";
5
+ import type { ComponentData } from "../../types/index.js";
6
+ export declare abstract class ModalRoleSelectMenu extends BaseModalComponent {
7
+ readonly type: ComponentType.RoleSelect;
8
+ readonly isV2 = false;
9
+ /**
10
+ * The custom ID of the component.
11
+ * If you want to provide a custom ID with additional data, you should either follow the default parser's format or implement your own custom parser.
12
+ *
13
+ * @see {@link customIdParser}
14
+ */
15
+ abstract customId: string;
16
+ /**
17
+ * This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
18
+ * By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
19
+ * It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
20
+ *
21
+ * You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
22
+ * - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
23
+ * - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
24
+ *
25
+ * @param id - The custom ID of the component as received from an interaction event
26
+ * @returns The base key and the data object
27
+ */
28
+ customIdParser: (id: string) => ComponentParserResult;
29
+ /**
30
+ * The minimum number of values that must be selected
31
+ */
32
+ minValues?: number;
33
+ /**
34
+ * The maximum number of values that can be selected
35
+ */
36
+ maxValues?: number;
37
+ /**
38
+ * Whether this component is required (defaults to true in modals)
39
+ */
40
+ required?: boolean;
41
+ /**
42
+ * The placeholder text for the select menu
43
+ */
44
+ placeholder?: string;
45
+ /**
46
+ * Default values for the select menu
47
+ */
48
+ defaultValues?: APIRoleSelectComponent["default_values"];
49
+ abstract run(interaction: RoleSelectMenuInteraction, data: ComponentData): unknown | Promise<unknown>;
50
+ serialize: () => APIRoleSelectComponent;
51
+ /**
52
+ * The disabled field is not allowed on modal select components
53
+ * @throws Error when trying to set disabled to true
54
+ */
55
+ set disabled(value: boolean | undefined);
56
+ get disabled(): boolean | undefined;
57
+ }
58
+ //# sourceMappingURL=ModalRoleSelectMenu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModalRoleSelectMenu.d.ts","sourceRoot":"","sources":["../../../../src/classes/components/ModalRoleSelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,sBAAsB,EAC3B,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAC1E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8CAA8C,CAAA;AAC7F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAGzD,8BAAsB,mBAAoB,SAAQ,kBAAkB;IACnE,QAAQ,CAAC,IAAI,2BAAoC;IACjD,QAAQ,CAAC,IAAI,SAAQ;IAErB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAEzB;;;;;;;;;;;OAWG;IACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,qBAAqB,CAAgB;IAErE;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,aAAa,CAAC,EAAE,sBAAsB,CAAC,gBAAgB,CAAC,CAAA;IAExD,QAAQ,CAAC,GAAG,CACX,WAAW,EAAE,yBAAyB,EACtC,IAAI,EAAE,aAAa,GACjB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAE7B,SAAS,QAAO,sBAAsB,CAgBrC;IAED;;;OAGG;IACH,IAAI,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,EAMtC;IAED,IAAI,QAAQ,IAAI,OAAO,GAAG,SAAS,CAElC;CACD"}
@@ -0,0 +1,68 @@
1
+ import { ComponentType } from "discord-api-types/v10";
2
+ import { BaseModalComponent } from "../../abstracts/BaseModalComponent.js";
3
+ import { parseCustomId } from "../../utils/customIdParser.js";
4
+ export class ModalRoleSelectMenu extends BaseModalComponent {
5
+ type = ComponentType.RoleSelect;
6
+ isV2 = false;
7
+ /**
8
+ * This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
9
+ * By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
10
+ * It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
11
+ *
12
+ * You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
13
+ * - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
14
+ * - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
15
+ *
16
+ * @param id - The custom ID of the component as received from an interaction event
17
+ * @returns The base key and the data object
18
+ */
19
+ customIdParser = parseCustomId;
20
+ /**
21
+ * The minimum number of values that must be selected
22
+ */
23
+ minValues;
24
+ /**
25
+ * The maximum number of values that can be selected
26
+ */
27
+ maxValues;
28
+ /**
29
+ * Whether this component is required (defaults to true in modals)
30
+ */
31
+ required;
32
+ /**
33
+ * The placeholder text for the select menu
34
+ */
35
+ placeholder;
36
+ /**
37
+ * Default values for the select menu
38
+ */
39
+ defaultValues;
40
+ serialize = () => {
41
+ const data = {
42
+ type: this.type,
43
+ custom_id: this.customId,
44
+ placeholder: this.placeholder,
45
+ min_values: this.minValues,
46
+ max_values: this.maxValues,
47
+ default_values: this.defaultValues
48
+ };
49
+ // In modals, required defaults to true
50
+ if (this.required !== undefined) {
51
+ data.required = this.required;
52
+ }
53
+ return data;
54
+ };
55
+ /**
56
+ * The disabled field is not allowed on modal select components
57
+ * @throws Error when trying to set disabled to true
58
+ */
59
+ set disabled(value) {
60
+ if (value === true) {
61
+ throw new Error("The 'disabled' field is not allowed on modal select components");
62
+ }
63
+ }
64
+ get disabled() {
65
+ return undefined;
66
+ }
67
+ }
68
+ //# sourceMappingURL=ModalRoleSelectMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModalRoleSelectMenu.js","sourceRoot":"","sources":["../../../../src/classes/components/ModalRoleSelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAI1E,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAE7D,MAAM,OAAgB,mBAAoB,SAAQ,kBAAkB;IAC1D,IAAI,GAAG,aAAa,CAAC,UAAmB,CAAA;IACxC,IAAI,GAAG,KAAK,CAAA;IAUrB;;;;;;;;;;;OAWG;IACH,cAAc,GAA0C,aAAa,CAAA;IAErE;;OAEG;IACH,SAAS,CAAS;IAElB;;OAEG;IACH,SAAS,CAAS;IAElB;;OAEG;IACH,QAAQ,CAAU;IAElB;;OAEG;IACH,WAAW,CAAS;IAEpB;;OAEG;IACH,aAAa,CAA2C;IAOxD,SAAS,GAAG,GAA2B,EAAE;QACxC,MAAM,IAAI,GAA2B;YACpC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,QAAQ;YACxB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,cAAc,EAAE,IAAI,CAAC,aAAa;SAClC,CAAA;QAED,uCAAuC;QACvC,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC9B,CAAC;QAED,OAAO,IAAI,CAAA;IACZ,CAAC,CAAA;IAED;;;OAGG;IACH,IAAI,QAAQ,CAAC,KAA0B;QACtC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CACd,gEAAgE,CAChE,CAAA;QACF,CAAC;IACF,CAAC;IAED,IAAI,QAAQ;QACX,OAAO,SAAS,CAAA;IACjB,CAAC;CACD"}
@@ -1,10 +1,58 @@
1
- import { StringSelectMenu } from "./StringSelectMenu.js";
2
- export declare abstract class ModalStringSelectMenu extends StringSelectMenu {
3
- required: boolean;
4
- disabled: false;
5
- serializeExtra(): {
6
- required: boolean;
7
- };
8
- protected get serializeDeleteKeys(): string[];
1
+ import { type APIStringSelectComponent, ComponentType } from "discord-api-types/v10";
2
+ import { BaseModalComponent } from "../../abstracts/BaseModalComponent.js";
3
+ import type { StringSelectMenuInteraction } from "../../internals/StringSelectMenuInteraction.js";
4
+ import type { ComponentParserResult } from "../../types/index.js";
5
+ import type { ComponentData } from "../../types/index.js";
6
+ export declare abstract class ModalStringSelectMenu extends BaseModalComponent {
7
+ readonly type: ComponentType.StringSelect;
8
+ readonly isV2 = false;
9
+ /**
10
+ * The custom ID of the component.
11
+ * If you want to provide a custom ID with additional data, you should either follow the default parser's format or implement your own custom parser.
12
+ *
13
+ * @see {@link customIdParser}
14
+ */
15
+ abstract customId: string;
16
+ /**
17
+ * This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
18
+ * By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
19
+ * It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
20
+ *
21
+ * You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
22
+ * - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
23
+ * - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
24
+ *
25
+ * @param id - The custom ID of the component as received from an interaction event
26
+ * @returns The base key and the data object
27
+ */
28
+ customIdParser: (id: string) => ComponentParserResult;
29
+ /**
30
+ * The minimum number of values that must be selected
31
+ */
32
+ minValues?: number;
33
+ /**
34
+ * The maximum number of values that can be selected
35
+ */
36
+ maxValues?: number;
37
+ /**
38
+ * Whether this component is required (defaults to true in modals)
39
+ */
40
+ required?: boolean;
41
+ /**
42
+ * The placeholder text for the select menu
43
+ */
44
+ placeholder?: string;
45
+ /**
46
+ * The options for the select menu
47
+ */
48
+ abstract options: APIStringSelectComponent["options"];
49
+ abstract run(interaction: StringSelectMenuInteraction, data: ComponentData): unknown | Promise<unknown>;
50
+ serialize: () => APIStringSelectComponent;
51
+ /**
52
+ * The disabled field is not allowed on modal select components
53
+ * @throws Error when trying to set disabled to true
54
+ */
55
+ set disabled(value: boolean | undefined);
56
+ get disabled(): boolean | undefined;
9
57
  }
10
58
  //# sourceMappingURL=ModalStringSelectMenu.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ModalStringSelectMenu.d.ts","sourceRoot":"","sources":["../../../../src/classes/components/ModalStringSelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAExD,8BAAsB,qBAAsB,SAAQ,gBAAgB;IACnE,QAAQ,UAAQ;IACP,QAAQ,EAAE,KAAK,CAAQ;IAEhC,cAAc;;;IAOd,SAAS,KAAK,mBAAmB,IAAI,MAAM,EAAE,CAE5C;CACD"}
1
+ {"version":3,"file":"ModalStringSelectMenu.d.ts","sourceRoot":"","sources":["../../../../src/classes/components/ModalStringSelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,wBAAwB,EAC7B,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAC1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,gDAAgD,CAAA;AACjG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAGzD,8BAAsB,qBAAsB,SAAQ,kBAAkB;IACrE,QAAQ,CAAC,IAAI,6BAAsC;IACnD,QAAQ,CAAC,IAAI,SAAQ;IAErB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAEzB;;;;;;;;;;;OAWG;IACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,qBAAqB,CAAgB;IAErE;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC,SAAS,CAAC,CAAA;IAErD,QAAQ,CAAC,GAAG,CACX,WAAW,EAAE,2BAA2B,EACxC,IAAI,EAAE,aAAa,GACjB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAE7B,SAAS,QAAO,wBAAwB,CAgBvC;IAED;;;OAGG;IACH,IAAI,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,EAMtC;IAED,IAAI,QAAQ,IAAI,OAAO,GAAG,SAAS,CAElC;CACD"}
@@ -1,15 +1,64 @@
1
- import { StringSelectMenu } from "./StringSelectMenu.js";
2
- export class ModalStringSelectMenu extends StringSelectMenu {
3
- required = false;
4
- disabled = false;
5
- serializeExtra() {
6
- return {
7
- required: this.required
1
+ import { ComponentType } from "discord-api-types/v10";
2
+ import { BaseModalComponent } from "../../abstracts/BaseModalComponent.js";
3
+ import { parseCustomId } from "../../utils/customIdParser.js";
4
+ export class ModalStringSelectMenu extends BaseModalComponent {
5
+ type = ComponentType.StringSelect;
6
+ isV2 = false;
7
+ /**
8
+ * This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
9
+ * By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
10
+ * It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
11
+ *
12
+ * You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
13
+ * - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
14
+ * - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
15
+ *
16
+ * @param id - The custom ID of the component as received from an interaction event
17
+ * @returns The base key and the data object
18
+ */
19
+ customIdParser = parseCustomId;
20
+ /**
21
+ * The minimum number of values that must be selected
22
+ */
23
+ minValues;
24
+ /**
25
+ * The maximum number of values that can be selected
26
+ */
27
+ maxValues;
28
+ /**
29
+ * Whether this component is required (defaults to true in modals)
30
+ */
31
+ required;
32
+ /**
33
+ * The placeholder text for the select menu
34
+ */
35
+ placeholder;
36
+ serialize = () => {
37
+ const data = {
38
+ type: this.type,
39
+ custom_id: this.customId,
40
+ placeholder: this.placeholder,
41
+ min_values: this.minValues,
42
+ max_values: this.maxValues,
43
+ options: this.options
8
44
  };
45
+ // In modals, required defaults to true
46
+ if (this.required !== undefined) {
47
+ data.required = this.required;
48
+ }
49
+ return data;
50
+ };
51
+ /**
52
+ * The disabled field is not allowed on modal select components
53
+ * @throws Error when trying to set disabled to true
54
+ */
55
+ set disabled(value) {
56
+ if (value === true) {
57
+ throw new Error("The 'disabled' field is not allowed on modal select components");
58
+ }
9
59
  }
10
- // Discord will give an error if this key is in the payload
11
- get serializeDeleteKeys() {
12
- return ["disabled"];
60
+ get disabled() {
61
+ return undefined;
13
62
  }
14
63
  }
15
64
  //# sourceMappingURL=ModalStringSelectMenu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ModalStringSelectMenu.js","sourceRoot":"","sources":["../../../../src/classes/components/ModalStringSelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAExD,MAAM,OAAgB,qBAAsB,SAAQ,gBAAgB;IACnE,QAAQ,GAAG,KAAK,CAAA;IACP,QAAQ,GAAU,KAAK,CAAA;IAEhC,cAAc;QACb,OAAO;YACN,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAA;IACF,CAAC;IAED,2DAA2D;IAC3D,IAAc,mBAAmB;QAChC,OAAO,CAAC,UAAU,CAAC,CAAA;IACpB,CAAC;CACD"}
1
+ {"version":3,"file":"ModalStringSelectMenu.js","sourceRoot":"","sources":["../../../../src/classes/components/ModalStringSelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAI1E,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAE7D,MAAM,OAAgB,qBAAsB,SAAQ,kBAAkB;IAC5D,IAAI,GAAG,aAAa,CAAC,YAAqB,CAAA;IAC1C,IAAI,GAAG,KAAK,CAAA;IAUrB;;;;;;;;;;;OAWG;IACH,cAAc,GAA0C,aAAa,CAAA;IAErE;;OAEG;IACH,SAAS,CAAS;IAElB;;OAEG;IACH,SAAS,CAAS;IAElB;;OAEG;IACH,QAAQ,CAAU;IAElB;;OAEG;IACH,WAAW,CAAS;IAYpB,SAAS,GAAG,GAA6B,EAAE;QAC1C,MAAM,IAAI,GAA6B;YACtC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,QAAQ;YACxB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,OAAO,EAAE,IAAI,CAAC,OAAO;SACrB,CAAA;QAED,uCAAuC;QACvC,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC9B,CAAC;QAED,OAAO,IAAI,CAAA;IACZ,CAAC,CAAA;IAED;;;OAGG;IACH,IAAI,QAAQ,CAAC,KAA0B;QACtC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CACd,gEAAgE,CAChE,CAAA;QACF,CAAC;IACF,CAAC;IAED,IAAI,QAAQ;QACX,OAAO,SAAS,CAAA;IACjB,CAAC;CACD"}
@@ -0,0 +1,58 @@
1
+ import { type APIUserSelectComponent, ComponentType } from "discord-api-types/v10";
2
+ import { BaseModalComponent } from "../../abstracts/BaseModalComponent.js";
3
+ import type { UserSelectMenuInteraction } from "../../internals/UserSelectMenuInteraction.js";
4
+ import type { ComponentParserResult } from "../../types/index.js";
5
+ import type { ComponentData } from "../../types/index.js";
6
+ export declare abstract class ModalUserSelectMenu extends BaseModalComponent {
7
+ readonly type: ComponentType.UserSelect;
8
+ readonly isV2 = false;
9
+ /**
10
+ * The custom ID of the component.
11
+ * If you want to provide a custom ID with additional data, you should either follow the default parser's format or implement your own custom parser.
12
+ *
13
+ * @see {@link customIdParser}
14
+ */
15
+ abstract customId: string;
16
+ /**
17
+ * This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
18
+ * By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
19
+ * It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
20
+ *
21
+ * You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
22
+ * - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
23
+ * - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
24
+ *
25
+ * @param id - The custom ID of the component as received from an interaction event
26
+ * @returns The base key and the data object
27
+ */
28
+ customIdParser: (id: string) => ComponentParserResult;
29
+ /**
30
+ * The minimum number of values that must be selected
31
+ */
32
+ minValues?: number;
33
+ /**
34
+ * The maximum number of values that can be selected
35
+ */
36
+ maxValues?: number;
37
+ /**
38
+ * Whether this component is required (defaults to true in modals)
39
+ */
40
+ required?: boolean;
41
+ /**
42
+ * The placeholder text for the select menu
43
+ */
44
+ placeholder?: string;
45
+ /**
46
+ * Default values for the select menu
47
+ */
48
+ defaultValues?: APIUserSelectComponent["default_values"];
49
+ abstract run(interaction: UserSelectMenuInteraction, data: ComponentData): unknown | Promise<unknown>;
50
+ serialize: () => APIUserSelectComponent;
51
+ /**
52
+ * The disabled field is not allowed on modal select components
53
+ * @throws Error when trying to set disabled to true
54
+ */
55
+ set disabled(value: boolean | undefined);
56
+ get disabled(): boolean | undefined;
57
+ }
58
+ //# sourceMappingURL=ModalUserSelectMenu.d.ts.map
@@ -0,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
+ import { ComponentType } from "discord-api-types/v10";
2
+ import { BaseModalComponent } from "../../abstracts/BaseModalComponent.js";
3
+ import { parseCustomId } from "../../utils/customIdParser.js";
4
+ export class ModalUserSelectMenu extends BaseModalComponent {
5
+ type = ComponentType.UserSelect;
6
+ isV2 = false;
7
+ /**
8
+ * This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
9
+ * By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
10
+ * It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
11
+ *
12
+ * You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
13
+ * - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
14
+ * - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
15
+ *
16
+ * @param id - The custom ID of the component as received from an interaction event
17
+ * @returns The base key and the data object
18
+ */
19
+ customIdParser = parseCustomId;
20
+ /**
21
+ * The minimum number of values that must be selected
22
+ */
23
+ minValues;
24
+ /**
25
+ * The maximum number of values that can be selected
26
+ */
27
+ maxValues;
28
+ /**
29
+ * Whether this component is required (defaults to true in modals)
30
+ */
31
+ required;
32
+ /**
33
+ * The placeholder text for the select menu
34
+ */
35
+ placeholder;
36
+ /**
37
+ * Default values for the select menu
38
+ */
39
+ defaultValues;
40
+ serialize = () => {
41
+ const data = {
42
+ type: this.type,
43
+ custom_id: this.customId,
44
+ placeholder: this.placeholder,
45
+ min_values: this.minValues,
46
+ max_values: this.maxValues,
47
+ default_values: this.defaultValues
48
+ };
49
+ // In modals, required defaults to true
50
+ if (this.required !== undefined) {
51
+ data.required = this.required;
52
+ }
53
+ return data;
54
+ };
55
+ /**
56
+ * The disabled field is not allowed on modal select components
57
+ * @throws Error when trying to set disabled to true
58
+ */
59
+ set disabled(value) {
60
+ if (value === true) {
61
+ throw new Error("The 'disabled' field is not allowed on modal select components");
62
+ }
63
+ }
64
+ get disabled() {
65
+ return undefined;
66
+ }
67
+ }
68
+ //# sourceMappingURL=ModalUserSelectMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModalUserSelectMenu.js","sourceRoot":"","sources":["../../../../src/classes/components/ModalUserSelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAI1E,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAE7D,MAAM,OAAgB,mBAAoB,SAAQ,kBAAkB;IAC1D,IAAI,GAAG,aAAa,CAAC,UAAmB,CAAA;IACxC,IAAI,GAAG,KAAK,CAAA;IAUrB;;;;;;;;;;;OAWG;IACH,cAAc,GAA0C,aAAa,CAAA;IAErE;;OAEG;IACH,SAAS,CAAS;IAElB;;OAEG;IACH,SAAS,CAAS;IAElB;;OAEG;IACH,QAAQ,CAAU;IAElB;;OAEG;IACH,WAAW,CAAS;IAEpB;;OAEG;IACH,aAAa,CAA2C;IAOxD,SAAS,GAAG,GAA2B,EAAE;QACxC,MAAM,IAAI,GAA2B;YACpC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,QAAQ;YACxB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,cAAc,EAAE,IAAI,CAAC,aAAa;SAClC,CAAA;QAED,uCAAuC;QACvC,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC9B,CAAC;QAED,OAAO,IAAI,CAAA;IACZ,CAAC,CAAA;IAED;;;OAGG;IACH,IAAI,QAAQ,CAAC,KAA0B;QACtC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CACd,gEAAgE,CAChE,CAAA;QACF,CAAC;IACF,CAAC;IAED,IAAI,QAAQ;QACX,OAAO,SAAS,CAAA;IACjB,CAAC;CACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"ComponentHandler.d.ts","sourceRoot":"","sources":["../../../src/internals/ComponentHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,8BAA8B,EACnC,KAAK,kCAAkC,EAKvC,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,iDAAiD,CAAA;AActG,qBAAa,gBAAiB,SAAQ,IAAI;IACzC,UAAU,EAAE,+BAA+B,EAAE,CAAK;IAElD,gBAAgB,EAAE,GAAG,CACpB,GAAG,MAAM,IAAI,MAAM,EAAE,EACrB;QACC,OAAO,EAAE,CAAC,IAAI,EAAE,kCAAkC,KAAK,IAAI,CAAA;KAC3D,CACD,CAAY;IACb;;;OAGG;IACH,iBAAiB,CAAC,SAAS,EAAE,+BAA+B;IAK5D;;;OAGG;IACG,iBAAiB,CAAC,IAAI,EAAE,8BAA8B;CAmM5D"}
1
+ {"version":3,"file":"ComponentHandler.d.ts","sourceRoot":"","sources":["../../../src/internals/ComponentHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,8BAA8B,EACnC,KAAK,kCAAkC,EAKvC,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,iDAAiD,CAAA;AActG,qBAAa,gBAAiB,SAAQ,IAAI;IACzC,UAAU,EAAE,+BAA+B,EAAE,CAAK;IAElD,gBAAgB,EAAE,GAAG,CACpB,GAAG,MAAM,IAAI,MAAM,EAAE,EACrB;QACC,OAAO,EAAE,CAAC,IAAI,EAAE,kCAAkC,KAAK,IAAI,CAAA;KAC3D,CACD,CAAY;IACb;;;OAGG;IACH,iBAAiB,CAAC,SAAS,EAAE,+BAA+B;IAK5D;;;OAGG;IACG,iBAAiB,CAAC,IAAI,EAAE,8BAA8B;CA2M5D"}
@@ -29,7 +29,7 @@ export class ComponentHandler extends Base {
29
29
  * @internal
30
30
  */
31
31
  async handleInteraction(data) {
32
- const component = this.components.find((x) => {
32
+ let component = this.components.find((x) => {
33
33
  const componentKey = x.customIdParser(x.customId).key;
34
34
  const interactionKey = x.customIdParser(data.data.custom_id).key;
35
35
  return (componentKey === interactionKey && x.type === data.data.component_type);
@@ -48,11 +48,15 @@ export class ComponentHandler extends Base {
48
48
  .catch(() => {
49
49
  console.warn(`Failed to acknowledge one-off component interaction for message ${data.message.id}`);
50
50
  });
51
+ return;
51
52
  }
52
- else {
53
+ component = this.components.find((x) => {
54
+ const componentKey = x.customIdParser(x.customId).key;
55
+ return componentKey === "*" && x.type === data.data.component_type;
56
+ });
57
+ if (!component) {
53
58
  throw new Error(`Unknown component with type ${data.data.component_type} and custom ID ${data.data.custom_id} was received, did you forget to register the component? See https://carbon.buape.com/concepts/component-registration for more information.`);
54
59
  }
55
- return;
56
60
  }
57
61
  const parsed = component.customIdParser(data.data.custom_id);
58
62
  if (component instanceof Button) {
@@ -1 +1 @@
1
- {"version":3,"file":"ComponentHandler.js","sourceRoot":"","sources":["../../../src/internals/ComponentHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,uBAAuB,EAEvB,MAAM,EACN,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAA;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAA;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAA;AACtF,OAAO,EAAE,cAAc,EAAE,M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D"}
@@ -0,0 +1,19 @@
1
+ import { Base } from "../abstracts/Base.js";
2
+ import { ApplicationEmoji } from "../structures/Emoji.js";
3
+ /**
4
+ * This class is specifically used for application emojis that you manage from the Discord Developer Portal
5
+ */
6
+ export declare class EmojiHandler extends Base {
7
+ list(): Promise<ApplicationEmoji[]>;
8
+ get(id: string): Promise<ApplicationEmoji>;
9
+ getByName(name: string): Promise<ApplicationEmoji | undefined>;
10
+ /**
11
+ * Upload a new emoji to the application
12
+ * @param name The name of the emoji
13
+ * @param image The image of the emoji in base64 format
14
+ * @returns The created ApplicationEmoji
15
+ */
16
+ create(name: string, image: string): Promise<ApplicationEmoji>;
17
+ delete(id: string): Promise<void>;
18
+ }
19
+ //# sourceMappingURL=EmojiHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmojiHandler.d.ts","sourceRoot":"","sources":["../../../src/internals/EmojiHandler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAEzD;;GAEG;AACH,qBAAa,YAAa,SAAQ,IAAI;IACxB,IAAI;IAWJ,GAAG,CAAC,EAAE,EAAE,MAAM;IAWd,SAAS,CAAC,IAAI,EAAE,MAAM;IAKnC;;;;;OAKG;IACU,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAYlC,MAAM,CAAC,EAAE,EAAE,MAAM;CAK9B"}
@@ -0,0 +1,35 @@
1
+ import { Routes } from "discord-api-types/v10";
2
+ import { Base } from "../abstracts/Base.js";
3
+ import { ApplicationEmoji } from "../structures/Emoji.js";
4
+ /**
5
+ * This class is specifically used for application emojis that you manage from the Discord Developer Portal
6
+ */
7
+ export class EmojiHandler extends Base {
8
+ async list() {
9
+ const emojis = (await this.client.rest.get(Routes.applicationEmojis(this.client.options.clientId)));
10
+ console.log(emojis);
11
+ return emojis.items.map((emoji) => new ApplicationEmoji(this.client, emoji, this.client.options.clientId));
12
+ }
13
+ async get(id) {
14
+ const emoji = (await this.client.rest.get(Routes.applicationEmoji(this.client.options.clientId, id)));
15
+ return new ApplicationEmoji(this.client, emoji, this.client.options.clientId);
16
+ }
17
+ async getByName(name) {
18
+ const emojis = await this.list();
19
+ return emojis.find((emoji) => emoji.name === name);
20
+ }
21
+ /**
22
+ * Upload a new emoji to the application
23
+ * @param name The name of the emoji
24
+ * @param image The image of the emoji in base64 format
25
+ * @returns The created ApplicationEmoji
26
+ */
27
+ async create(name, image) {
28
+ const emoji = (await this.client.rest.post(Routes.applicationEmojis(this.client.options.clientId), { body: { name, image } }));
29
+ return new ApplicationEmoji(this.client, emoji, this.client.options.clientId);
30
+ }
31
+ async delete(id) {
32
+ await this.client.rest.delete(Routes.applicationEmoji(this.client.options.clientId, id));
33
+ }
34
+ }
35
+ //# sourceMappingURL=EmojiHandler.js.map