【问题标题】:@bot.event causing commands to not respond@bot.event 导致命令无响应
【发布时间】:2021-01-31 20:06:58
【问题描述】:

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

@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")

感谢未来的回答者

【问题讨论】:

    标签: google-api discord discord.py google-api-python-client


    【解决方案1】:

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

    await bot.process_commands(message)
    

    有关此主题的更多信息,请访问documentation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-18
      • 2017-10-15
      • 2021-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多