mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-06 09:22:31 -05:00
[Modlog]Raise error instead of failing silently on invalid arguments (#5386)
Co-authored-by: Dav <dav@mail.stopdavabuse.de> Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> Co-authored-by: Flame442 <34169552+Flame442@users.noreply.github.com>
This commit is contained in:
@@ -1020,18 +1020,23 @@ async def create_case(
|
||||
|
||||
Raises
|
||||
------
|
||||
ValueError
|
||||
If the action type is not a valid action type.
|
||||
RuntimeError
|
||||
If user is the bot itself.
|
||||
TypeError
|
||||
If ``channel`` is of type `discord.PartialMessageable`.
|
||||
"""
|
||||
case_type = await get_casetype(action_type, guild)
|
||||
if case_type is None:
|
||||
return
|
||||
raise ValueError(f"{action_type} is not a valid action type.")
|
||||
|
||||
if not await case_type.is_enabled():
|
||||
return
|
||||
|
||||
if user == bot.user:
|
||||
return
|
||||
user_id = user if isinstance(user, int) else user.id
|
||||
if user_id == bot.user.id:
|
||||
raise RuntimeError("The bot itself can not be the target of a modlog entry.")
|
||||
|
||||
if isinstance(channel, discord.PartialMessageable):
|
||||
raise TypeError("Can't use PartialMessageable as the channel for a modlog case.")
|
||||
|
||||
Reference in New Issue
Block a user