import { AttachmentBuilder, ChatInputCommandInteraction, SlashCommandBuilder, } from "discord.js"; import type { customClient } from "../../index.ts"; import { createDong } from "../../lib/dong-io.ts"; import { download } from "../../lib/download.ts"; import { Buffer } from "node:buffer"; export const data = new SlashCommandBuilder() .setName("create") .setDescription("Create a dong file!") .addAttachmentOption((opt) => opt .setName("image") .setDescription("The image of the dong file") .setRequired(true) ) .addAttachmentOption((opt) => opt .setName("audio") .setDescription("The audio of the dong file") .setRequired(true) ) .addStringOption((opt) => opt .setName("name") .setDescription("Filename of the dong file") .setRequired(true) ); export const execute = async ( interaction: ChatInputCommandInteraction & { client: customClient } ) => { const filename = interaction.options.getString("name", true) + ".dong"; const image = interaction.options.getAttachment("image", true); const audio = interaction.options.getAttachment("audio", true); if (!image.contentType?.startsWith("image/")) { await interaction.reply("Image is not a valid image!"); return; } if (!audio.contentType?.startsWith("audio/")) { await interaction.reply("Audio is not a valid audio!"); return; } await interaction.deferReply(); const downloaded = { image: await download(image), audio: await download(audio), }; const dong = new File( [await createDong(downloaded.image, downloaded.audio)], filename, { type: "application/prs.vielle.dong" } ); await interaction.editReply({ files: [ new AttachmentBuilder(Buffer.from(await dong.arrayBuffer()), { name: dong.name, }), ], }); };