mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 14:11:50 +00:00
Make sure waitForButtonConfirm() component custom IDs are unique
This commit is contained in:
parent
a179119f2e
commit
d6c4868ccf
1 changed files with 5 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
||||||
import { MessageActionRow, MessageButton, MessageComponentInteraction, MessageOptions, TextChannel } from "discord.js";
|
import { MessageActionRow, MessageButton, MessageComponentInteraction, MessageOptions, TextChannel } from "discord.js";
|
||||||
import { noop } from "knub/dist/utils";
|
import { noop } from "knub/dist/utils";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
|
import uuidv4 from "uuid/v4";
|
||||||
|
|
||||||
export async function waitForButtonConfirm(
|
export async function waitForButtonConfirm(
|
||||||
channel: TextChannel,
|
channel: TextChannel,
|
||||||
|
@ -13,12 +14,12 @@ export async function waitForButtonConfirm(
|
||||||
new MessageButton()
|
new MessageButton()
|
||||||
.setStyle("SUCCESS")
|
.setStyle("SUCCESS")
|
||||||
.setLabel(options?.confirmText || "Confirm")
|
.setLabel(options?.confirmText || "Confirm")
|
||||||
.setCustomId(`confirmButton:${idMod}`),
|
.setCustomId(`confirmButton:${idMod}:${uuidv4()}`),
|
||||||
|
|
||||||
new MessageButton()
|
new MessageButton()
|
||||||
.setStyle("DANGER")
|
.setStyle("DANGER")
|
||||||
.setLabel(options?.cancelText || "Cancel")
|
.setLabel(options?.cancelText || "Cancel")
|
||||||
.setCustomId(`cancelButton:${idMod}`),
|
.setCustomId(`cancelButton:${idMod}:${uuidv4()}`),
|
||||||
]);
|
]);
|
||||||
const message = await channel.send({ ...toPost, components: [row] });
|
const message = await channel.send({ ...toPost, components: [row] });
|
||||||
|
|
||||||
|
@ -28,10 +29,10 @@ export async function waitForButtonConfirm(
|
||||||
if (options?.restrictToId && options.restrictToId !== interaction.user.id) {
|
if (options?.restrictToId && options.restrictToId !== interaction.user.id) {
|
||||||
interaction.reply({ content: `You are not permitted to use these buttons.`, ephemeral: true });
|
interaction.reply({ content: `You are not permitted to use these buttons.`, ephemeral: true });
|
||||||
} else {
|
} else {
|
||||||
if (interaction.customId === `confirmButton:${idMod}`) {
|
if (interaction.customId.startsWith(`confirmButton:${idMod}:`)) {
|
||||||
message.delete();
|
message.delete();
|
||||||
resolve(true);
|
resolve(true);
|
||||||
} else if (interaction.customId === `cancelButton:${idMod}`) {
|
} else if (interaction.customId.startsWith(`cancelButton:${idMod}:`)) {
|
||||||
message.delete();
|
message.delete();
|
||||||
resolve(false);
|
resolve(false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue