Bot更改角色颜色不会产生任何错误,但不会更改颜色

时间:2020-10-01 03:53:27

标签: discord.py

我正在使用Discord API制作一个更改角色颜色的机器人。当我运行此代码时,它不会产生任何错误,但不会改变颜色

import discord
import time
from discord.ext import commands
bot = commands.Bot(command_prefix='>')

colors = [0xFF0000, 0xF0A804, 0xFFFF00, 0x008000, 0x0000FF, 0x800080]
@bot.command()
async def rainbow(ctx):
    username = ctx.message.author
    print(username)
    roleid = 123
    role = discord.utils.get(username.guild.roles, id=roleid)
    await username.add_roles(discord.utils.get(username.guild.roles, id=roleid))
    await ctx.send('You found the Rainbow!')  #  (The rainbow hates you)
    for i in range(6):
        await role.edit(colour=discord.Colour(colors[i]))
        time.sleep(0.5)
        print(colors)
    await username.remove_roles(discord.utils.get(username.guild.roles, id=roleid))
bot.run('bot token')

1 个答案:

答案 0 :(得分:0)

我也有这个问题。我注意到,每当您修改角色后,由于某些原因,您将不再能够对其进行修改。我仍在努力找出原因。