问题
I am trying to implement embedded messages for my bot. I know that I need to fill an Embed
Object with the specific informations. But how can I send it to the Channel? When I use e.Channel.SendMessage(string);
it can't send an Embed
object, it will just send strings.
回答1:
var eb = new EmbedBuilder();
eb.WithDescription("some text");
await Context.Channel.SendMessageAsync("", false, eb.Build());
In Discord.NET 1.0.
0.9.6 doesn't support embeds.
回答2:
With Discord.Net 2.0.1 syntax will look a little different.
EmbedBuilder builder = new EmbedBuilder();
builder.WithTitle("Ice Wizard Stats");
builder.AddField("Cost", "3", true); // true - for inline
builder.AddField("HP", "665", true);
builder.AddField("DPS", "42", true);
builder.AddField("Hit Speed", "1.5sec", true);
builder.AddField("SlowDown", "35%", true);
builder.AddField("AOE", "63", true);
builder.WithThumbnailUrl("http://...");
builder.WithColor(Color.Red);
await Context.Channel.SendMessageAsync("", false, builder.Build());
回答3:
You need to use Discord.net 1.0
Here is an example showing EmbedBuilder()
var builder = new EmbedBuilder();
builder.WithTitle("Ice Wizard Stats");
builder.AddInlineField("Cost", "3");
builder.AddInlineField("HP", "665");
builder.AddInlineField("DPS", "42");
builder.AddInlineField("Hit Speed", "1.5sec");
builder.AddInlineField("SlowDown", "35%");
builder.AddInlineField("AOE", "63");
builder.WithThumbnailUrl("url");
builder.WithColor(Color.Red);
await Context.Channel.SendMessageAsync("", false, builder);
Sorry I am a Clash fanatic. The await Context.Channel.SendMessageAsync("", false, builder);
sends the Embed to the channel :).
来源:https://stackoverflow.com/questions/44300770/discord-net-bot-embed-message