Search code examples
c#.net-4.5discord.net

Send an empty message instead of Embed Discord.Net


I stated my problem in the title.

code:

public static async Task Whois(SocketSlashCommand command)
{
    var guildUser = (SocketGuildUser)command.Data.Options.First().Value;
    var roleList = string.Join(",\n", guildUser.Roles.Where(x => !x.IsEveryone).Select(x => x.Mention));
    var embedBuiler = new EmbedBuilder()
        .WithAuthor(guildUser.ToString(), guildUser.GetAvatarUrl() ?? guildUser.GetDefaultAvatarUrl())
        .WithTitle("Roles")
        .WithDescription(roleList)
        .WithColor(Color.Green)
        .WithCurrentTimestamp();

    await command.RespondAsync(embed: embedBuiler.Build());
}

response: response

I don't know what to do. Thank you for your help


Solution

  • Possible Solution 1

    First, be sure that you show embeds in you discord client. Go in your settings under Text & Images and activate the Show embeds and preview website links pasted into chat setting.

    Possible Solution 2

    As it seems in some GitHub issues you also have to give your bot the "Embed Link" permission. (Although this doesn't seem to affect slash commands embeds)

    Possible Solution 3

    It is also possible that another bot is removing the embed from you message, so you may want to add a logging bot (to check who is removing the embed) or create a new guild where only your bot is.


    It's very unlikely that the problem is in your code, as the Discord API doesn't actually allow empty messages to be sent. (although it is possible, if you send for example _ _ as your message content)