首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >导致命令不响应的@bot.event

导致命令不响应的@bot.event
EN

Stack Overflow用户
提问于 2021-02-01 04:06:58
回答 1查看 29关注 0票数 0

我最近从google api serve=ive添加了一段代码,它导致我的整个脚本除了事件之外没有响应:

代码语言:javascript
复制
@bot.event
async def on_message(msg):
        analyze_request = {'comment': { 'text': msg.content }, 'requestedAttributes': {'TOXICITY': {}}}
        response = service.comments().analyze(body=analyze_request).execute()
        spanScore = response['attributeScores']['TOXICITY']['spanScores']
        value = spanScore[0]['score']['value']
        print(value * 100)
        toxicity = value * 100
        if toxicity > 95:
            await msg.author.kick(reason = "Toxic messages")
            await msg.author.send('You were kicked because you sent toxic message(s)')
            await msg.send(f"{msg.author}, has been kicked for being toxic !")
        elif toxicity > 70 and toxicity < 94:
            await msg.channel.send(f"{msg.author.mention}, please watch your language")

感谢你的未来

EN

回答 1

Stack Overflow用户

发布于 2021-02-01 04:45:47

您需要处理这些命令,请在on_message事件的末尾添加以下内容:

代码语言:javascript
复制
await bot.process_commands(message)

有关documentation上此主题的更多信息

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65983722

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档