Reputation: 53
(new to stack overflow) Im trying to make it so when I type $clear 5 in my discord it will clear the last 5 rows but I have no idea how to get the limit to = whatever I put in after the $clear. I would love it if anyone could help (sorry if I've done this wrong)
if message.content.startswith('$clear '):
message.content.split('$clear ',1)[1].lower()
await message.channel.purge(limit=[1])
Upvotes: 0
Views: 470
Reputation: 239
This is what I came up with:
if message.content.startswith("$clear "):
limit_amount = int(message.content.split("$clear ")[1])
await message.channel.purge(limit = limit_amount)
Basically you should be storing the value that you get from splitting the message content, also assuming that the user inputs the command correctly, the limit value should be the first index, so that's why I use 1 there. You also need to turn the string value from splitting into an integer in order to pass it as a valid limit argument.
Upvotes: 1