mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 19:50:12 +01:00
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
|
|
"""
|
||
|
|
Copyright © Krypton 2019-Present - https://github.com/kkrypt0nn (https://krypton.ninja)
|
||
|
|
Description:
|
||
|
|
🐍 A simple template to start to code your own and personalized Discord bot in Python
|
||
|
|
|
||
|
|
Version: 6.4.0
|
||
|
|
"""
|
||
|
|
|
||
|
|
import discord
|
||
|
|
from discord import app_commands
|
||
|
|
from discord.ext import commands
|
||
|
|
from discord.ext.commands import Context
|
||
|
|
|
||
|
|
|
||
|
|
class Purge(commands.Cog, name="purge"):
|
||
|
|
def __init__(self, bot) -> None:
|
||
|
|
self.bot = bot
|
||
|
|
|
||
|
|
@commands.hybrid_command(
|
||
|
|
name="purge",
|
||
|
|
description="Delete a number of messages.",
|
||
|
|
)
|
||
|
|
@commands.has_guild_permissions(manage_messages=True)
|
||
|
|
@commands.bot_has_permissions(manage_messages=True)
|
||
|
|
@app_commands.describe(amount="The amount of messages that should be deleted.")
|
||
|
|
async def purge(self, context: Context, amount: int) -> None:
|
||
|
|
"""
|
||
|
|
Delete a number of messages.
|
||
|
|
|
||
|
|
:param context: The hybrid command context.
|
||
|
|
:param amount: The number of messages that should be deleted.
|
||
|
|
"""
|
||
|
|
await context.send("Deleting messages...")
|
||
|
|
purged_messages = await context.channel.purge(limit=amount + 1)
|
||
|
|
embed = discord.Embed(
|
||
|
|
description=f"**{context.author}** cleared **{len(purged_messages)-1}** messages!",
|
||
|
|
color=0xBEBEFE,
|
||
|
|
)
|
||
|
|
await context.channel.send(embed=embed)
|
||
|
|
|
||
|
|
|
||
|
|
async def setup(bot) -> None:
|
||
|
|
await bot.add_cog(Purge(bot))
|