Discord.Net使用Bots头像作为IconURL / AvatarURL

时间:2020-07-05 09:24:58

标签: c# vb.net discord discord.net

我目前是一个嵌入对象,遇到麻烦的是将机器人的头像作为图标。这是在Visual Basic中提供的,但是如果C#中有某些功能,我可以使用它并尝试使其正常工作。

        Dim embed As New EmbedBuilder With {
        .Title = "Help comand",
        .Description = "hello",
        .Color = New Color(255, 0, 0),
        .ThumbnailUrl = Context.Guild.IconUrl,
        .Timestamp = Context.Message.Timestamp,
        .Footer = New EmbedFooterBuilder With {
                .Text = "Footer",
                .IconUrl = "URL COMMAND HERE"
            }
        }

我该如何解决?我曾经用其他语言看到过这种情况,但根据我的发现,Discord.Net上都没有

1 个答案:

答案 0 :(得分:0)

//as an author
var builder = new EmbedBuilder()
                .WithAuthor(author =>
                {
                    author
                    .WithIconUrl(Context.User.GetAvatarUrl() ?? Context.User.GetDefaultAvatarUrl());
                });
            var embed = builder.Build();

            await Context.Channel.SendMessageAsync(null, false, embed);
//as a title
var builder = new EmbedBuilder()
                .WithTitle(Context.User.GetAvatarUrl() ?? Context.User.GetDefaultAvatarUrl());
            var embed = builder.Build();

            await Context.Channel.SendMessageAsync(null, false, embed);

等等,你几乎可以在任何地方使用它。我有点晚了,但是为搜索此内容的新人做的