添加聊天过滤器事件后,discord命令不起作用

时间:2018-12-20 16:24:42

标签: python-3.x

我正在尝试使用Python为我的服务器构建一个简单的discord机器人。我是python的新手。我创建了一些简单的机器人命令,例如“ hi”,“ info”。然后我添加了聊天文件管理器,此后,bot命令不起作用,只有聊天过滤器起作用。

import discord
from discord.ext import commands
from discord.ext.commands import Bot
import asyncio
import chalk
import time

chat_filter = ["CURSE", "EVIL", "BAD"]
bypass_list = []
bot = commands.Bot(command_prefix='#')

@bot.event
async def on_ready():
    print ("Bot is Online")
    print ("Running on " + bot.user.name)
    print ("With ID: " + bot.user.id)

@bot.command(pass_context=True)
async def hi(ctx):
    await bot.say(":hugging: hey !!")
    print ("user has pinged")

@bot.command(pass_context=True)
async def info(ctx, user: discord.Member):
    await bot.say("The users name is: {}".format(user.name))
    await bot.say("The users ID is: {}".format(user.id))
    await bot.say("The users status is: {}".format(user.status))
    await bot.say("The users highest role is: {}".format(user.top_role))
    await bot.say("The user joined at: {}".format(user.joined_at))

@bot.command(pass_context=True)
async def kick(ctx, user: discord.Member):
    await bot.say(":boot: Cya, {}. Ya loser!".format(user.name))
    await bot.kick(user)

@bot.command(pass_context=True)
async def developer(ctx):
    await bot.say("Made by XX")

@bot.event
async def on_message(message):
    contents = message.content.split(" ")
    for word in contents:
        if word.upper() in chat_filter:
            if not message.author.id in bypass_list:
                try:
                    await bot.delete_message(message)
                    await bot.send_message(message.channel, ":mask: You cannot use that word here !")
                except discord.errors.NotFound:
                    return


bot.run("my token")

0 个答案:

没有答案