D
D
dasehak2020-08-27 17:13:32
Python
dasehak, 2020-08-27 17:13:32

Discord py not working help why?

Command code (I removed help)

@bot.command(pass_context = True)
async def help(ctx, arg):
    emb = discord.Embed(title = 'Помощь', colour = 0x2e2d2d)

    if arg == 'poll':
        emb.add_field(name = f"{PREFIX}poll", value = f"Использовать:\nder poll (название голосования), (первый параметр), (второй параметр), (и так до 9 раз)\nПример создания голосования:\npoll test, 1, 2")
        await ctx.send(embed = emb)

    else:
        emb.add_field(name = f"{PREFIX}poll", value = f"Создание голосовния.")
        await ctx.send(embed = emb)

Mistake:
Ignoring exception in command help:
Traceback (most recent call last):
  File "D:\f\lib\site-packages\discord\ext\commands\bot.py", line 903, in invoke
    await ctx.command.invoke(ctx)
  File "D:\f\lib\site-packages\discord\ext\commands\core.py", line 847, in invoke
    await self.prepare(ctx)
  File "D:\f\lib\site-packages\discord\ext\commands\core.py", line 784, in prepare
    await self._parse_arguments(ctx)
  File "D:\f\lib\site-packages\discord\ext\commands\core.py", line 699, in _parse_arguments
    kwargs[name] = await self.transform(ctx, param)
  File "D:\f\lib\site-packages\discord\ext\commands\core.py", line 535, in transform
    raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: arg is a required argument that is missing.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Nevzorov, 2020-08-27
@dasehak

Your argument argdoes not have a default value. Arguments without a default value are considered required arguments.
Add a default argument value, or make the argument type Optional.

@bot.command()  # pass_context НЕ существует в текущей версии discord.py: https://discordpy.readthedocs.io/en/v1.4.1/migrating.html#context-changes
async def help(ctx, arg = None):
    emb = discord.Embed(title = 'Помощь', colour = 0x2e2d2d)

    if arg == 'poll':
        emb.add_field(name = f"{ctx.prefix}poll", value = f"Использовать:\nder poll (название голосования), (первый параметр), (второй параметр), (и так до 9 раз)\nПример создания голосования:\npoll test, 1, 2")
        await ctx.send(embed = emb)

    else:
        emb.add_field(name = f"{ctx.prefix}poll", value = f"Создание голосовния.")
        await ctx.send(embed = emb)

or
from typing import Optional

@commands.command()
async def cmd(ctx, arg: Optional[str]): ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question