簡體   English   中英

機器人不響應命令

[英]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變量定義為字符串。 我相信您可能會誤解messagestr是您要查找的變量。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM