mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[Mod] Fixed loud RuntimeError on modlog cases (#2331)
This commit is contained in:
parent
351749dff6
commit
38b15ded87
@ -1570,8 +1570,9 @@ class Mod(commands.Cog):
|
|||||||
"""
|
"""
|
||||||
An event for modlog case creation
|
An event for modlog case creation
|
||||||
"""
|
"""
|
||||||
mod_channel = await modlog.get_modlog_channel(case.guild)
|
try:
|
||||||
if mod_channel is None:
|
mod_channel = await modlog.get_modlog_channel(case.guild)
|
||||||
|
except RuntimeError:
|
||||||
return
|
return
|
||||||
use_embeds = await case.bot.embed_requested(mod_channel, case.guild.me)
|
use_embeds = await case.bot.embed_requested(mod_channel, case.guild.me)
|
||||||
case_content = await case.message_content(use_embeds)
|
case_content = await case.message_content(use_embeds)
|
||||||
|
|||||||
@ -666,29 +666,30 @@ async def register_casetypes(new_types: List[dict]) -> List[CaseType]:
|
|||||||
return type_list
|
return type_list
|
||||||
|
|
||||||
|
|
||||||
async def get_modlog_channel(guild: discord.Guild) -> Union[discord.TextChannel, None]:
|
async def get_modlog_channel(guild: discord.Guild) -> discord.TextChannel:
|
||||||
"""
|
"""
|
||||||
Get the current modlog channel
|
Get the current modlog channel.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
guild: `discord.Guild`
|
guild: `discord.Guild`
|
||||||
The guild to get the modlog channel for
|
The guild to get the modlog channel for.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
`discord.TextChannel` or `None`
|
`discord.TextChannel`
|
||||||
The channel object representing the modlog channel
|
The channel object representing the modlog channel.
|
||||||
|
|
||||||
Raises
|
Raises
|
||||||
------
|
------
|
||||||
RuntimeError
|
RuntimeError
|
||||||
If the modlog channel is not found
|
If the modlog channel is not found.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if hasattr(guild, "get_channel"):
|
if hasattr(guild, "get_channel"):
|
||||||
channel = guild.get_channel(await _conf.guild(guild).mod_log())
|
channel = guild.get_channel(await _conf.guild(guild).mod_log())
|
||||||
else:
|
else:
|
||||||
|
# For unit tests only
|
||||||
channel = await _conf.guild(guild).mod_log()
|
channel = await _conf.guild(guild).mod_log()
|
||||||
if channel is None:
|
if channel is None:
|
||||||
raise RuntimeError("Failed to get the mod log channel!")
|
raise RuntimeError("Failed to get the mod log channel!")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user