How can I make my Discord Bot delete all messages in a channel?

Paradoxian

I am trying to make my bot delete all messages at once when a user asks the bot to do so, but my code isn't working.

import os
import discord

client = discord.Client()
client = commands.Bot(command_prefix='+')
@client.command(name='effacer')

async def purge(ctx):
    async for msg in client.logs_from(ctx.message.channel):
        await client.delete_messages(msg)
    await ctx.send("Who am I? What is this place? And where the hell did the messages go?")

client.run(TOKEN)

How can I fix my code so that my bot can delete all messages? I believe my biggest problem is await client.delete_messages(msg), since Python continuously says that the client has no attribute to delete_messages.

Cohen

By deleting every message would rate limit the bot, creating performance issues which would also slow down the bot. Instead it would be more efficient if the bot just deleted the channel and made a clone of it in the exact same place.

Here's the purge included in your command

@client.command(name='effacer')
async def purge(ctx):
        await ctx.channel.delete()
        new_channel = await ctx.channel.clone(reason="Channel was purged")
        await new_channel.edit(position=ctx.channel.position)
        await new_channel.send("Channel was purged")

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I make my Discord Bot delete all messages in a channel?

From Dev

How do i delete the previous messages that my discord bot sent in a specific channel?

From Dev

how can i make my discord.py bot send a message i choose to a channel i choose?

From Dev

How can I make my Discord bot respond to mentions?

From Dev

How can I make my "say" command delete the command message, while keeping the bot's message? (discord.py)

From Dev

How do I make my c# Discord Bot notify my server when I upload a YouTube video to my channel

From Dev

How can make my Python Discord bot I check if a message was sent by the bot itself?

From Dev

How can I quickly delete multiple messages at once in Discord?

From Dev

How can I make my discord bot respond with a "follow up" message

From Dev

(discord.py) How can I make my bot randomly reply to DMs?

From Dev

How can I make the bot code independent of the channel,( I want a single bot code for facebook at work and DirectLine)

From Java

How can I delete all messages from an Apache Pulsar topic?

From Dev

Programming a Discord bot in Python- How do I make it automatically send messages?

From Dev

How do I make my Discord Bot make a message right after it's launched?

From Java

How can I get a list of all the messages in a channel and then pick a random message from that list to send as a message?

From Dev

How can I implement a !leaveguild <guildID> command (that leaves the specified guild) into my Discord (discord.js) bot?

From Dev

Discord Bot: How would I make this work?

From Java

How can I delete all of my Git stashes at once?

From Dev

How can I delete all .LNK files on my Ubuntu machine?

From Dev

How can I delete all .LNK files on my Ubuntu machine?

From Dev

How can I delete all my core files cleanly?

From Dev

How can I delete all Panels from my calendar?

From Dev

Programming a Discord bot in Python- How would I make it so my mute command is timed?

From Dev

when i tried to make my discord bot it gave me this error

From Dev

How can I make a list of all dataframes that are in my global environment?

From Dev

How can I make a prototype function to all my object properties?

From Dev

How can I make all my processes start with niceness 5

From Dev

How can i make my jQuery code work on all elements

From Dev

How can I make my form responsive on all sizes

Related Related

  1. 1

    How can I make my Discord Bot delete all messages in a channel?

  2. 2

    How do i delete the previous messages that my discord bot sent in a specific channel?

  3. 3

    how can i make my discord.py bot send a message i choose to a channel i choose?

  4. 4

    How can I make my Discord bot respond to mentions?

  5. 5

    How can I make my "say" command delete the command message, while keeping the bot's message? (discord.py)

  6. 6

    How do I make my c# Discord Bot notify my server when I upload a YouTube video to my channel

  7. 7

    How can make my Python Discord bot I check if a message was sent by the bot itself?

  8. 8

    How can I quickly delete multiple messages at once in Discord?

  9. 9

    How can I make my discord bot respond with a "follow up" message

  10. 10

    (discord.py) How can I make my bot randomly reply to DMs?

  11. 11

    How can I make the bot code independent of the channel,( I want a single bot code for facebook at work and DirectLine)

  12. 12

    How can I delete all messages from an Apache Pulsar topic?

  13. 13

    Programming a Discord bot in Python- How do I make it automatically send messages?

  14. 14

    How do I make my Discord Bot make a message right after it's launched?

  15. 15

    How can I get a list of all the messages in a channel and then pick a random message from that list to send as a message?

  16. 16

    How can I implement a !leaveguild <guildID> command (that leaves the specified guild) into my Discord (discord.js) bot?

  17. 17

    Discord Bot: How would I make this work?

  18. 18

    How can I delete all of my Git stashes at once?

  19. 19

    How can I delete all .LNK files on my Ubuntu machine?

  20. 20

    How can I delete all .LNK files on my Ubuntu machine?

  21. 21

    How can I delete all my core files cleanly?

  22. 22

    How can I delete all Panels from my calendar?

  23. 23

    Programming a Discord bot in Python- How would I make it so my mute command is timed?

  24. 24

    when i tried to make my discord bot it gave me this error

  25. 25

    How can I make a list of all dataframes that are in my global environment?

  26. 26

    How can I make a prototype function to all my object properties?

  27. 27

    How can I make all my processes start with niceness 5

  28. 28

    How can i make my jQuery code work on all elements

  29. 29

    How can I make my form responsive on all sizes

HotTag

Archive