3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-27 11:15:02 +00:00

more fixes

Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
metal 2023-03-11 12:12:48 +00:00 committed by GitHub
parent 343a91e3c3
commit c33a216857
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 81 additions and 58 deletions

View file

@ -1,10 +1,10 @@
import { Channel, ThreadChannel } from "discord.js";
import { AnyThreadChannel, Channel, ChannelType } from "discord.js";
import { ChannelTypeStrings } from "src/types";
export function isThreadChannel(channel: Channel): channel is ThreadChannel {
export function isThreadChannel(channel: Channel): channel is AnyThreadChannel {
return (
channel.type === ChannelTypeStrings.NEWS_THREAD ||
channel.type === ChannelTypeStrings.PUBLIC_THREAD ||
channel.type === ChannelTypeStrings.PRIVATE_THREAD
channel.type === ChannelType.PublicThread ||
channel.type === ChannelType.PrivateThread ||
channel.type === ChannelType.AnnouncementThread
);
}

View file

@ -47,7 +47,7 @@ export async function resolveMessageTarget(pluginData: GuildPluginData<any>, val
}
const channel = pluginData.guild.channels.resolve(result.channelId as Snowflake);
if (!channel?.isText()) {
if (!channel?.isTextBased()) {
return null;
}

View file

@ -9,6 +9,7 @@ import {
Snowflake,
StageInstance,
Sticker,
StickerFormatType,
ThreadChannel,
User,
} from "discord.js";
@ -239,7 +240,7 @@ export function userToTemplateSafeUser(user: User | UnknownUser): TemplateSafeUs
discriminator: user.discriminator,
mention: `<@${user.id}>`,
tag: user.tag,
avatarURL: user.displayAvatarURL?.({ dynamic: true }),
avatarURL: user.displayAvatarURL?.(),
bot: user.bot,
createdAt: user.createdTimestamp,
});
@ -305,9 +306,9 @@ export function stickerToTemplateSafeSticker(sticker: Sticker): TemplateSafeStic
packId: sticker.packId ?? undefined,
name: sticker.name,
description: sticker.description ?? "",
tags: sticker.tags?.join(", ") ?? "",
tags: sticker.tags ?? "",
format: sticker.format,
animated: sticker.format === "PNG" ? false : true,
animated: sticker.format === StickerFormatType.PNG ? false : true,
url: sticker.url,
});
}

View file

@ -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);
});
});