Python Discord.py方法不';我不明白

Python Discord.py方法不';我不明白,python,discord,bots,Python,Discord,Bots,我正在制作一个.py机器人 当我在Discord中向我的bot写入“.hello hello”时,方法hello不会得到arg hello, 如以下文档所述: 我得到了一个错误: Ignoring exception in command hello: Traceback (most recent call last): File "C:\Python39\lib\site-packages\discord\ext\commands\bot.py", line 902,

我正在制作一个.py机器人

当我在Discord中向我的bot写入“.hello hello”时,方法hello不会得到arg hello, 如以下文档所述:

我得到了一个错误:

Ignoring exception in command hello:
Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\discord\ext\commands\bot.py", line 902, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Python39\lib\site-packages\discord\ext\commands\core.py", line 856, in invoke
    await self.prepare(ctx)
  File "C:\Python39\lib\site-packages\discord\ext\commands\core.py", line 790, in prepare
    await self._parse_arguments(ctx)
  File "C:\Python39\lib\site-packages\discord\ext\commands\core.py", line 697, in _parse_arguments
    transformed = await self.transform(ctx, param)
  File "C:\Python39\lib\site-packages\discord\ext\commands\core.py", line 542, in transform
    raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: arg is a required argument that is missing.
这是密码

import discord
from discord.ext import commands

client = commands.Bot(command_prefix = '.')
# . - это запуск команды

@client.event

async def on_ready():
    print('BOT connected')

@client.command( pass_context = True) # use for chat prefix.

async def hello(ctx, arg):
    author = ctx.message.author
    
    await ctx.send(f'{author.mention}' + arg)

# Connect 
token = open( 'token.txt','r').readline()
client.run( token )
错误清楚地显示“MissingRequiredArguments”,我假设您正在尝试这样做。hello(您的句子)和bot在前面提到并添加了您的句子?那么这应该行得通。
*
会使用您在命令后所说的一切。例如:如果您添加了“hello this is a test”,但没有在arg/查询之前添加
*
,那么它将只接受第一个单词,在本例中为“hello”。 还可以使用
ctx.author
而不是ctx.message.author,您还可以做进一步的工作,如
ctx.author.name
ctx.author.notice

@client.command() 
async def hello(ctx, *, query):
    author = ctx.author
    await ctx.send(f"{author.mention} {query}")

这有用吗?不,这个链接的主题完全不同。除此之外,核心是discord.py库最近发生了变化,我的视频课程也过时了。是的,这正是我想让我的句子排在bot的前面的原因。事实上,我不能用*检查这个语法-在我应用之后,这个函数在我的bot中不起作用。谢谢,我现在和以后都会尝试。如果失败,请告诉我,如果真的失败,请通过discord UnidentifiedComponent(8118)与我联系