DISCORD PURGE COMMAND help

Status
This thread has been locked.

FelixDev

Typical Developer and Designer
Premium
Feedback score
9
Posts
1,112
Reactions
331
Resources
0
Code:
ReferenceError: args is not defined
    at Client.bot.on.message (C:\Users\Felix\Desktop\DISCORD BOT\app.js:65:36)
    at emitOne (events.js:121:20)
    at Client.emit (events.js:211:7)
    at MessageCreateHandler.handle (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
    at WebSocketPacketManager.handle (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65)
    at WebSocketConnection.onPacket (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
    at WebSocketConnection.onMessage (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
    at WebSocket.onMessage (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\ws\lib\event-target.js:120:16)
    at emitOne (events.js:116:13)
    at WebSocket.emit (events.js:211:7)
got this error and here is my code, I understand that I need to define args but I do not understand how to really. I've been trying to figure something out for 1 hour now xD Im learning dont hate <333
CODE -
Code:
  });
  bot.on('message', message => {
    if(message.content.toLowerCase() === prefix + 'purge') {
      const deleteCount = parseInt(args[0], 10);

      if(!deleteCount || deleteCount < 2 || deleteCount > 100)
        return message.reply('please provide a number between 2 and 100 for the number of messages to delete');
      const fetched = message.channel.fetchMessage({limit: deleteCount});
      message.channel.bulkDelete(fetched)
          .catch(error => message.reply('Couldent delete messages bc of : ${error}'));
    }

  });
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

FelixDev

Typical Developer and Designer
Premium
Feedback score
9
Posts
1,112
Reactions
331
Resources
0
FIXED
 

alice

Supreme
Feedback score
24
Posts
310
Reactions
178
Resources
0
You can do this in Python in 3 lines of code, and it's far more readable and maintainable than whatever you're doing now.
Code:
@commands.command()
async def purge(self, ctx, messages: int):
    await ctx.channel.purge(limit=messages)
 
Status
This thread has been locked.
Top