mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-25 18:25:03 +00:00
more fixes
Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
parent
343a91e3c3
commit
c33a216857
23 changed files with 81 additions and 58 deletions
|
@ -1,23 +1,35 @@
|
|||
import { MessageActionRow, MessageButton, MessageComponentInteraction, MessageOptions, TextChannel } from "discord.js";
|
||||
import {
|
||||
ActionRow,
|
||||
ActionRowBuilder,
|
||||
ButtonBuilder,
|
||||
ButtonComponent,
|
||||
ButtonStyle,
|
||||
Message,
|
||||
MessageActionRowComponentBuilder,
|
||||
MessageComponentInteraction,
|
||||
MessageCreateOptions,
|
||||
MessagePayloadOption,
|
||||
TextChannel,
|
||||
} from "discord.js";
|
||||
import { noop } from "knub/dist/utils";
|
||||
import moment from "moment";
|
||||
import uuidv4 from "uuid/v4";
|
||||
|
||||
export async function waitForButtonConfirm(
|
||||
channel: TextChannel,
|
||||
toPost: MessageOptions,
|
||||
toPost: MessageCreateOptions,
|
||||
options?: WaitForOptions,
|
||||
): Promise<boolean> {
|
||||
return new Promise(async (resolve) => {
|
||||
const idMod = `${channel.guild.id}-${moment.utc().valueOf()}`;
|
||||
const row = new MessageActionRow().addComponents([
|
||||
new MessageButton()
|
||||
.setStyle("SUCCESS")
|
||||
const row = new ActionRowBuilder<MessageActionRowComponentBuilder>().addComponents([
|
||||
new ButtonBuilder()
|
||||
.setStyle(ButtonStyle.Success)
|
||||
.setLabel(options?.confirmText || "Confirm")
|
||||
.setCustomId(`confirmButton:${idMod}:${uuidv4()}`),
|
||||
|
||||
new MessageButton()
|
||||
.setStyle("DANGER")
|
||||
new ButtonBuilder()
|
||||
.setStyle(ButtonStyle.Danger)
|
||||
.setLabel(options?.cancelText || "Cancel")
|
||||
.setCustomId(`cancelButton:${idMod}:${uuidv4()}`),
|
||||
]);
|
||||
|
@ -41,7 +53,7 @@ export async function waitForButtonConfirm(
|
|||
}
|
||||
});
|
||||
collector.on("end", () => {
|
||||
if (!message.deleted) message.delete().catch(noop);
|
||||
if (message.deletable) message.delete().catch(noop);
|
||||
resolve(false);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue