不和谐机器人的担忧

时间:2019-01-27 09:59:28

标签: python

不确定我当前的代码到底是什么,打印成功并显示机器人游戏为“正常”。

但是,当涉及到命令时,它们似乎都不起作用。 它也不打印任何错误消息。

任何帮助将不胜感激。

删除了必要的凭据。

谢谢。

import discord
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio
import random
from discord import Game
import time

Client  = discord.client
client = commands.Bot(command_prefix = "!")

chat_filter = ["", "", "", ""] #Chat filter
bypass_list = []

@client.event # Game status
async def on_ready():
    await client.change_presence(game=Game(name="working"))
    print("Success")

# General commands #

@client.event
async def on_message(message):
    if message.content.upper().startswith('!PING'): # General command, case senstive included.
        userID = message.author.id
        await client.send_message(message.channel, "<@%s> Pong!" % (userID)) # Mentions user role
    if message.content.upper().startswith('!BAN'):
        if "531297906091884544" in {role.id for role in message.author.roles}: # Role specific to run command
            await client.send_message(message.channel, "<@%s> Still underconstruction! :slight_frown:" % (userID))
        else:
            await client.send_message(message.channel, "Insufficient permissions!")

# Chat Filter #

@client.event
async def on_message(message):
    contents = message.content.split(" ") #contents is a list type
    for word in contents:
        if word.upper() in chat_filter:
            if not message.author.id in bypass_list:
                try:
                    await client.delete_message(message)
                    await client.send_message(message.channel, "<@%s> You're unable to mention that word here :/" % (userID)) # Mentions user role
                except discord.errors.NotFound:
                    return

client.run("")

0 个答案:

没有答案