Compare commits

..

2 commits

Author SHA1 Message Date
54ac77ceb9
fix(aurora): fix `__str__() method of the Type` class
Some checks failed
Actions / Build Documentation (MkDocs) (pull_request) Failing after 26s
Actions / Lint Code (Ruff & Pylint) (pull_request) Failing after 39s
2024-07-06 12:16:15 -04:00
b85932c338
feat(aurora): use resolve handlers 2024-07-06 12:15:39 -04:00
2 changed files with 20 additions and 19 deletions

View file

@ -7,7 +7,6 @@ from typing import Dict, Iterable, List, Optional, Tuple, Union
import discord import discord
from aiosqlite import Connection, Cursor, OperationalError, Row from aiosqlite import Connection, Cursor, OperationalError, Row
from aiosqlite import connect as aiosqlite_connect from aiosqlite import connect as aiosqlite_connect
from discord import NotFound
from redbot.core import data_manager from redbot.core import data_manager
from redbot.core.bot import Red from redbot.core.bot import Red
@ -82,26 +81,28 @@ class Moderation(AuroraGuildModel):
self.resolved_by = resolved_by self.resolved_by = resolved_by
self.resolve_reason = reason self.resolve_reason = reason
if self.type in ["UNMUTE", "UNBAN"]: await self.type.resolve_handler(self.bot, self.guild, await self.get_target(), reason)
raise TypeError("Cannot resolve an unmute or unban case!")
if self.type == "MUTE": # if self.type in ["UNMUTE", "UNBAN"]:
try: # raise TypeError("Cannot resolve an unmute or unban case!")
guild: discord.Guild = await self.bot.fetch_guild(self.guild_id)
member = await guild.fetch_member(self.target_id)
await member.timeout( # if self.type == "MUTE":
None, reason=f"Case {self.moderation_id} resolved by {resolved_by}{' for '+ reason if reason else ''}" # try:
) # guild: discord.Guild = await self.bot.fetch_guild(self.guild_id)
except NotFound: # member = await guild.fetch_member(self.target_id)
pass
if self.type in ["BAN", "TEMPBAN"]: # await member.timeout(
try: # None, reason=f"Case {self.moderation_id} resolved by {resolved_by}{' for '+ reason if reason else ''}"
guild: discord.Guild = await self.bot.fetch_guild(self.guild_id) # )
await guild.unban(await self.get_target(), reason=f"Case {self.moderation_id} resolved by {resolved_by}{' for '+ reason if reason else ''}") # except NotFound:
except NotFound: # pass
pass
# if self.type in ["BAN", "TEMPBAN"]:
# try:
# guild: discord.Guild = await self.bot.fetch_guild(self.guild_id)
# await guild.unban(await self.get_target(), reason=f"Case {self.moderation_id} resolved by {resolved_by}{' for '+ reason if reason else ''}")
# except NotFound:
# pass
if not self.changes: if not self.changes:
self.changes.append(Change.from_dict(self.bot, { self.changes.append(Change.from_dict(self.bot, {

View file

@ -12,7 +12,7 @@ class Type(object):
embed_desc = "been" embed_desc = "been"
def __str__(self) -> str: def __str__(self) -> str:
return self.type return self.moderation_type
@classmethod @classmethod
async def handler(cls, ctx: commands.Context, target: Member | User, silent: bool, **kwargs) -> 'Type': # pylint: disable=unused-argument async def handler(cls, ctx: commands.Context, target: Member | User, silent: bool, **kwargs) -> 'Type': # pylint: disable=unused-argument