Search code examples
c#discorddsharp+

C# - DSharp getting color of the Bots (highest) Role


I'm trying to make it so when you call a Interactivity Embed, the line that shows on the left side is the same color as the Bots highest role color. (Really minor details, but for some reason I really want it)

So far i only found answers for the Javascript version (discord.js) but none for DSharp. The Documentation on https://dsharpplus.github.io/api isn't helping either. I tried the following:

ctx.Guild.GetMemberAsync(MY BOT ID).Color;

I did that on a test server with a static ID just to see if it would work at all, at least on one server, but it didn't.

Next I tried using

ctx.Client.Guild.GetRole(MY BOT ROLE ID).Color;

which does work, but only on one server and with one role. I want it to work on any server with any role, so that it gets the color

I am at a loss. Help plz.

The relevant code in general:

public async Task join(CommandContext ctx)
{

   DiscordColor botTopRoleColor =  //help;
    


    var Thumbnail = new DiscordEmbedBuilder.EmbedThumbnail { Url = ctx.Client.CurrentUser.AvatarUrl };
    var joinEmbed = new DiscordEmbedBuilder
    {
        Title = "Head",
        Description = "Body",
        Thumbnail = Thumbnail,
        Color = botTopRoleColor //(This should be the highest role color which i am trying to set in botTopRoleColor
    }; ...

Solution

  • ctx.Guild.CurrentMember.Color. If that doesn't work, you might be on an old version that doesn't have proper intents enabled.