Repository navigation
Expand file tree
/
Copy pathColor Code
More file actions
39 lines (31 loc) · 1.41 KB
/
Copy pathColor Code
File metadata and controls
39 lines (31 loc) · 1.41 KB
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
30
31
32
33
34
35
36
37
38
39
import asyncio
import discord
client = discord.Client()
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('!hello'):
await message.channel.send('Hello!')
if message.content.startswith('!color'):
color = message.content.split()[1]
role_name = f"Color-{color}"
role = discord.utils.get(message.guild.roles, name=role_name)
if role is None:
role = await message.guild.create_role(name=role_name, color=discord.Color(int(color, 16)))
await message.author.add_roles(role)
await message.channel.send(f'Color changed to {color}')
elif message.content.startswith('!recolor'):
role_name = f"Color-Rainbow"
role = discord.utils.get(message.guild.roles, name=role_name)
if role is None:
role = await message.guild.create_role(name=role_name)
await message.author.add_roles(role)
await message.channel.send("Rainbow color mode activated")
colors = [discord.Color.red(), discord.Color.orange(), discord.Color.yellow(),
discord.Color.green(), discord.Color.blue(), discord.Color.purple()]
while True:
for color in colors:
await role.edit(color=color)
await asyncio.sleep(0.5)
client.run('MTA2NjUwNTI2NjUwMzM1NjQzNg.Gwe1ao.x6EwcA7aSgpslnnL_VNjwnioqoqy6yOJ82zHvM')