discord.py::来自bot的消息被发送了两次

zdwk9cvp  于 2021-08-25  发布在  Java
关注(0)|答案(0)|浏览(122)

这是我在亵渎过滤器中添加单词的代码:

@client.command()
@commands.has_any_role("Head Honcho", "Discord Moderator")
async def addfilter(ctx, word):
    if word.lower() in bannedWords:
        await ctx.send(f"`{word}` is already in the profanity filter.")
    else:
        bannedWords.append(word.lower())

        with open("./config.json", "r+") as f:
            data = json.load(f)
            data["bannedWords"] = bannedWords
            f.seek(0)
            f.write(json.dumps(data))
            f.truncate()

        await ctx.message.delete()
        await ctx.send(f"`{word}` was added to the profanity filter.")

每当第二次尝试添加单词时,bot将删除该消息并说“f” {word} 已经在亵渎过滤器中了。”它做得很好,但出于某种原因,它发送了两次而不是一次。我看不出我做错了什么。有人能告诉我是什么导致了这一切吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题