【发布时间】:2019-12-06 00:18:29
【问题描述】:
我试图让我的机器人创建一个服务器(公会),但我遇到的问题是它说它没有在等待,即使我让它等待。
我试过等待它
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)
预期:使用随机字符串创建服务器,无区域,无图标 实际结果:协程问题 错误
Traceback (most recent call last):
File "app.py", line 31, in <module>
asyncio.run(start_creation())
TypeError: 'coroutine' object is not callable
sys:1: RuntimeWarning: coroutine 'Client.create_guild' was never awaited
【问题讨论】:
标签: python async-await discord.py coroutine