I have a Discord bot and I'm trying to make an embed with a random RGB color. When I try to use this command in discord, it simply returns nothing.
My code for this is:
DiscordEmbedBuilder Embed = new DiscordEmbedBuilder
{
Color = new DiscordColor(Rand.Next(0, 256), Rand.Next(0, 256), Rand.Next(0, 256))
};
CodePudding user response:
I suspect you are trying to make use of
Switching to this code, which explicitly casts the values to byte
works:
Random rand = new Random();
DiscordEmbedBuilder Embed = new DiscordEmbedBuilder
{
Color = new DiscordColor((byte)rand.Next(0, 255), (byte)rand.Next(0, 255), (byte)rand.Next(0, 255))
};
Also, you probably want rand.Next(0, 255)
since byte
only goes up to 255.