[英]The bot does not respond to the command
機器人不響應命令,如何解決?
@bot.command(command=['sendmessage'])
async def sendmessage(ctx, message: str):
channel = ctx.message.channel
await channel.send(str)
我試圖用 message_handler 替換命令,但出現錯誤
line 117, in <module>
async def sendmessage(ctx, message: str):
TypeError: 'NoneType' object is not callable
您正在嘗試調用變量的數據類型,而不是變量本身。
您應該調用的變量是message
變量。 當您調用str
時,您指的是承載值的string
數據類型。 如下圖所示:
@bot.command(command=['sendmessage'])
async def sendmessage(ctx, message: str):
channel = ctx.message.channel
await channel.send(message)
您的函數將message
變量定義為字符串。 我相信您可能會誤解message
或str
是您要查找的變量。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.