Как сделать, чтоб сообщения удалялись? (Discord, Python)

import discord
from discord.ext import commands
import datetime
from pymongo import MongoClient
import time

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


@client.event
async def on_ready():
    print('Бот готов')


# выдача обычной роли
@client.event
async def on_member_join(member):
    standart_channel = client.get_channel(912753884068479029)
    standart_role = discord.utils.get(member.guild.roles, id=912793481162928208)

    await member.add_roles(standart_role)


#######################################################################


# !clear
@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def clear(ctx, amount=10000):
    await ctx.channel.purge(limit=amount + 1)


#######################################################################


# !kick
@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def kick(ctx, member: discord.Member, *, reason=None):
    await member.kick(reason=reason)
    await ctx.send(f'кикнут грешник по имени {member.mention}')


#######################################################################


# !ban
@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def ban(ctx, member: discord.Member, *, reason=None):
    await member.ban(reason=reason)
    await ctx.send(
        f'Забанен грешник по имени {member.mention}. Он больше не будет мучать наш сервер своими грязными делишками как минимум 7 дней')


#######################################################################


time_window_milliseconds = 5000
max_msg_per_window = 5
author_msg_times = {}


# Struct:
# {
#    "<author_id>": ["<msg_time", "<msg_time>", ...],
#    "<author_id>": ["<msg_time"],
# }

@client.event
async def on_message(ctx):
    global author_msg_counts

    author_id = ctx.author.id
    curr_time = datetime.datetime.now().timestamp() * 1000

    if not author_msg_times.get(author_id, False):
        author_msg_times[author_id] = []

    author_msg_times[author_id].append(curr_time)

    expr_time = curr_time - time_window_milliseconds

    expired_msgs = [
        msg_time for msg_time in author_msg_times[author_id]
        if msg_time < expr_time
    ]

    for msg_time in expired_msgs:
        author_msg_times[author_id].remove(msg_time)

    if len(author_msg_times[author_id]) > max_msg_per_window:

#здесь надо, чтоб все наспамленные сообщения удалялись

    await ctx.channel.send(f'Не спамь <@{author_id}>')


token = ''

client.run(token)

Ответы (0 шт):