【发布时间】:2021-07-22 15:26:23
【问题描述】:
我的 discord 机器人有问题:当我输入 discord $ping 时,他没有回复我 pong 并且我不知道为什么,我只是检查机器人是否具有管理员角色,以便他可以写,我'我使用 VsCode,他没有给我任何错误。
这是代码
import discord
from discord.ext import commands
import requests
import json
import random
client = discord.Client()
bot = commands.Bot(command_prefix='$')
@bot.command()
async def ping(ctx):
await ctx.channel.send("pong")
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
client.run("XXXXXXXXXXXXXXXXXXXXXXX")
【问题讨论】:
-
你在混合
client和bot,不要那样做...这就是命令不起作用的原因。 -
那么我需要删除什么? client =discord.Client() andall@client 事件?
-
是的,您可以删除
client = discord.Client()并使用bot.event和bot.command()。要运行机器人,请使用bot.run("Token")
标签: python command discord.py bots