TypeError:“coroutine”对象不是callab

2024-09-30 03:23:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图让我的机器人创建一个服务器(公会),我有一个问题,它说它不等待,即使我让它等待。在

我试着等它

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}$

Tags: inimport服务器clienttokenasynciostringdef
1条回答
网友
1楼 · 发布于 2024-09-30 03:23:59

您试图使用^{}作为装饰器,但事实并非如此。在

你的代码相当于

async def temp():
    await client.create_guild(randomString(10), region=None, icon=None)

start_creation = client.create_guild(temp)

所以start_creation是一个协同程序对象,它是可等待的但不可调用的。在

相关问题 更多 >

    热门问题