32 lines
1.0 KiB
Python

from discord.ext import commands
import discord
class Spam(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_message(self, message):
dump = []
print(len(dump))
print((dump[len(dump)-1].created_at - dump[1].created_at).total_seconds())
async for temp in message.channel.history(limit=5):
if temp.author == message.author:
dump.append(temp)
if (dump[len(dump)-1].created_at - dump[1].created_at).total_seconds() <= 2:
await message.delete()
await self.client.process_commands(message)
def setup(client):
client.add_cog(Spam(client))
""" async for tempMessage in message.channel.history(limit=5):
if tempMessage.id == message.id:
pass
elif tempMessage.author == message.author:
difference = message.created_at - tempMessage.created_at
if difference.total_seconds() <= 2:
await message.delete()"""