C# Discord bot get senders avatar

假如想象 提交于 2020-02-06 08:39:01

问题


Hi I was wondering if anyone knew how to make my c# bot get a senders avatar and then have it reply with the users avatar in the message. Here is what I have:

    [Command("testuser")]
    public async Task testuser()
    {
        EmbedBuilder builder = new EmbedBuilder();

        builder.WithTitle("Message response")
            .WithDescription("Message" + **SENDERS USER AVATAR HERE**);

        await ReplyAsync("", false, builder.Build());
    }

I tried using:

.withurl() and .withimageurl()combined with Context.User.GetAvatarUrl and Context.User.AvatarId

But none of those worked, please help

Here is an example of what I want it to look like


回答1:


The EmbedBuilder.WithDescription() doesn't allow you to add images to the content of an embed's description, if what you want is for the embed to look like the screenshot you linked, then you have to use

builder.WithFooter($"Help requested by {Context.User.Username}", Context.User.GetAvatarUrl());


来源:https://stackoverflow.com/questions/52522155/c-sharp-discord-bot-get-senders-avatar

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!