我试图让我的机器人创建一个服务器(公会),我有一个问题,它说它不等待,即使我让它等待。在
我试着等它
import discord, random, string, asyncio
from discord.ext import commands
def randomString(stringLength=10):
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(stringLength))
Token = ""
client = discord.Client()
print("-----------------------------------")
print("| Choices |")
print("| (1) Token Banner |")
print("-----------------------------------")
Choice = input("Which choice would you like to choose?: ")
if Choice == "1":
Token = input(str("What token would you like to get banned?: "))
@client.event
async def on_ready():
print("Logged in as: %s" % Token)
@client.create_guild
async def start_creation():
await client.create_guild(randomString(10), region=None, icon=None)
asyncio.run(start_creation())
client.run(Token, bot=False)
预期:创建一个带有随机字符串、无区域、无图标的服务器 实际结果:协同程序问题 错误
^{pr2}$
您试图使用^{} 作为装饰器,但事实并非如此。在
你的代码相当于
所以
start_creation
是一个协同程序对象,它是可等待的但不可调用的。在相关问题 更多 >
编程相关推荐