@GroznyDev

Не работает команда discord.py?

я создал команду /clear
@bot.command()
async def clear(ctx, amount=50):
    await ctx.channel.delete(limit=amount)

но при когда я пишу /clear 5
появляется ошибка
[2023-11-13 15:40:52] [ERROR   ] discord.ext.commands.bot: Ignoring exception in command clear
Traceback (most recent call last):
  File "C:\Users\daniel\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 235, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\daniel\Documents\Project\Grozny_bot\main.py", line 18, in clear
    await ctx.channel.delete(limit=amount)
TypeError: GuildChannel.delete() got an unexpected keyword argument 'limit'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\daniel\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1350, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\daniel\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 1029, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Users\daniel\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 244, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: GuildChannel.delete() got an unexpected keyword argument 'limit'
  • Вопрос задан
  • 104 просмотра
Решения вопроса 1
Mike_Ro
@Mike_Ro
Python, JS, WordPress, SEO, Bots, Adversting
https://www.folkstalk.com/2022/10/purge-command-di...
@bot.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def clean(ctx, limit: int):
        await ctx.channel.purge(limit=limit)
        await ctx.send('Cleared by {}'.format(ctx.author.mention))
        await ctx.message.delete()

@clean.error
async def clear_error(ctx, error):
    if isinstance(error, commands.MissingPermissions):
        await ctx.send("You cant do that!")
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы