Skip to content

Commit 9d82f88

Browse files
committed
Better response messages
1 parent 9131af4 commit 9d82f88

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

cogs/modmail.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import re
33
from datetime import datetime
44
from typing import Optional, Union
5-
from types import SimpleNamespace as p
5+
from types import SimpleNamespace as param
66

77
import discord
88
from discord.ext import commands
@@ -421,7 +421,7 @@ async def logs(self, ctx, *, member: User = None):
421421
if not member:
422422
thread = ctx.thread
423423
if not thread:
424-
raise commands.MissingRequiredArgument(p(name=member))
424+
raise commands.MissingRequiredArgument(param(name='member'))
425425
user = thread.recipient
426426
else:
427427
user = member
@@ -690,15 +690,17 @@ async def block(self, ctx, user: Optional[User] = None, *,
690690
thread = ctx.thread
691691
if thread:
692692
user = thread.recipient
693+
elif after is None:
694+
raise commands.MissingRequiredArgument(param(name='user'))
693695
else:
694-
raise commands.MissingRequiredArgument(p(name='user'))
696+
raise commands.BadArgument(f'User "{after}" not found')
695697

696698
if after is not None:
697699
reason = after.arg
698700
if reason.startswith('System Message: '):
699701
raise commands.BadArgument('The reason cannot start with `System Message:`.')
700702
if re.search(r'%(.+?)%$', reason) is not None:
701-
raise commands.MissingRequiredArgument(p(name='reason'))
703+
raise commands.MissingRequiredArgument(param(name='reason'))
702704
if after.dt > after.now:
703705
reason = f'{reason} %{after.dt.isoformat()}%'
704706

@@ -750,12 +752,13 @@ async def unblock(self, ctx, *, user: User = None):
750752
use only.
751753
"""
752754

755+
753756
if user is None:
754757
thread = ctx.thread
755758
if thread:
756759
user = thread.recipient
757760
else:
758-
raise commands.MissingRequiredArgument(p(name='user'))
761+
raise commands.MissingRequiredArgument(param(name='user'))
759762

760763
mention = user.mention if hasattr(user, 'mention') else f'`{user.id}`'
761764

@@ -793,14 +796,20 @@ async def unblock(self, ctx, *, user: User = None):
793796

794797
@commands.command()
795798
@checks.has_permissions(PermissionLevel.SUPPORTER)
796-
async def delete(self, ctx, message_id: int = None):
799+
@checks.thread_only()
800+
async def delete(self, ctx, message_id = None):
797801
"""Delete a message that was sent using the reply command.
798802
799803
Deletes the previous message, unless a message ID is provided, which in that case,
800804
deletes the message with that message ID.
801805
"""
802806
thread = ctx.thread
803807

808+
try:
809+
message_id = int(message_id)
810+
except ValueError:
811+
raise commands.BadArgument('An integer message ID needs to be specified.')
812+
804813
linked_message_id = await self.find_linked_message(ctx, message_id)
805814

806815
if linked_message_id is None:

0 commit comments

Comments
 (0)