No longer allow warning user not in guild

This commit is contained in:
Zeva Rose 2022-04-19 11:41:21 -06:00
parent 2235479b40
commit 785f67c9c4

View file

@ -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(