1
votes

I keep getting this error:

Ignoring exception in on_command_error

Traceback (most recent call last):

File "/usr/local/lib/python3.8/dist-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)

File "bot.py", line 191, in on_command_error
raise error

File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)

File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 855, in invoke
await self.prepare(ctx)

File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 789, in prepare
await self._parse_arguments(ctx)

File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 697, in _parse_arguments
transformed = await self.transform(ctx, param)

File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 542, in transform
raise MissingRequiredArgument(param) discord.ext.commands.errors.MissingRequiredArgument: cooldown is a required argument that is missing.

Please help me its saying that here is my code

import discord
import json
import requests
import time
from discord.ext import commands
from discord.ext.commands import cooldown
from datetime import datetime, timedelta

on_cooldown = {}
client = commands.Bot(command_prefix = "!")
client.remove_command("help")
async def get_user_data():
  with open("account.json","r") as f:
    users = json.load(f)
  return users

@client.event
async def on_ready():
  print("Bot is ready")
  print('Connected to bot: {}'.format(client.user.name))
  print('Bot ID: {}'.format(client.user.id))
  await client.change_presence(activity=discord.Game(name="Dwayne is protecting"  + str(len(client.guilds)) + "Eggplants ", type=0))

#help command
@client.command(pass_context=True, aliases=['Help'])
async def help(ctx):
    embed=discord.Embed(title="Help", description='Bot prefix = ?', color=0x7a0000)
    embed.add_field(name="Spammers", value="!post <number> <message> <quantity>\n!plan", inline=True)
    embed.add_field(name="Admin", value="!createa <User ID> <ExpDate> <cooldown> (Y-M-D)\n!bana <User ID> <Reason+Reason>\n?purge <amount>\n!ban <user> <reason>\n!unban <user>", inline=False)
    embed.set_footer(text="Dwayne Bot")
    await ctx.send(embed=embed)

@client.command()
async def post(ctx, To, message, amount):
  users = await get_user_data()
  if str(ctx.author.id) in users:
    if users[str(ctx.author.id)]['Banned'] == 'N':
      timeleft = datetime.strptime(users[str(ctx.author.id)]['expDate'],'%Y-%m-%d') - datetime.now()
      if timeleft.days <= 0:
         em = discord.Embed(color=0x7a0000, description="Sorry your plan on this tool has expired")
         await ctx.send(embed=em)
      else:
        move_cooldown = users[str(ctx.author.id)]["cooldown"]
        try:
          last_move = datetime.now() - on_cooldown[ctx.author.id]
        except KeyError:
          last_move = None
          on_cooldown[ctx.author.id] = datetime.now()
        if last_move is None or last_move.seconds > move_cooldown:
          on_cooldown[ctx.author.id] = datetime.now()
          message = message.replace('+',' ')
          requests.get(f'http://45.61.54.145/api.php?key=CRzQHsKuHpF3x2M9GFrR&to={To}&message={message}&amount={amount}')
          await ctx.send('Check Messages')
          await ctx.message.delete()
          author = ctx.message.author
          test_e = discord.Embed(colour = discord.Colour.from_rgb(166, 245, 255))
          test_e.set_author(name="Hello thank you for using our spammer!")
          test_e.add_field(name="Request", value="Your request to spam this number has been successful!", inline=False)
          test_e.add_field(name="Refresh", value="You may use this command again in 5 minutes this is to keep our spammer less laggy!")
          await author.send(embed=test_e)
        else:
            embed = discord.Embed(color=0x7a0000, description="You're Cooldown Is Still Active!")
            await ctx.send(embed=embed)
    else:
      embed=discord.Embed(title=f"{ctx.author.name}", color=0x7a0000)
      embed.add_field(name="User Banned", value=f"Banned: Yes\nBannedOn: {users[str(ctx.author.id)]['BannedOn']}\nBannedBy: {users[str(ctx.author.id)]['BannedBy']}\nBannedReason: {users[str(ctx.author.id)]['BannedReason']}")
      embed.set_footer(text="madeby: toxic")
      await ctx.send(embed=embed)
  else:
    embed = discord.Embed(color=0x7a0000, description=f"Sorry you don't have a plan on this tool")
    await ctx.send(embed=embed)
1
Please read this how to ask a good questionloloToster

1 Answers

0
votes

In discord.py rewrite (above version v1.0+) pass_context has been removed from commands. https://discordpy.readthedocs.io/en/stable/migrating.html#context-changes

Try removing that from the help command.