Discord.net 机器人嵌入消息
Discord.net bot Embed Message
我正在尝试为我的机器人实现嵌入式消息。我知道我需要用特定信息填充一个 Embed
对象。但是我怎样才能将它发送到频道呢?当我使用 e.Channel.SendMessage(string);
时,它无法发送 Embed
对象,它只会发送字符串。
var eb = new EmbedBuilder();
eb.WithDescription("some text");
await Context.Channel.SendMessageAsync("", false, eb.Build());
在 Discord.NET 1.0.
0.9.6 不支持嵌入。
您需要使用Discord.net 1.0
这是一个显示 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);
对不起,我是冲突狂热者。 await Context.Channel.SendMessageAsync("", false, builder);
将嵌入发送到频道 :).
使用 Discord.Net 2.0.1 语法看起来会有些不同。
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());
我正在尝试为我的机器人实现嵌入式消息。我知道我需要用特定信息填充一个 Embed
对象。但是我怎样才能将它发送到频道呢?当我使用 e.Channel.SendMessage(string);
时,它无法发送 Embed
对象,它只会发送字符串。
var eb = new EmbedBuilder();
eb.WithDescription("some text");
await Context.Channel.SendMessageAsync("", false, eb.Build());
在 Discord.NET 1.0.
0.9.6 不支持嵌入。
您需要使用Discord.net 1.0
这是一个显示 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);
对不起,我是冲突狂热者。 await Context.Channel.SendMessageAsync("", false, builder);
将嵌入发送到频道 :).
使用 Discord.Net 2.0.1 语法看起来会有些不同。
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());