0
0
0PinguiDev92021-09-23 17:57:03
Python
0PinguiDev9, 2021-09-23 17:57:03

I took the clear command from a random site, and the command clears the entire channel, why?

I took the 'clear' command code from the website random, I tested it, and the whole channel was cleared

@bot.command()
async def clear(ctx, amount=None):
    await ctx.channel.purge(limit=int(500))
    await ctx.channel.send(':: Сообщения успешно удалены')

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Telmor, 2021-09-23
@0PinguiDev9

Line Change to:
await ctx.channel.purge(limit=int(500))

await ctx.channel.purge(limit = 1) # для удаления сообщения которое вызывает команду
deleted = await ctx.message.channel.purge(limit=amount) #само удаление сообщений.

A
Alexander Nesterov, 2021-09-23
@AlexNest

cleared the whole channel

Not news, but the last 500 messages.
If you understand at least a little the syntax of python (which I'm not particularly sure of because of the question), how to do it the way you need it - you will understand.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question