Fazer download em txt, pdf ou txt
Fazer download em txt, pdf ou txt
Você está na página 1de 2

/*Comando para enviar fotos aleatorias de Gatos e Cachorros, fiz só por fazer

Packages: discord.js ( Versão 14.11.0 )


axios ( Versão 1.6.7 )

Créditos da API usada no Código: https://api.alexflipnote.dev/*/

const Discord = require("discord.js");


const axios = require("axios");

module.exports = {
name: "foto",
description: "Enviar fotos aleatorias no chat",
options: [{
name: "tipo",
description: "Escolha o tipo de imagem",
type: Discord.ApplicationCommandOptionType.String,
required: true,
choices: [{
name: "Gatos",
value: "cat"
}, {
name: "Cachorros",
value: "dog"
}]
}],
run: async (client, inter) => {
try {
await inter.deferReply().catch((_) => {});
let res;
let option = inter.options.getString("tipo");

switch (option) {
case "cat":
await axios.get("https://api.alexflipnote.dev/cats").then(r =>
{
res = r.data;
});
break;
case "dog":
await axios.get("https://api.alexflipnote.dev/dogs").then(r =>
{
res = r.data;
});
break;
}
let row = new Discord.ActionRowBuilder().addComponents(new
Discord.ButtonBuilder().setLabel("Deletar").setStyle(Discord.ButtonStyle.Danger).se
tCustomId("botao").setEmoji(""));

let img = new Discord.AttachmentBuilder(res.file);


let msg = await inter.editReply({ files: [img], components: [row],
fetchReply: true
});
let c = msg.createMessageComponentCollector({ time: 600000 })

c.on("collect", async i => {


if (inter.user.id !== i.user.id) {
return await i.reply({ content: "Você não é o autor deste
comando, portanto não pode deletar a mensagem.", ephemeral: true
});
}
let fetchMsg = await i.channel.messages.fetch(i.message.id);
await fetchMsg.delete();
});
} catch (err) {
console.error(err)
}
}
}

Você também pode gostar