Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to make a discord bot delete messages python

import discord 
 
@client.event 
async def on_message(message):
  	response = await message.channel.send("Hello") 
    # Deletes the message the user sent
	await message.delete() 
    # Deletes the responding message
	await response.delete() 
Comment

discord bot python delete messages like mee6

  async def on_message(self,message):
    	channel = bot.get_channel(channel_id)
        if message.content.startswith("!clear",):
            messages = await channel.history(limit=anynumber).flatten()
            for m in messages:
                msg = await channel.fetch_message(m.id)
                await msg.delete()
            print("done!")
Comment

delete all messages discord.py

import discord
from discord.ext import commands

client = commands.Bot(command_prefix = ".")

@client.command()
async def clear(ctx):
  await ctx.channel.purge()#deletes all messages
Comment

PREVIOUS NEXT
Code Example
::  
::  
::  
Python ::  
::  
::  
::  
::  
::  
::  
Python ::  
::  
::  
Javascript :: jquery get second td of tr 
::  
Javascript ::  
::  
::  
:: js extract only numbers from string 
::  
::  
::  
::  
::  
Javascript ::  
::  
::  
::  
::  
::  
ADD CONTENT
Topic
Content
Source link
Name
4+3 =