-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrainbowembed.py
29 lines (24 loc) · 989 Bytes
/
rainbowembed.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import discord, asyncio
from random import randint
from discord.ext import commands
class RainbowEmbed:
message = None
content = None
def __init__(self, bot):
self.bot = bot
async def loop(self):
while self.message is not None:
await self.message.edit(content=None, embed=discord.Embed(description=self.content, color=discord.Colour.from_rgb(r=randint(0, 255), g=randint(0, 255), b=randint(0, 255))))
await asyncio.sleep(1)
@commands.command(aliases=['rbembed', 'rb'], pass_context=True)
async def rainbowembed(self, ctx, msg_id: int = 0):
await ctx.message.delete()
if not self.message:
async for msg in ctx.message.channel.history().filter(lambda m: m.id == msg_id):
self.content = msg.content
self.message = msg
break
await self.loop()
else: self.message = None
def setup(bot):
bot.add_cog(RainbowEmbed(bot))