【发布时间】:2021-01-21 15:45:46
【问题描述】:
所以我正在制作一个基本的机器人命令,以响应玩家所说的内容,例如执行 !test code 将使机器人以“代码”响应。出于某种原因,运行命令时没有任何反应。我什至在里面放了一个打印件,看看它是否真的在运行,但事实并非如此。这是我的代码:
import discord
from discord.ext import commands
client = discord.Client()
bot = commands.Bot(command_prefix="!")
@client.event
async def on_ready():
print('Logged in as {0.user}'.format(client))
print("-"*16)
game = discord.Game("Discord")
await client.change_presence(status=discord.Status.online, activity=game)
@bot.command()
async def test(ctx, arg):
await ctx.send(str(arg))
client.run('token here')
感谢任何帮助。
【问题讨论】: