from discord.ext import commands
from discord import Embed, Color
from random import randint as ri
from asyncio import sleep as sl
@bot.command(name="rainbow")
async def rainbow_cmd(ctx):
emb = discord.Embed(title="Rainbow time 🕺")
first_msg = await ctx.send(embed=emb)
for _ in range(10): # Amount of times to change color before stopping
# Random RGB values every time (You could do this differently or just limit the range)
red = ri(1,255)
green = ri(1,255)
blue = ri(1,255)
clr = discord.Color.from_rgb(
r = red,
g = green,
b = blue
)
emb.color = clr
await first_msg.edit(embed=emb)
await sl(0.5)
End result looking 😳 (It was a little slow since it was running locally on my 6 year old mac)