fix(aurora): add a softban type
Some checks failed
Actions / Build Documentation (MkDocs) (pull_request) Failing after 26s
Actions / Lint Code (Ruff & Pylint) (pull_request) Failing after 40s

This commit is contained in:
Seaswimmer 2024-07-06 13:10:09 -04:00
parent 8f0425456c
commit 37bae2eeb3
Signed by: cswimr
GPG key ID: 3813315477F26F82

View file

@ -245,6 +245,63 @@ class Tempban(Ban):
await send_evidenceformat(ctx, moderation.id)
return cls
@type_registry.register(key="softban")
class Softban(Type):
key="softban"
string="softban"
verb="softbanned"
@classmethod
async def handler(cls, ctx: commands.Context, target: Member | User, silent: bool, reason: str = None, delete_messages: app_commands.Choice | None = None) -> 'Softban':
"""Softban a user."""
bot = ctx.bot
try:
await ctx.guild.fetch_ban(target)
await ctx.send(content=error(f"{target.mention} is already {Ban.verb}!"), ephemeral=True)
except NotFound:
pass
if delete_messages is None:
delete_messages_seconds = 0
else:
delete_messages_seconds = delete_messages.value
response_message = await ctx.send(f"{target.mention} has been {cls.verb}!\n{bold('Reason:')} {inline(reason)}")
if silent is False:
try:
embed = await message_factory(
bot,
await bot.get_embed_color(ctx.channel),
ctx.guild,
reason,
cls(),
ctx.author,
None,
response_message
)
await target.send(embed=embed, file=get_icon(bot))
except HTTPException:
pass
await ctx.guild.ban(target, reason=f"{str.title(cls.verb)} by {ctx.author.id} for: {reason}", delete_message_seconds=delete_messages_seconds)
await ctx.guild.unban(target, reason=f"Softban by {ctx.author.id} for: {reason}")
moderation = await Moderation.log(
bot,
ctx.guild.id,
ctx.author.id,
cls(),
'user',
target.id,
None,
None,
reason
)
await response_message.edit(content=f"{target.mention} has been {cls.verb}! (Case {inline(f'#{moderation.id}')})\n{bold('Reason:')} {inline(reason)}")
await log(ctx, moderation.id)
await send_evidenceformat(ctx, moderation.id)
return cls
@type_registry.register(key="unban")
class Unban(Type):
key="unban"