Skip to content

Instantly share code, notes, and snippets.

@Zzz9194
Last active July 16, 2020 14:21
Show Gist options
  • Save Zzz9194/1633312f92dd435b6fbf88bcd28006de to your computer and use it in GitHub Desktop.
Save Zzz9194/1633312f92dd435b6fbf88bcd28006de to your computer and use it in GitHub Desktop.
Make a command that sends a rainbow embed (Editing the embed w/ different colors at a certain interval for an amount of time)
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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment