WIP: Refactor Aurora (3.0.0) #29

Draft
cswimr wants to merge 347 commits from aurora-pydantic into main
Showing only changes of commit 9faf1b027c - Show all commits

View file

@ -73,14 +73,14 @@ class Kick(Type):
if silent is False: if silent is False:
try: try:
embed = await message_factory( embed = await message_factory(
bot, bot=bot,
await bot.get_embed_color(ctx.channel), color=await bot.get_embed_color(ctx.channel),
ctx.guild, guild=ctx.guild,
reason, reason=reason,
cls(), moderation_type=cls(),
ctx.author, moderator=ctx.author,
None, duration=None,
response_message response=response_message
) )
await target.send(embed=embed, file=get_icon(bot)) await target.send(embed=embed, file=get_icon(bot))
except HTTPException: except HTTPException:
@ -88,15 +88,15 @@ class Kick(Type):
await target.kick(reason=f"{str.title(cls.verb)} by {ctx.author.id} for: {reason}") await target.kick(reason=f"{str.title(cls.verb)} by {ctx.author.id} for: {reason}")
moderation = await Moderation.log( moderation = await Moderation.log(
bot, bot=bot,
ctx.guild.id, guild_id=ctx.guild.id,
ctx.author.id, moderator_id=ctx.author.id,
cls(), moderation_type=cls(),
'user', target_type='user',
target.id, target_id=target.id,
None, role_id=None,
None, duration=None,
reason reason=reason
) )
await response_message.edit(content=f"{target.mention} has been {cls.verb}! (Case {inline(f'#{moderation.id}')})\n{bold('Reason:')} {inline(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 log(ctx, moderation.id)
@ -128,14 +128,14 @@ class Ban(Type):
if silent is False: if silent is False:
try: try:
embed = await message_factory( embed = await message_factory(
bot, bot=bot,
await bot.get_embed_color(ctx.channel), color=await bot.get_embed_color(ctx.channel),
ctx.guild, guild=ctx.guild,
reason, reason=reason,
cls(), moderation_type=cls(),
ctx.author, moderator=ctx.author,
None, duration=None,
response_message response=response_message
) )
await target.send(embed=embed, file=get_icon(bot)) await target.send(embed=embed, file=get_icon(bot))
except HTTPException: except HTTPException:
@ -143,15 +143,15 @@ class Ban(Type):
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.ban(target, reason=f"{str.title(cls.verb)} by {ctx.author.id} for: {reason}", delete_message_seconds=delete_messages_seconds)
moderation = await Moderation.log( moderation = await Moderation.log(
bot, bot=bot,
ctx.guild.id, guild_id=ctx.guild.id,
ctx.author.id, moderator_id=ctx.author.id,
cls(), moderation_type=cls(),
'user', target_type='user',
target.id, target_id=target.id,
None, role_id=None,
None, duration=None,
reason reason=reason
) )
await response_message.edit(content=f"{target.mention} has been {cls.verb}! (Case {inline(f'#{moderation.id}')})\n{bold('Reason:')} {inline(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 log(ctx, moderation.id)
@ -168,14 +168,14 @@ class Ban(Type):
try: try:
embed = await message_factory( embed = await message_factory(
bot, bot=bot,
await bot.get_embed_color(guild.channels[0]), color=await bot.get_embed_color(guild.channels[0]),
guild, guild=guild,
reason, reason=reason,
'unban', moderation_type=Unban(),
None, moderator=None,
None, duration=None,
None response=None
) )
await target.send(embed=embed, file=get_icon(bot)) await target.send(embed=embed, file=get_icon(bot))
except HTTPException: except HTTPException:
@ -215,14 +215,14 @@ class Tempban(Ban):
if silent is False: if silent is False:
try: try:
embed = await message_factory( embed = await message_factory(
bot, bot=bot,
await bot.get_embed_color(ctx.channel), color=await bot.get_embed_color(ctx.channel),
ctx.guild, guild=ctx.guild,
reason, reason=reason,
cls(), moderation_type=cls(),
ctx.author, moderator=ctx.author,
parsed_time, duration=parsed_time,
response_message response=response_message
) )
await target.send(embed=embed, file=get_icon(bot)) await target.send(embed=embed, file=get_icon(bot))
except HTTPException: except HTTPException:
@ -230,15 +230,15 @@ class Tempban(Ban):
await ctx.guild.ban(target, reason=f"{str.title(cls.verb)} by {ctx.author.id} for: {reason} (Duration: {parsed_time})", delete_message_seconds=delete_messages_seconds) await ctx.guild.ban(target, reason=f"{str.title(cls.verb)} by {ctx.author.id} for: {reason} (Duration: {parsed_time})", delete_message_seconds=delete_messages_seconds)
moderation = await Moderation.log( moderation = await Moderation.log(
bot, bot=bot,
ctx.guild.id, guild_id=ctx.guild.id,
ctx.author.id, moderator_id=ctx.author.id,
cls(), moderation_type=cls(),
'user', target_type='user',
target.id, target_id=target.id,
None, role_id=None,
parsed_time, duration=parsed_time,
reason reason=reason
) )
await response_message.edit(content=f"{target.mention} has been {cls.verb} for {humanize_timedelta(parsed_time)}! (Case {inline(f'#{moderation.id}')})\n{bold('Reason:')} {inline(reason)}") await response_message.edit(content=f"{target.mention} has been {cls.verb} for {humanize_timedelta(parsed_time)}! (Case {inline(f'#{moderation.id}')})\n{bold('Reason:')} {inline(reason)}")
await log(ctx, moderation.id) await log(ctx, moderation.id)
@ -271,14 +271,14 @@ class Softban(Type):
if silent is False: if silent is False:
try: try:
embed = await message_factory( embed = await message_factory(
bot, bot=bot,
await bot.get_embed_color(ctx.channel), color=await bot.get_embed_color(ctx.channel),
ctx.guild, guild=ctx.guild,
reason, reason=reason,
cls(), moderation_type=cls(),
ctx.author, moderator=ctx.author,
None, duration=None,
response_message response=response_message
) )
await target.send(embed=embed, file=get_icon(bot)) await target.send(embed=embed, file=get_icon(bot))
except HTTPException: except HTTPException:
@ -287,15 +287,15 @@ class Softban(Type):
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.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"{str.title(cls.verb)} by {ctx.author.id} for: {reason}") await ctx.guild.unban(target, reason=f"{str.title(cls.verb)} by {ctx.author.id} for: {reason}")
moderation = await Moderation.log( moderation = await Moderation.log(
bot, bot=bot,
ctx.guild.id, guild_id=ctx.guild.id,
ctx.author.id, moderator_id=ctx.author.id,
cls(), moderation_type=cls(),
'user', target_type='user',
target.id, target_id=target.id,
None, role_id=None,
None, duration=None,
reason reason=reason
) )
await response_message.edit(content=f"{target.mention} has been {cls.verb}! (Case {inline(f'#{moderation.id}')})\n{bold('Reason:')} {inline(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 log(ctx, moderation.id)
@ -323,14 +323,14 @@ class Unban(Type):
if silent is False: if silent is False:
try: try:
embed = await message_factory( embed = await message_factory(
bot, bot=bot,
await bot.get_embed_color(ctx.channel), color=await bot.get_embed_color(ctx.channel),
ctx.guild, guild=ctx.guild,
reason, reason=reason,
cls(), moderation_type=cls(),
ctx.author, moderator=ctx.author,
None, duration=None,
response_message response=response_message
) )
await target.send(embed=embed, file=get_icon(bot)) await target.send(embed=embed, file=get_icon(bot))
except HTTPException: except HTTPException:
@ -338,15 +338,15 @@ class Unban(Type):
await ctx.guild.unban(target, reason=f"{str.title(cls.verb)} by {ctx.author.id} for: {reason}") await ctx.guild.unban(target, reason=f"{str.title(cls.verb)} by {ctx.author.id} for: {reason}")
moderation = await Moderation.log( moderation = await Moderation.log(
bot, bot=bot,
ctx.guild.id, guild_id=ctx.guild.id,
ctx.author.id, moderator_id=ctx.author.id,
cls(), moderation_type=cls(),
'user', target_type='user',
target.id, target_id=target.id,
None, role_id=None,
None, duration=None,
reason reason=reason
) )
await response_message.edit(content=f"{target.mention} has been {cls.verb}! (Case {inline(f'#{moderation.id}')})\n{bold('Reason:')} {inline(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 log(ctx, moderation.id)
@ -379,15 +379,15 @@ class Slowmode(Type):
if isinstance(target, TextChannel): if isinstance(target, TextChannel):
await target.edit(slowmode_delay=ceil(parsed_time.total_seconds())) await target.edit(slowmode_delay=ceil(parsed_time.total_seconds()))
moderation = await Moderation.log( moderation = await Moderation.log(
bot, bot=bot,
ctx.guild.id, guild_id=ctx.guild.id,
ctx.author.id, moderator_id=ctx.author.id,
cls(), moderation_type=cls(),
'channel', target_type='channel',
target.id, target_id=target.id,
None, role_id=None,
parsed_time, duration=parsed_time,
None reason=None
) )
await ctx.send(f"{ctx.author.mention} has {cls.verb} {target.mention} to {humanize_timedelta(parsed_time)}!\n{bold('Reason:')} {inline(reason)}") await ctx.send(f"{ctx.author.mention} has {cls.verb} {target.mention} to {humanize_timedelta(parsed_time)}!\n{bold('Reason:')} {inline(reason)}")
await log(ctx, moderation.id) await log(ctx, moderation.id)