How to delete message discord py

How to delete message discord py

How can I delete entire messages in a text channel in Discord with discord python library

I used a code from a asked question in stack overflow but the functions used in that seems to be changed.

Code :

Error:

async for x in client(ctx.message.channel, limit = number): TypeError: ‘Bot’ object is not callable

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: ‘Bot’ object is not callable

2 Answers 2

Trending sort

Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.

It falls back to sorting by highest score if no posts are trending.

Switch to Trending sort

A really easy way to do it in the new versions of discord.py would probably look something like this:

You could also use a regular command for this so you won’t need await client.process_commands(message) but the function you are after will still be await message.channel.purge(limit=amount, check=is_not_pinned) That way only people with the manage messages permission will be able to use this command and it will not deleted pinned messages.

You can set the amount to an incredible high number so it will just delete close to, if not everything. I only tried it for around 300 and it worked perfectly (may take some time though).

How to delete message in discord.py in python 3.10 (nothing else works)

I have tried anything in the internet and nothing works. My code:

I use python version 3.10

How to delete message discord py. Смотреть фото How to delete message discord py. Смотреть картинку How to delete message discord py. Картинка про How to delete message discord py. Фото How to delete message discord py

2 Answers 2

Trending sort

Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.

It falls back to sorting by highest score if no posts are trending.

Switch to Trending sort

If you want to delete a message the bot sent after x amount of time you can use the delete_after kwarg.

Simple delete command you can use. I added an if that checks if amount is more than 0 (because deleting 0 messages doesn’t make sense)

How to delete message discord py. Смотреть фото How to delete message discord py. Смотреть картинку How to delete message discord py. Картинка про How to delete message discord py. Фото How to delete message discord py

How to delete message discord py. Смотреть фото How to delete message discord py. Смотреть картинку How to delete message discord py. Картинка про How to delete message discord py. Фото How to delete message discord py

Not the answer you’re looking for? Browse other questions tagged python discord.py or ask your own question.

Related

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источники информации:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *