@@ -277,9 +277,6 @@ async def handle_mute_user(
277277 target (discord.Member): The target for being muted
278278 reason (str): The reason for being muted
279279 duration (str, optional): The human readable duration to be muted for. Defaults to None.
280-
281- Raises:
282- ValueError: Raised if the duration is invalid or cannot be parsed
283280 """
284281 permission_check = await self .permission_check (
285282 invoker = interaction .user , target = target , action_name = "mute"
@@ -316,17 +313,29 @@ async def handle_mute_user(
316313 seconds = round (delta_duration .total_seconds ())
317314 )
318315 except TypeError as exc :
319- raise ValueError ("Invalid duration" ) from exc
316+ embed = auxiliary .prepare_deny_embed (message = "Invalid duration" )
317+ await interaction .response .send_message (embed = embed )
318+ return
320319 if not delta_duration :
321- raise ValueError ("Invalid duration" )
320+ embed = auxiliary .prepare_deny_embed (message = "Invalid duration" )
321+ await interaction .response .send_message (embed = embed )
322+ return
322323 else :
323324 delta_duration = timedelta (hours = 1 )
324325
325326 # Checks to ensure time is valid and within the scope of the API
326327 if delta_duration > timedelta (days = 28 ):
327- raise ValueError ("Timeout duration cannot be more than 28 days" )
328+ embed = auxiliary .prepare_deny_embed (
329+ message = "Timeout duration cannot be more than 28 days"
330+ )
331+ await interaction .response .send_message (embed = embed )
332+ return
328333 if delta_duration < timedelta (seconds = 1 ):
329- raise ValueError ("Timeout duration cannot be less than 1 second" )
334+ embed = auxiliary .prepare_deny_embed (
335+ message = "Timeout duration cannot be less than 1 second"
336+ )
337+ await interaction .response .send_message (embed = embed )
338+ return
330339
331340 result = await moderation .mute_user (
332341 user = target ,
0 commit comments