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 :: declare empty var python 
Python :: python print n numbers 
Python :: add new row to dataframe pandas 
Python :: online python 
Python :: find frequency of numbers in list python 
Python :: pandas today date 
Python :: append extend python 
Python :: python package for confluence 
Python :: how to stop all pygame mixer sound 
Python :: number of spaes pythopn 
Python :: merge multiple excel files with multiple worksheets into a single dataframe 
Python :: iterating through a list in python 
Python :: count specific instances in a columb in pandas 
Python :: astype python 
Python :: media pipe install ERROR: Could not find a version that satisfies the requirement mediapipe (from versions: none) 
Python :: python circular import 
Python :: how to show a progress spinner when python script is running 
Python :: python string cut first n characters 
Python :: pandas convert string column to int list column 
Python :: django serve media folder 
Python :: how to get first element of array in python 
Python :: how to make every letter capital in python 
Python :: multiple bars barchart matplotlib 
Python :: python variable is not none 
Python :: accessing items of tuple in python 
Python :: add reaction discord.py 
Python :: append to pythonpath 
Python :: enumarate in python 
Python :: .split python 
Python :: python run code at the same time 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =