diff --git a/src/cogs/dev.py b/src/cogs/dev.py index 2d6d096..ba1ae2b 100644 --- a/src/cogs/dev.py +++ b/src/cogs/dev.py @@ -2,8 +2,15 @@ import asyncio from pprint import pprint import discord -from discord import TextChannel, PermissionOverwrite -from discord.ext.commands import command, has_role, Bot, Cog, ExtensionNotLoaded +from discord import TextChannel, PermissionOverwrite, Message +from discord.ext.commands import ( + command, + has_role, + Bot, + Cog, + ExtensionNotLoaded, + Context, +) from discord.utils import get from ptpython.repl import embed @@ -182,6 +189,19 @@ class DevCog(Cog, name="Dev tools"): await ctx.message.delete() await ctx.send(" ".join(msg)) + @command(name="del") + @has_role(Role.CNO) + async def del_range_cmd(self, ctx: Context, id1: Message, id2: Message): + """ + (cno) Supprime les messages entre les deux IDs en argument. + """ + channel: TextChannel = id1.channel + to_delete = [ + message async for message in channel.history(before=id1, after=id2) + ] + [id1, id2] + await channel.delete_messages(to_delete) + await ctx.message.delete() + def setup(bot: CustomBot): bot.add_cog(DevCog(bot)) diff --git a/src/tfjm_discord_bot.py b/src/tfjm_discord_bot.py index c8a11a2..6d26380 100644 --- a/src/tfjm_discord_bot.py +++ b/src/tfjm_discord_bot.py @@ -1,12 +1,10 @@ #!/bin/python from src.constants import * - +from src.core import CustomBot # We allow "! " to catch people that put a space in their commands. # It must be in first otherwise "!" always match first and the space is not recognised -from src.core import CustomBot - bot = CustomBot(("! ", "!")) # Global variable to hold the tirages.