没有使用Discord.py的命令响应重写[duplicate]

问题描述 投票:0回答:1

我使用下面的代码创建了一个不和谐的bot,但是当我在服务器中键入.8ball或.ping时,我没有响应,也没有收到任何错误消息。但是,当我键入“ hello”时,确实得到了“ Hi”的预期响应,因此我知道它已连接。我感到困惑,因为我检查了100次语法,看不到任何错误。

import discord
import random
from discord.ext import commands

bot = commands.Bot(command_prefix = '.')

@bot.command()
async def ping(ctx):
  await ctx.send("PONG!")
  #await ctx.send(f'pong {round(bot.latency * 1000)}ms')

@bot.event
async def on_message(message):
  id = bot.get_guild(521372392132706328)
  if message.content.find("hello") != -1:
    await message.channel.send("Hi")
  elif message.content == "users":
    await message.channel.send(f"""# of Members {id.member_count}""")

@bot.command(aliases=['8ball'])
async def _8ball(ctx, *, question):
  responses = [
            "It is certain.",
            "It is decidedly so.",
            "Without a doubt.",
            "Yes - definitely.",
            "You may rely on it.",
            "As I see it, yes.",
            "Most likely.",
            "Outlook good.",
            "Yes.",
            "Signs point to yes.",
            "Reply hazy, try again.",
            "Ask again later.",
            "Better not tell you now.",
            "Cannot predict now.",
            "Concentrate and ask again.",
            "Don't count on it.",
            "My reply is no.",
            "My sources say no.",
            "Outlook not so good.",
            "Very doubtful."]
  await ctx.send(f'Question: {question}\nAnswer: {random.choice(responses)}')


bot.run('12345')
python command bots discord discord.py
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.