Bot 没有响应命令并且没有显示错误 discord.py

时间:2020-12-20 18:06:35

标签: python asynchronous

当我运行我的机器人时,它从不显示命令的任何错误消息,但是当我尝试不和谐地使用它们时,它根本没有响应。我尝试了很多东西,比如看视频和不同的网站,但它们根本没有帮助。有人可以告诉我这里出了什么问题:

import discord
from discord.ext import commands, tasks
import asyncio
from itertools import cycle
keep_alive()
import os

client = discord.Client()
bot = commands.Bot(command_prefix="!")
status = cycle(['Hail the almighty DEATH','!help'])
bot.remove_command('help')


@client.event
async def on_ready():
  change_status.start()
  print('Bot is ready')

@tasks.loop(seconds=10)
async def change_status():
  await client.change_presence(activity=discord.Game(next(status)))

@client.event
async def on_message(message):
    channel = message.channel
    if message.author == client.user:
        return

    if message.content.startswith('!hello'):
      if str(message.author) == "DEATH ITSELF#6030":
        await message.channel.send('Hello DEATH, my master.')
      else:
          await message.channel.send('Why hello there mortal')
    if message.content.startswith('!echo'): #repeats what user says
      msg = message.content.split()
      await channel.send(" ".join(msg[1:]))

@bot.command()
async def ping():
  await client.say('Pong!')

@bot.command(pass_context=True)
async def help(ctx):
  author = ctx.message.author
  embed = discord.Embed(
    colour = discord.Colour.red()
  )
  embed.set_author(name='Help')
  embed.add_field('!ping', value= 'Returns Pong!', inline=False)
  await client.send_message(author, embed=embed)

@bot.command(pass_context=True)
async def clear(ctx,amount=3):
  channel = ctx.message.channel
  messages = []
  async for message in client.logs_from(channel, limit=int(amount)):
    messages.append(message)
  await client.delete_messages(messages)







client.run(os.getenv('TOKEN'))```

0 个答案:

没有答案