✨ bulk delete messages
This commit is contained in:
parent
cec426cd8d
commit
7e50c11d66
|
@ -2,8 +2,15 @@ import asyncio
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord import TextChannel, PermissionOverwrite
|
from discord import TextChannel, PermissionOverwrite, Message
|
||||||
from discord.ext.commands import command, has_role, Bot, Cog, ExtensionNotLoaded
|
from discord.ext.commands import (
|
||||||
|
command,
|
||||||
|
has_role,
|
||||||
|
Bot,
|
||||||
|
Cog,
|
||||||
|
ExtensionNotLoaded,
|
||||||
|
Context,
|
||||||
|
)
|
||||||
from discord.utils import get
|
from discord.utils import get
|
||||||
from ptpython.repl import embed
|
from ptpython.repl import embed
|
||||||
|
|
||||||
|
@ -182,6 +189,19 @@ class DevCog(Cog, name="Dev tools"):
|
||||||
await ctx.message.delete()
|
await ctx.message.delete()
|
||||||
await ctx.send(" ".join(msg))
|
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):
|
def setup(bot: CustomBot):
|
||||||
bot.add_cog(DevCog(bot))
|
bot.add_cog(DevCog(bot))
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
#!/bin/python
|
#!/bin/python
|
||||||
|
|
||||||
from src.constants import *
|
from src.constants import *
|
||||||
|
from src.core import CustomBot
|
||||||
|
|
||||||
# We allow "! " to catch people that put a space in their commands.
|
# 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
|
# It must be in first otherwise "!" always match first and the space is not recognised
|
||||||
from src.core import CustomBot
|
|
||||||
|
|
||||||
bot = CustomBot(("! ", "!"))
|
bot = CustomBot(("! ", "!"))
|
||||||
|
|
||||||
# Global variable to hold the tirages.
|
# Global variable to hold the tirages.
|
||||||
|
|
Loading…
Reference in New Issue