Discord.js Trying to send embed, but just sends empty message
Clash Royale CLAN TAG#URR8PPP
Discord.js Trying to send embed, but just sends empty message
I'm trying to send my channel an embed message, so when I type
**embed
in my channel it should return the embed message like
testbot Title
Description
But it just returns an empty message from my testbot (the bot name). I tried using
message.channel.send(embedd, embed);
instead, but it gives me an error saying embed isn't declared. .send(content, options) is the format and embed is the option.
const Discord = require("discord.js");
const bot = new Discord.Client();
const TOKEN = "MY_TOKEN_ID";
const PREFIX = "**";
var name;
var usrAuth = 0;
bot.on("ready", function()
console.log("Ready");
);
bot.on("message", function(message)
console.log(message.content);
if ( message.author.equals(bot.user))
return;
// If the message doesn't begin with ** (Our prefix); do nothing
if( !message.content.startsWith(PREFIX))
return;
var argv = message.content.substr(PREFIX.length).split(" ");
console.log("argv: "+argv+", argv[1]: "+argv[1]+"");
// "+VAR_NAME+" Allows you to print a variable
switch(argv[0].toLowerCase())
case "ping":
message.channel.send("Ping!");
break;
case "embed":
var embedd = new Discord.RichEmbed()
.addField("Title", "Description")
message.channel.sendEmbed(embedd);
// .catch(console.error);
break;
default:
message.channel.send("Invalid commands");
);
bot.login(TOKEN);
My code is above, any ideas what's wrong? Changing var to const also does nothing.
4 Answers
4
Rename the variable to embed
and use this format
embed
case "embed":
var embed = new Discord.RichEmbed()
.addField("Title", "Description")
message.channel.send(embed);
// .catch(console.error);
break;
What do you mean by prints an empty string? When I do
**embed
alone it gives prntscr.com/fdvcfa which is exactly as you've described wanting it to do. Or am I missing a point? @Mad_Questionnaire– Wright
May 30 '17 at 15:47
**embed
I think someone on my system is bugged, the bot doesn't seem to print things, but worked for you, prints this puu.sh/w5DFa/3a79b4fd17.png
– Mad_ Questionnaire
May 30 '17 at 16:02
Thank you so much! I had forgot the in the send action.
– Chip Thrasher
Oct 15 '17 at 19:57
This should work
case "embed":
var embed = new Discord.RichEmbed()
.setTitle(`Title`)
.setDescription(`Desc`)
.addField("Title", "Description")
message.channel.sendEmbed(embed);
// .catch(console.error);
break;
Use this format:
message.channel.send( embed: embedd )
The method of sending using sendEmbed
is now deprecated. For embeds using the send event, you need to specify it is an embed using send( embed: variable )
otherwise it will return an empty message which will (in future) make the bot exit.
sendEmbed
send( embed: variable )
Could you explain why and how exactly this answers the question?
– anothernode
Jul 23 at 15:01
The method of sending using sendEmbed is now deprecated. For embeds using the send event, you need to specify it is an embed using send( embed: variable ) otherwise it will return empty message which will (in future) make the bot exit.
– XxMulti GamerxX
Jul 23 at 15:25
let embed = new Discord.RichEmbed()
.setColor(0x00AE86)
.addField("Title", "Description")
.setTimestamp()
if(!args[0]) return message.channel.send(embed);
This what I have used to make all the embed on my bot.
Can you expand your answer to include what is different in your example or why the OP's code isn't working?
– ivcubr
Aug 12 at 2:37
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
I just tried this and it still prints an empty string, although it doesn't give me the deprecation error anymore.
– Mad_ Questionnaire
May 30 '17 at 15:38