When attempting to use this code I got the error below:

const embed = new RichEmbed();

var num = Math.floor(Math.random() * 10);
let name = part + num + ".gif";

embed.attachFiles([name]);
embed.setImage('attachment://' + name);

mess.channel.send(embed);
TypeError: embed.attachFiles is not a function

I if I delete away embed.attachFiles([name]) I get an error saying that embed.setImage isn't a function either.
Is there anything I can do to make Heroku register these as functions? It is worth noting that this worked outside of Heroku, when I ran it using the command line on my own computer.

1 Answers

1
Federico Grandi On

Heroku by itself does not modify the behavior of discord.js. Here's a list of things you can try:

  • Verify that your package.json file is updated with the version of discord.js you want and run npm i to make sure the version on your pc is the same*.
  • Make sure that RichEmbed is Discord.RichEmbed: try to write it explicitly to see if that helps.
  • Try to console.log(embed) and see what gets logged in the console: that might give you a clue of what the problem is...

* The RichEmbed.attachFile() method was added in the 11.0.0 version: any previous version of discord.js won't allow you to use it.