【发布时间】:2020-12-15 14:03:03
【问题描述】:
我正在尝试做一个永久改变颜色的角色。我正在使用 discord.py 重写。
几个小时前它起作用了,现在我很困惑,因为它不再起作用了。我什么都没改变。
这是我的代码:
import discord
import asyncio
from discord.ext import commands
bot = commands.Bot(command_prefix='?', description="description")
@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
@bot.command()
async def rgb(ctx, time: int):
colours = [0xFF0000, 0x00FF00, 0x0000FF]
i = 0
selectedrole = ctx.guild.get_role(748128282859274251)
while True:
i = (i + 1) % 3
print("This is printed")
await selectedrole.edit(colour=discord.Colour(colours[i]))
print("This will not be printed")
await asyncio.sleep(time)
bot.run('xxxxx')
它不运行这行代码,只是停止(程序仍在运行,没有任何反应)
等待 selectedrole.edit(color=discord.Colour(colours[i]))
【问题讨论】:
-
你有什么错误?
-
没有错误
-
永远不要在任何代码中提供您的机器人令牌。
-
我将令牌更改为随机的东西。不是我的。 ;)
标签: python discord discord.py discord.py-rewrite