我最近从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")感谢你的未来
发布于 2021-02-01 04:45:47
https://stackoverflow.com/questions/65983722
复制相似问题