2

I'm having problems with constants in different files: I have to store an embed in a different file, and then call it in the main one, but when I try to do it gives me parse errors like Unexpected '.' in 'help.embed' I tried to use the methods suggested in these threads [1,2] but they didn't work: it continues to give me that parse error. Can somebody help me?
PS: I don't want to use an HTML file to call the scripts, I want to use only JS and JSON

This is my code (simplified):

// help.js const Discord = require("discord.js"); var embed = new Discord.RichEmbed() .setTitle("Title") module.exports = Object.freeze({ embed: embed }); 
// main.js const help = require("./help.js") client.on("ready", () =>{ client.channels.find("id",config.disaply_channel).send(help.embed); //Parse error }); 
3
  • Are you sure the help object is coming through properly? Do you see the embed property when you log it to the console? Commented Jun 26, 2017 at 11:11
  • Try .send({help.embed}) Commented Jun 26, 2017 at 18:04
  • I logged the help object and I clearly see the embed property, with the type RichEmbed. I tried also to log only the help.embed and it's a normal object. But when I tried to send it, it returned "Unable to send empty message"or a thing like that Commented Jun 27, 2017 at 8:53

1 Answer 1

0

I found out that if the command was in the same file as the embed I should use message.channel.send({embed}), so I tried to send help.{embed}, but it gave me a fatal error. I resolved declaring the export embed: {embed} instead of only embed: embed, and then calling help.embed in the main file. Thank you for your support anyway

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.