commandkit 0.1.6-dev.20231112181436 → 0.1.6-dev.20231113071041
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/bin/build.mjs +1 -1
- package/dist/index.d.mts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +6 -6
- package/dist/index.mjs +11 -7
- package/package.json +1 -1
package/bin/build.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
3
|
import { build } from 'tsup';
|
|
4
|
-
import ora from 'ora';
|
|
5
4
|
import { Colors, erase, findCommandKitJSON, panic, write } from './common.mjs';
|
|
5
|
+
import ora from 'ora';
|
|
6
6
|
|
|
7
7
|
export async function bootstrapProductionBuild(config) {
|
|
8
8
|
const { minify = false, outDir = 'dist', main, src } = findCommandKitJSON(config);
|
package/dist/index.d.mts
CHANGED
|
@@ -156,6 +156,10 @@ type CommandKitButtonBuilderInteractionCollectorDispatchContextData = {
|
|
|
156
156
|
* The message to listen for button interactions on.
|
|
157
157
|
*/
|
|
158
158
|
message: Message;
|
|
159
|
+
/**
|
|
160
|
+
* The duration (in ms) that the collector should run for.
|
|
161
|
+
*/
|
|
162
|
+
time?: number;
|
|
159
163
|
/**
|
|
160
164
|
* If the collector should automatically reset the timer when a button is clicked.
|
|
161
165
|
*/
|
|
@@ -176,13 +180,15 @@ declare class ButtonKit extends ButtonBuilder {
|
|
|
176
180
|
* .setStyle(ButtonStyle.Primary)
|
|
177
181
|
* .setCustomId('click_me');
|
|
178
182
|
*
|
|
179
|
-
* const
|
|
183
|
+
* const row = new ActionRowBuilder().addComponents(button);
|
|
184
|
+
*
|
|
185
|
+
* const message = await channel.send({ content: 'Click the button', components: [row] });
|
|
180
186
|
*
|
|
181
187
|
* button.onClick(async (interaction) => {
|
|
182
188
|
* await interaction.reply('You clicked me!');
|
|
183
189
|
* }, { message });
|
|
184
190
|
*
|
|
185
|
-
* //
|
|
191
|
+
* // Remove onClick handler and destroy the interaction collector
|
|
186
192
|
* button.onClick(null);
|
|
187
193
|
* ```
|
|
188
194
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -156,6 +156,10 @@ type CommandKitButtonBuilderInteractionCollectorDispatchContextData = {
|
|
|
156
156
|
* The message to listen for button interactions on.
|
|
157
157
|
*/
|
|
158
158
|
message: Message;
|
|
159
|
+
/**
|
|
160
|
+
* The duration (in ms) that the collector should run for.
|
|
161
|
+
*/
|
|
162
|
+
time?: number;
|
|
159
163
|
/**
|
|
160
164
|
* If the collector should automatically reset the timer when a button is clicked.
|
|
161
165
|
*/
|
|
@@ -176,13 +180,15 @@ declare class ButtonKit extends ButtonBuilder {
|
|
|
176
180
|
* .setStyle(ButtonStyle.Primary)
|
|
177
181
|
* .setCustomId('click_me');
|
|
178
182
|
*
|
|
179
|
-
* const
|
|
183
|
+
* const row = new ActionRowBuilder().addComponents(button);
|
|
184
|
+
*
|
|
185
|
+
* const message = await channel.send({ content: 'Click the button', components: [row] });
|
|
180
186
|
*
|
|
181
187
|
* button.onClick(async (interaction) => {
|
|
182
188
|
* await interaction.reply('You clicked me!');
|
|
183
189
|
* }, { message });
|
|
184
190
|
*
|
|
185
|
-
* //
|
|
191
|
+
* // Remove onClick handler and destroy the interaction collector
|
|
186
192
|
* button.onClick(null);
|
|
187
193
|
* ```
|
|
188
194
|
*/
|
package/dist/index.js
CHANGED
|
@@ -907,7 +907,7 @@ var CommandKit = class {
|
|
|
907
907
|
}
|
|
908
908
|
};
|
|
909
909
|
|
|
910
|
-
// src/components/
|
|
910
|
+
// src/components/ButtonKit.ts
|
|
911
911
|
var import_discord2 = require("discord.js");
|
|
912
912
|
var ButtonKit = class extends import_discord2.ButtonBuilder {
|
|
913
913
|
#onClickHandler = null;
|
|
@@ -915,7 +915,7 @@ var ButtonKit = class extends import_discord2.ButtonBuilder {
|
|
|
915
915
|
#collector = null;
|
|
916
916
|
onClick(handler, data) {
|
|
917
917
|
if (this.data.style === import_discord2.ButtonStyle.Link) {
|
|
918
|
-
throw new TypeError('Cannot setup "onClick" handler
|
|
918
|
+
throw new TypeError('Cannot setup "onClick" handler on link buttons.');
|
|
919
919
|
}
|
|
920
920
|
this.#destroyCollector();
|
|
921
921
|
this.#onClickHandler = handler;
|
|
@@ -927,14 +927,14 @@ var ButtonKit = class extends import_discord2.ButtonBuilder {
|
|
|
927
927
|
#setupInteractionCollector() {
|
|
928
928
|
if (!this.#contextData || !this.#onClickHandler)
|
|
929
929
|
return;
|
|
930
|
-
const message = this.#contextData
|
|
930
|
+
const message = this.#contextData.message;
|
|
931
931
|
if (!message) {
|
|
932
932
|
throw new TypeError(
|
|
933
|
-
'Cannot setup "onClick" handler without a message in the context data'
|
|
933
|
+
'Cannot setup "onClick" handler without a message in the context data.'
|
|
934
934
|
);
|
|
935
935
|
}
|
|
936
936
|
if ("customId" in this.data && !this.data.customId) {
|
|
937
|
-
throw new TypeError('Cannot setup "onClick" handler without a custom id');
|
|
937
|
+
throw new TypeError('Cannot setup "onClick" handler on a button without a custom id.');
|
|
938
938
|
}
|
|
939
939
|
const data = {
|
|
940
940
|
time: 864e5,
|
|
@@ -954,7 +954,7 @@ var ButtonKit = class extends import_discord2.ButtonBuilder {
|
|
|
954
954
|
return collector.stop("destroyed");
|
|
955
955
|
}
|
|
956
956
|
if (data.autoReset) {
|
|
957
|
-
this.#collector
|
|
957
|
+
this.#collector.resetTimer();
|
|
958
958
|
}
|
|
959
959
|
return handler(interaction);
|
|
960
960
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -874,15 +874,19 @@ var CommandKit = class {
|
|
|
874
874
|
}
|
|
875
875
|
};
|
|
876
876
|
|
|
877
|
-
// src/components/
|
|
878
|
-
import {
|
|
877
|
+
// src/components/ButtonKit.ts
|
|
878
|
+
import {
|
|
879
|
+
ButtonStyle,
|
|
880
|
+
ButtonBuilder,
|
|
881
|
+
ComponentType
|
|
882
|
+
} from "discord.js";
|
|
879
883
|
var ButtonKit = class extends ButtonBuilder {
|
|
880
884
|
#onClickHandler = null;
|
|
881
885
|
#contextData = null;
|
|
882
886
|
#collector = null;
|
|
883
887
|
onClick(handler, data) {
|
|
884
888
|
if (this.data.style === ButtonStyle.Link) {
|
|
885
|
-
throw new TypeError('Cannot setup "onClick" handler
|
|
889
|
+
throw new TypeError('Cannot setup "onClick" handler on link buttons.');
|
|
886
890
|
}
|
|
887
891
|
this.#destroyCollector();
|
|
888
892
|
this.#onClickHandler = handler;
|
|
@@ -894,14 +898,14 @@ var ButtonKit = class extends ButtonBuilder {
|
|
|
894
898
|
#setupInteractionCollector() {
|
|
895
899
|
if (!this.#contextData || !this.#onClickHandler)
|
|
896
900
|
return;
|
|
897
|
-
const message = this.#contextData
|
|
901
|
+
const message = this.#contextData.message;
|
|
898
902
|
if (!message) {
|
|
899
903
|
throw new TypeError(
|
|
900
|
-
'Cannot setup "onClick" handler without a message in the context data'
|
|
904
|
+
'Cannot setup "onClick" handler without a message in the context data.'
|
|
901
905
|
);
|
|
902
906
|
}
|
|
903
907
|
if ("customId" in this.data && !this.data.customId) {
|
|
904
|
-
throw new TypeError('Cannot setup "onClick" handler without a custom id');
|
|
908
|
+
throw new TypeError('Cannot setup "onClick" handler on a button without a custom id.');
|
|
905
909
|
}
|
|
906
910
|
const data = {
|
|
907
911
|
time: 864e5,
|
|
@@ -921,7 +925,7 @@ var ButtonKit = class extends ButtonBuilder {
|
|
|
921
925
|
return collector.stop("destroyed");
|
|
922
926
|
}
|
|
923
927
|
if (data.autoReset) {
|
|
924
|
-
this.#collector
|
|
928
|
+
this.#collector.resetTimer();
|
|
925
929
|
}
|
|
926
930
|
return handler(interaction);
|
|
927
931
|
});
|
package/package.json
CHANGED