mirror of
https://github.com/artiemis/artemis.js.git
synced 2026-02-14 10:21:54 +00:00
49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
import {
|
|
ActionRowBuilder,
|
|
ButtonBuilder,
|
|
ButtonStyle,
|
|
ChatInputCommandInteraction,
|
|
ComponentType,
|
|
} from "discord.js";
|
|
|
|
export async function confirmPrompt(
|
|
interaction: ChatInputCommandInteraction,
|
|
message: string
|
|
) {
|
|
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(
|
|
new ButtonBuilder()
|
|
.setCustomId("confirm")
|
|
.setLabel("Confirm")
|
|
.setStyle(ButtonStyle.Success),
|
|
new ButtonBuilder()
|
|
.setCustomId("cancel")
|
|
.setLabel("Cancel")
|
|
.setStyle(ButtonStyle.Danger)
|
|
);
|
|
|
|
const msg = (
|
|
await interaction.reply({
|
|
content: message,
|
|
components: [row],
|
|
withResponse: true,
|
|
})
|
|
).resource!.message!;
|
|
|
|
const confirmation = await msg
|
|
.awaitMessageComponent({
|
|
componentType: ComponentType.Button,
|
|
time: 60000,
|
|
filter: (i) => i.user.id === interaction.user.id,
|
|
dispose: true,
|
|
})
|
|
.catch(() => {
|
|
interaction.editReply({
|
|
content: "You took too long to respond.",
|
|
components: [],
|
|
});
|
|
});
|
|
|
|
interaction.deleteReply();
|
|
return confirmation?.customId === "confirm";
|
|
}
|