From 785f67c9c4cd777b990e2d2fa02b1e22f8b8b91a Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Tue, 19 Apr 2022 11:41:21 -0600 Subject: [PATCH] No longer allow warning user not in guild --- jarvis/cogs/admin/warning.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/jarvis/cogs/admin/warning.py b/jarvis/cogs/admin/warning.py index e8b9dbb..031ee86 100644 --- a/jarvis/cogs/admin/warning.py +++ b/jarvis/cogs/admin/warning.py @@ -5,7 +5,7 @@ from dis_snek import InteractionContext, Permissions, Snake from dis_snek.client.utils.misc_utils import get_all from dis_snek.ext.paginators import Paginator from dis_snek.models.discord.embed import EmbedField -from dis_snek.models.discord.user import User +from dis_snek.models.discord.user import Member from dis_snek.models.snek.application_commands import ( OptionTypes, slash_command, @@ -44,7 +44,7 @@ class WarningCog(ModcaseCog): ) @check(admin_or_permissions(Permissions.MANAGE_GUILD)) async def _warn( - self, ctx: InteractionContext, user: User, reason: str, duration: int = 24 + self, ctx: InteractionContext, user: Member, reason: str, duration: int = 24 ) -> None: if len(reason) > 100: await ctx.send("Reason must be < 100 characters", ephemeral=True) @@ -55,6 +55,9 @@ class WarningCog(ModcaseCog): elif duration >= 120: await ctx.send("Duration must be < 5 days", ephemeral=True) return + if not await ctx.guild.fetch_member(user.id): + await ctx.send("User not in guild", ephemeral=True) + return await ctx.defer() await Warning( user=user.id, @@ -76,7 +79,7 @@ class WarningCog(ModcaseCog): required=False, ) @check(admin_or_permissions(Permissions.MANAGE_GUILD)) - async def _warnings(self, ctx: InteractionContext, user: User, active: bool = True) -> None: + async def _warnings(self, ctx: InteractionContext, user: Member, active: bool = True) -> None: warnings = ( await Warning.find( q(