diff --git a/bot.py b/bot.py index 53c5a6b..59c9eb6 100644 --- a/bot.py +++ b/bot.py @@ -1356,6 +1356,52 @@ async def mute(ctx, member: discord.Member, *, reason=None): ) +@bot.slash_command( + guild_only=True, + name="bulkdelete", + description="Removes all messages from a user in a channel", +) +@discord.default_permissions(manage_messages=True, ) +async def bulkdelete(ctx, channel: discord.TextChannel, member: discord.Member, *, reason=None): + await SendMetric("builkdelete") + guild = ctx.guild + + if reason == None: + reason = await GetTranslatedText(ctx.guild.id, + "punishment_default_reason") + + + await ctx.defer() + msgcount = 0 + try: + # delete msg on channel from user + async for message in channel.history(): + if message.author == member: + msgcount+=1 + await message.delete() + except Exception as e: + await ctx.respond( + embed=ErrorEmbed(await GetTranslatedText(ctx.guild.id, "error_no_permission")), + ephemeral=True, + ) + return + + embed = discord.Embed( + title=await GetTranslatedText(ctx.guild.id, + "bulkdelete_title", + CHANNEL=channel, + MEMBER=filterMember(member)), + description=await GetTranslatedText(ctx.guild.id, + "bulkdelete_description", + CHANNEL=channel, + AMOUNT=msgcount, + MEMBER=filterMember(member), + REASON=reason), + colour=discord.Colour.red(), + ) + await ctx.respond(embed=embed) + + # description="Unmutes a specified user." @bot.slash_command( guild_only=True, diff --git a/langs/cat.json b/langs/cat.json index 7ce7b3c..485dbfe 100644 --- a/langs/cat.json +++ b/langs/cat.json @@ -16,6 +16,7 @@ "footer_executed_by": "Hammer | Comanda executada per {USERNAME}", "hello_command": "El Hammer ha tornat!", "error_deliver_msg": "No s'ha pogut lliurar el missatge a l'usuari {USERNAME}\n Això pot ser a causa que l'usuari sigui un bot, hagi bloquejat el bot o hagi desactivat els missatges directes. \n\n**Però l'usuari ha estat advertit** i s'ha guardat a la meva inoblidable base de dades.", + "error_no_permission": "No tinc els permisos suficients per fer això :( :hammer:", "automod_warn_title": "{USERNAME} ha estat advertit! :hammer_pick:", "automod_warn_description": "L'usuari {USERNAME} ha estat advertit perquè ha dit una paraula obscena prohibida", "automod_warn_footer": "Hammer | Servei d'AutoMod", @@ -68,6 +69,8 @@ "setdelay_title": "Retard {M} a #{CHANNEL} :hammer_pick:", "for": "per ", "setdelay_description": "Aquest canal té ara un retard de **{SECONDS}** segons {REASON}", + "bulkdelete_title": "Eliminació massiva a #{CHANNEL} de @{MEMBER} :hammer_pick:", + "bulkdelete_description": "Tots els missatges de l'usuari @{MEMBER} han estat eliminats, hi havien {AMOUNT} missatges al canal #{CHANNEL}", "mute_title": "Usuari Silenciat: {MEMBER}", "mute_description": "L'usuari {MENTION} ha estat silenciat per {REASON}", "mute_msg": ":no_entry: Has estat silenciat de: {GUILD} per {REASON}", diff --git a/langs/en.json b/langs/en.json index 52d62d0..2e84f7e 100644 --- a/langs/en.json +++ b/langs/en.json @@ -16,6 +16,7 @@ "footer_executed_by": "Hammer | Command executed by {USERNAME}", "hello_command": "Hammer is back!", "error_deliver_msg": "Could not deliver the message to the user {USERNAME}\n This may be caused because the user is a bot, has blocked me or has the DMs turned off. \n\n**But the user is warned** and I have saved it into my beautiful unforgettable database", + "error_no_permission": "I don't have enough permission to do that :( :hammer:", "automod_warn_title": "{USERNAME} has been warned! :hammer_pick:", "automod_warn_description": "The user {USERNAME} has been warned because said a banned swear word", "automod_warn_footer": "Hammer | Automod service", @@ -68,6 +69,8 @@ "setdelay_title": "Delay {M} on #{CHANNEL} :hammer_pick:", "for": "for ", "setdelay_description": "This channel now has a delay of **{SECONDS}** seconds {REASON}", + "bulkdelete_title": "Bulk delete in #{CHANNEL} of @{MEMBER} :hammer_pick:", + "bulkdelete_description": "All messages from user @{MEMBER} have been deleted, there were {AMOUNT} messages in the channel #{CHANNEL}", "mute_title": "User Muted: {MEMBER}", "mute_description": "User {MENTION} has been muted for {REASON}", "mute_msg": ":no_entry: You have been muted from: {GUILD} for {REASON}", diff --git a/langs/es.json b/langs/es.json index e7bc166..5625af0 100644 --- a/langs/es.json +++ b/langs/es.json @@ -16,6 +16,7 @@ "footer_executed_by": "Hammer | Comando ejecutado por {USERNAME}", "hello_command": "¡Hammer ha vuelto!", "error_deliver_msg": "No se pudo entregar el mensaje al usuario {USERNAME}\n Esto puede deberse a que el usuario es un bot, me ha bloqueado o ha desactivado los MD. \n\n**Pero el usuario ha sido advertido** y lo he guardado en mi inolvidable y hermosa base de datos", + "error_no_permission": "No tengo suficientes permisos para hacer eso :( :hammer:", "automod_warn_title": "¡{USERNAME} ha sido advertido! :hammer_pick:", "automod_warn_description": "El usuario {USERNAME} ha sido advertido por haber dicho una palabra prohibida", "automod_warn_footer": "Hammer | Servicio de AutoMod", @@ -68,6 +69,8 @@ "setdelay_title": "Retraso {M} en #{CHANNEL} :hammer_pick:", "for": "por ", "setdelay_description": "Este canal ahora tiene un retraso de **{SECONDS}** segundos por {REASON}", + "bulkdelete_title": "Eliminación masiva en #{CHANNEL} de @{MEMBER} :hammer_pick:", + "bulkdelete_description": "Todos los mensajes del usuario @{MEMBER} han sido eliminados, había {AMOUNT} mensajes en el canal #{CHANNEL}", "mute_title": "Usuario Silenciado: {MEMBER}", "mute_description": "El usuario {MENTION} ha sido silenciado por {REASON}", "mute_msg": ":no_entry: Has sido silenciado de: {GUILD} por {REASON}", diff --git a/tests.py b/tests.py index 1aab2f2..b0b0865 100644 --- a/tests.py +++ b/tests.py @@ -84,6 +84,9 @@ def jsonToDict(filename): "modified", "removed", "setdelay_title", + "bulkdelete_title", + "bulkdelete_description", + "error_no_permission", "for", "setdelay_description", "mute_title",