Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
55
rated 0 times [  58] [ 3]  / answers: 1 / hits: 54615  / 5 Years ago, tue, april 23, 2019, 12:00:00

when i make a embed and run the bot, the problem here appears cos i used a let EmbedHelp = Discord.RichEmbed this problems appears in the Terminal, please type the problem and what i need to fix :



SyntaxError: Lexical declaration cannot appear in a single-statement context
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:283:19)


the code i use for the embed is :



client.on('message', message => {
if (message.startsWith('$Commands'))

let EmbedHelp = Discord.RichEmbed()
title: title ~~(did you know you can have markdown here too?)~~,
description: ```,
url: https://discordapp.com,
color: 192748,
timestamp: Timezone - GGT 3+,
footer: {
icon_url: https://cdn.discordapp.com/avatars/563449221701959700/8386d5fe48d71898c40244e7a5a66d58.png,
text: footer text
},
thumbnail: {
url: https://cdn.discordapp.com/avatars/563449221701959700/8386d5fe48d71898c40244e7a5a66d58.png
},
image: {
url: https://cdn.discordapp.com/embed/avatars/0.png
},
author: {
name: Galak$y#3038,
url: https://discordapp.com,
icon_url: https://discordapp.com/channels/564059839320555540/569179399211974666
},

}
});
channel.send({EmbedHelp})



More From » node.js

 Answers
10

That error is referring to the line below Discord.RichEmbed(). You have an Object property declaration without any Object in sight. Looks like you're mixing up a few things that you tried to pull from the Discord docs.


RichEmbed is intended to be chained with other helper methods. If you instead put your code into an Object (wrapping it in curly braces {}) and pass it into an send method, it should get rid of that error.


client.on('message', (message) => {
if (message.startsWith('$Commands')) {
message.channel.send({
embed: {
title: 'title ~~(did you know you can have markdown here too?)~~',
description: '```',
url: 'https://discordapp.com',
color: 192748,
timestamp: 'Timezone - GGT 3+',
footer: {
icon_url:
'https://cdn.discordapp.com/avatars/563449221701959700/8386d5fe48d71898c40244e7a5a66d58.png',
text: 'footer text',
},
thumbnail: {
url: 'https://cdn.discordapp.com/avatars/563449221701959700/8386d5fe48d71898c40244e7a5a66d58.png',
},
image: {
url: 'https://cdn.discordapp.com/embed/avatars/0.png',
},
author: {
name: 'Galak$y#3038',
url: 'https://discordapp.com',
icon_url:
'https://discordapp.com/channels/564059839320555540/569179399211974666',
},
},
});
}
});


[#52199] Wednesday, April 17, 2019, 5 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
joseluispauld

Total Points: 13
Total Questions: 132
Total Answers: 98

Location: Venezuela
Member since Sat, Apr 24, 2021
3 Years ago
;