I used the trigger example code of canvacord, but I get the error:
DiscordAPIError: Cannot send an empty message
My code is:
const Command = require("../Structures/Command.js");
const canvacord = require('canvacord');
const Discord = require("discord.js")
module.exports = new Command({
name: "image",
description: "Edits an image!",
permission: "SEND_MESSAGES",
async run(message, args, client) {
let avatar = message.author.displayAvatarURL({ dynamic: false, format: 'png' });
let image = await canvacord.Canvas.trigger(avatar);
let attachment = new Discord.MessageAttachment(image, "triggered.gif");
message.channel.send(attachment);
}
})
Normal text commands work totally fine, it is just this one that isnt working. I tried with other code examples, but it still doesnt work.
When sending attachments, you need to specify them in the .send() function. You need to use the files property to make sure that the attachment is being sent properly, so you just need to edit the way you send the attachment to:
message.channel.send({
files: [attachment]
})