|
2 | 2 | import re
|
3 | 3 | from datetime import datetime
|
4 | 4 | from typing import Optional, Union
|
5 |
| -from types import SimpleNamespace as p |
| 5 | +from types import SimpleNamespace as param |
6 | 6 |
|
7 | 7 | import discord
|
8 | 8 | from discord.ext import commands
|
@@ -421,7 +421,7 @@ async def logs(self, ctx, *, member: User = None):
|
421 | 421 | if not member:
|
422 | 422 | thread = ctx.thread
|
423 | 423 | if not thread:
|
424 |
| - raise commands.MissingRequiredArgument(p(name=member)) |
| 424 | + raise commands.MissingRequiredArgument(param(name='member')) |
425 | 425 | user = thread.recipient
|
426 | 426 | else:
|
427 | 427 | user = member
|
@@ -690,15 +690,17 @@ async def block(self, ctx, user: Optional[User] = None, *,
|
690 | 690 | thread = ctx.thread
|
691 | 691 | if thread:
|
692 | 692 | user = thread.recipient
|
| 693 | + elif after is None: |
| 694 | + raise commands.MissingRequiredArgument(param(name='user')) |
693 | 695 | else:
|
694 |
| - raise commands.MissingRequiredArgument(p(name='user')) |
| 696 | + raise commands.BadArgument(f'User "{after}" not found') |
695 | 697 |
|
696 | 698 | if after is not None:
|
697 | 699 | reason = after.arg
|
698 | 700 | if reason.startswith('System Message: '):
|
699 | 701 | raise commands.BadArgument('The reason cannot start with `System Message:`.')
|
700 | 702 | if re.search(r'%(.+?)%$', reason) is not None:
|
701 |
| - raise commands.MissingRequiredArgument(p(name='reason')) |
| 703 | + raise commands.MissingRequiredArgument(param(name='reason')) |
702 | 704 | if after.dt > after.now:
|
703 | 705 | reason = f'{reason} %{after.dt.isoformat()}%'
|
704 | 706 |
|
@@ -750,12 +752,13 @@ async def unblock(self, ctx, *, user: User = None):
|
750 | 752 | use only.
|
751 | 753 | """
|
752 | 754 |
|
| 755 | + |
753 | 756 | if user is None:
|
754 | 757 | thread = ctx.thread
|
755 | 758 | if thread:
|
756 | 759 | user = thread.recipient
|
757 | 760 | else:
|
758 |
| - raise commands.MissingRequiredArgument(p(name='user')) |
| 761 | + raise commands.MissingRequiredArgument(param(name='user')) |
759 | 762 |
|
760 | 763 | mention = user.mention if hasattr(user, 'mention') else f'`{user.id}`'
|
761 | 764 |
|
@@ -793,14 +796,20 @@ async def unblock(self, ctx, *, user: User = None):
|
793 | 796 |
|
794 | 797 | @commands.command()
|
795 | 798 | @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): |
797 | 801 | """Delete a message that was sent using the reply command.
|
798 | 802 |
|
799 | 803 | Deletes the previous message, unless a message ID is provided, which in that case,
|
800 | 804 | deletes the message with that message ID.
|
801 | 805 | """
|
802 | 806 | thread = ctx.thread
|
803 | 807 |
|
| 808 | + try: |
| 809 | + message_id = int(message_id) |
| 810 | + except ValueError: |
| 811 | + raise commands.BadArgument('An integer message ID needs to be specified.') |
| 812 | + |
804 | 813 | linked_message_id = await self.find_linked_message(ctx, message_id)
|
805 | 814 |
|
806 | 815 | if linked_message_id is None:
|
|
0 commit comments