Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Discord.py:黑名单Cog.listener标记错误:TypeError:';str';对象不可调用_Python_Python 3.x_Discord.py - Fatal编程技术网

Python Discord.py:黑名单Cog.listener标记错误:TypeError:';str';对象不可调用

Python Discord.py:黑名单Cog.listener标记错误:TypeError:';str';对象不可调用,python,python-3.x,discord.py,Python,Python 3.x,Discord.py,我有一个将单词列入黑名单的命令,但它似乎不起作用。标记错误第128行,在on_消息中,msg=message.content()类型错误:“str”对象不可调用 @commands.Cog.listener() async def on_message(self, message): """Deletes a messaged that contains a blacklisted word""" msg = mess

我有一个将单词列入黑名单的命令,但它似乎不起作用。标记错误
第128行,在on_消息中,msg=message.content()类型错误:“str”对象不可调用

@commands.Cog.listener()
async def on_message(self, message):
    """Deletes a messaged that contains a blacklisted word"""

    msg = message.content()

    for word in msg:

        if msg.find("blacklist") != -1:

            await message.delete()

这是因为您试图将属性
.content
用作函数。不能调用属性

获取消息内容的正确方法是删除这些括号

@commands.Cog.listener()
async def on_message(self, message):
    """Deletes a messaged that contains a blacklisted word"""

    msg = message.content
    
    ...

它可以工作,但它会标记error
discord.errors.NotFound:404 NotFound(错误代码:10008):未知消息
在哪一行生成错误?在我的示例中,
等待消息的那一行。delete()
处于启用状态,这意味着消息已被删除。因此,我会检查是否有其他机器人正在删除您之前的邮件。没有其他机器人。