WIP: Refactor Aurora (3.0.0) #29
1 changed files with 19 additions and 18 deletions
|
@ -7,7 +7,6 @@ from typing import Dict, Iterable, List, Optional, Tuple, Union
|
|||
import discord
|
||||
from aiosqlite import Connection, Cursor, OperationalError, Row
|
||||
from aiosqlite import connect as aiosqlite_connect
|
||||
from discord import NotFound
|
||||
from redbot.core import data_manager
|
||||
from redbot.core.bot import Red
|
||||
|
||||
|
@ -82,26 +81,28 @@ class Moderation(AuroraGuildModel):
|
|||
self.resolved_by = resolved_by
|
||||
self.resolve_reason = reason
|
||||
|
||||
if self.type in ["UNMUTE", "UNBAN"]:
|
||||
raise TypeError("Cannot resolve an unmute or unban case!")
|
||||
await self.type.resolve_handler(self.bot, self.guild, await self.get_target(), reason)
|
||||
|
||||
if self.type == "MUTE":
|
||||
try:
|
||||
guild: discord.Guild = await self.bot.fetch_guild(self.guild_id)
|
||||
member = await guild.fetch_member(self.target_id)
|
||||
# if self.type in ["UNMUTE", "UNBAN"]:
|
||||
# raise TypeError("Cannot resolve an unmute or unban case!")
|
||||
|
||||
await member.timeout(
|
||||
None, reason=f"Case {self.moderation_id} resolved by {resolved_by}{' for '+ reason if reason else ''}"
|
||||
)
|
||||
except NotFound:
|
||||
pass
|
||||
# if self.type == "MUTE":
|
||||
# try:
|
||||
# guild: discord.Guild = await self.bot.fetch_guild(self.guild_id)
|
||||
# member = await guild.fetch_member(self.target_id)
|
||||
|
||||
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
|
||||
# await member.timeout(
|
||||
# None, reason=f"Case {self.moderation_id} resolved by {resolved_by}{' for '+ reason if reason else ''}"
|
||||
# )
|
||||
# except NotFound:
|
||||
# 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:
|
||||
self.changes.append(Change.from_dict(self.bot, {
|
||||
|
|
Loading…
Reference in a new issue