Make it a link button

This commit is contained in:
PandaNinjas 2023-01-16 19:03:28 -08:00
parent d2119299fa
commit 90fbd3f717
No known key found for this signature in database
GPG key ID: 0BD7553044D47763

View file

@ -1,4 +1,12 @@
import { Colors, EmbedBuilder, type Message, ThreadChannel } from "discord.js"; import {
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
Colors,
EmbedBuilder,
type Message,
ThreadChannel,
} from "discord.js";
function findFirstImage(message: Message): string | undefined { function findFirstImage(message: Message): string | undefined {
const result = message.attachments.find((attach) => { const result = message.attachments.find((attach) => {
@ -58,11 +66,13 @@ export async function expandDiscordLink(message: Message): Promise<void> {
builder.setImage(firstImage); builder.setImage(firstImage);
} }
} }
builder.addFields({ const row = new ActionRowBuilder().addComponents(
name: "Source", new ButtonBuilder()
value: `[Jump to original message](${messageToShow.url})`, .setLabel("Jump to original message")
}); .setStyle(ButtonStyle.Link)
message.channel.send({ embeds: [builder] }); .setURL(messageToShow.url)
);
message.channel.send({ embeds: [builder], components: [row] });
} catch (e) { } catch (e) {
console.error(e); console.error(e);
continue; continue;