Mr-KayJayDee / discord-image-generation

Moved to a new repository
https://git.mrkayjaydee.xyz/Mr-KayJayDee/discord-image-generation
53 stars 13 forks source link

Triggered command returns image instead of gif. #22

Closed errorcodezero closed 2 years ago

errorcodezero commented 2 years ago

The triggered command for some reason returned an image instead of a gif.

Mr-KayJayDee commented 2 years ago

Hello, can you show me your code ?

errorcodezero commented 2 years ago
const { Client, Intents } = require("discord.js");

const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
const DIG = require("discord-image-generation");

client.once("ready", () => {
  console.log(`Ready!`);
});

client.on("messageCreate", (message) => {
  if (!message.content == "$triggered") {
    const avatar = message.author.displayAvatarURL({
      dynamic: false,
      format: "png",
    });
    const img = DIG.Triggered().setImage(avatar);
    message.channel.send({ files: [img] });
  }
});

client.login(process.env.token);

Screen Shot 2022-01-16 at 8 00 25 PM

Mr-KayJayDee commented 2 years ago

You need to dynamically specify the image type when sending.

let attach = new Discord.MessageAttachment(img, "triggered.png");
errorcodezero commented 2 years ago

Ohh okay thank you so much