Discord bot to open dong files

scafold open and create

add base content for create

+90 -2
+73
src/commands/dong/create.ts
···
··· 1 + import { 2 + Attachment, 3 + ChatInputCommandInteraction, 4 + SlashCommandBuilder, 5 + } from "discord.js"; 6 + import type { customClient } from "../.."; 7 + 8 + const download = async (file: Attachment): Promise<File> => 9 + new File( 10 + [ 11 + await fetch(file.url).then((res) => { 12 + return res.blob(); 13 + }), 14 + ], 15 + file.name, 16 + { 17 + type: file.contentType ?? "application/octet-stream", 18 + } 19 + ); 20 + 21 + export const data = new SlashCommandBuilder() 22 + .setName("create") 23 + .setDescription("Create a dong file!") 24 + .addAttachmentOption((opt) => 25 + opt 26 + .setName("image") 27 + .setDescription("The image of the dong file") 28 + .setRequired(true) 29 + ) 30 + .addAttachmentOption((opt) => 31 + opt 32 + .setName("audio") 33 + .setDescription("The audio of the dong file") 34 + .setRequired(true) 35 + ) 36 + .addStringOption((opt) => 37 + opt 38 + .setName("name") 39 + .setDescription("Filename of the dong file") 40 + .setRequired(true) 41 + ); 42 + export const execute = async ( 43 + interaction: ChatInputCommandInteraction & { client: customClient } 44 + ) => { 45 + const filename = interaction.options.getString("name", true) + ".dong"; 46 + const image = interaction.options.getAttachment("image", true); 47 + const audio = interaction.options.getAttachment("audio", true); 48 + 49 + if (!image.contentType?.startsWith("image/")) { 50 + await interaction.reply("Image is not a valid image!"); 51 + return; 52 + } 53 + if (!audio.contentType?.startsWith("audio/")) { 54 + await interaction.reply("Audio is not a valid audio!"); 55 + return; 56 + } 57 + 58 + await interaction.deferReply(); 59 + 60 + let downloaded = { 61 + image: await download(image), 62 + audio: await download(audio), 63 + }; 64 + console.log(downloaded); 65 + await interaction.editReply(`Not implemented! Debug: 66 + \`\`\` 67 + filename: ${filename} 68 + 69 + image: ${image.contentType} | ${image.url} 70 + 71 + audio: ${audio.contentType} | ${audio.url} 72 + \`\`\``); 73 + };
+17
src/commands/dong/open.ts
···
··· 1 + import { ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js"; 2 + import type { customClient } from "../.."; 3 + 4 + export const data = new SlashCommandBuilder() 5 + .setName("open") 6 + .setDescription("Open a dong file!") 7 + .addAttachmentOption((opt) => 8 + opt 9 + .setName("dong") 10 + .setDescription("The dong file") 11 + .setRequired(true) 12 + ); 13 + export const execute = async ( 14 + interaction: ChatInputCommandInteraction & { client: customClient } 15 + ) => { 16 + await interaction.reply("Not Implemented!"); 17 + };
-2
src/commands/util/ping.ts
··· 1 import { 2 ChatInputCommandInteraction, 3 - Client, 4 - CommandInteraction, 5 SlashCommandBuilder, 6 } from "discord.js"; 7 import type { customClient } from "../..";
··· 1 import { 2 ChatInputCommandInteraction, 3 SlashCommandBuilder, 4 } from "discord.js"; 5 import type { customClient } from "../..";