'Why I can't send embed messages to my discord bot?
I'm trying to make a simple discord bot. Unfortunately, I ran into a problem where I can't send embedded messages specifically "event.getChannel().sendMessage(embed.build()).queue();" this line of code is not working. Any help would be appreciated!
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
public class Commands extends ListenerAdapter {
public String prefix = "!";
@Override
public void onMessageReceived(MessageReceivedEvent event) {
String[] args = event.getMessage().getContentRaw().split(" ");
if(args[0].equalsIgnoreCase(prefix + "test")){
EmbedBuilder embed = new EmbedBuilder();
embed.setTitle("Title");
embed.setDescription("This is the Embed Description");
embed.addField("Embed Field 1", "Field", false);
embed.setFooter("Bot created by toMar?s");
//event.getMessage().reply("This bot is working!").queue();
event.getChannel().sendMessage("This bot is working!").queue();
event.getChannel().sendMessage(embed.build()).queue();
}
}
}
Solution 1:[1]
You have to change the .sendMessage() to .sendMessageEmbeds(). Probably because .sendMessage() needs some type of character sequence but I did not provide that.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | user16731988 |
