【发布时间】:2018-07-10 06:57:13
【问题描述】:
我有一段代码,它接受一个指定的角色和角色服务器并将其放入一个列表中,列表中的任何角色都应该改变颜色,但是......它不会。
代码:
@client.command(pass_context=True,description="Linusifies a role")
@has_permissions(administrator = True)
async def rgb(ctx, role : discord.Role):
server = ctx.message.author.server
if (("{}, {}").format(server, role)) in rgb_list:
msg = "{}'s rgb is turned off :disappointed_relieved:".format(role)
rgb_list.remove(("{}, {}").format(server, role))
await client.send_message(ctx.message.channel, msg)
print (server)
else:
msg = "{}'s rgb has been turned on :christmas_tree:".format(role)
rgb_list.append(("{}, {}").format(server, role))
await client.send_message(ctx.message.channel, msg)
print (server)
在我的@client.event 中:
async def rgb_():
await client.wait_until_ready()
while not client.is_closed:
print (rgb_list)
await client.edit_role(rgb_list,colour=discord.Colour(0x1abc9c))
await asyncio.sleep(2)
await client.edit_role(rgb_list,colour=discord.Colour(0x11806a))
await asyncio.sleep(2)
await client.edit_role(rgb_list,colour=discord.Colour(0x2ecc71))
await asyncio.sleep(2)
await client.edit_role(rgb_list,colour=discord.Colour(0x1f8b4c))
await asyncio.sleep(2)
await client.edit_role(rgb_list,colour=discord.Colour(0x3498db))
await asyncio.sleep(2)
await client.edit_role(rgb_list,colour=discord.Colour(0x206694))
await asyncio.sleep(2)
await client.edit_role(rgb_list,colour=discord.Colour(0x9b59b6))
await asyncio.sleep(2)
await client.edit_role(rgb_list,colour=discord.Colour(0x71368a))
await asyncio.sleep(2)
await client.edit_role(rgb_list,colour=discord.Colour(0xe91e63))
await asyncio.sleep(2)
await client.edit_role(rgb_list,colour=discord.Colour(0xad1457))
await asyncio.sleep(2)
await client.edit_role(rgb_list,colour=discord.Colour(0xf1c40f))
await asyncio.sleep(2)
await client.edit_role(rgb_list,colour=discord.Colour(0xc27c0e))
await asyncio.sleep(2)
await client.edit_role(rgb_list,colour=discord.Colour(0xe67e22))
await asyncio.sleep(2)
await client.edit_role(rgb_list,colour=discord.Colour(0xa84300))
await asyncio.sleep(2)
await client.edit_role(rgb_list,colour=discord.Colour(0xe74c3c))
await asyncio.sleep(2)
await client.edit_role(rgb_list,colour=discord.Colour(0x992d22))
await asyncio.sleep(2)
【问题讨论】:
标签: python python-3.x discord discord.py