Skip to content

Commit 732de02

Browse files
committed
Change move command to consume for category
1 parent 1f846fa commit 732de02

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

cogs/modmail.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,22 +284,43 @@ async def snippet_edit(self, ctx, name: str.lower, *, value):
284284
embed = create_not_found_embed(name, self.bot.snippets.keys(), "Snippet")
285285
await ctx.send(embed=embed)
286286

287-
@commands.command()
287+
@commands.command(usage='<category> [options]')
288288
@checks.has_permissions(PermissionLevel.MODERATOR)
289289
@checks.thread_only()
290-
async def move(self, ctx, category: discord.CategoryChannel, *, specifics: str = None):
290+
async def move(self, ctx, *, arguments):
291291
"""
292292
Move a thread to another category.
293293
294294
`category` may be a category ID, mention, or name.
295-
`specifics` is a string which takes in arguments on how to perform the move. Ex: "silently"
295+
`options` is a string which takes in arguments on how to perform the move. Ex: "silently"
296296
"""
297+
split_args = arguments.strip('"').split(' ')
298+
299+
# manually parse arguments, consumes as much of args as possible for category
300+
for i in range(len(split_args)):
301+
try:
302+
if i == 0:
303+
fmt = arguments
304+
else:
305+
fmt = ' '.join(split_args[:-i])
306+
307+
category = await commands.CategoryChannelConverter().convert(ctx, fmt)
308+
except commands.BadArgument:
309+
if i == len(split_args) - 1:
310+
# last one
311+
raise
312+
pass
313+
else:
314+
break
315+
316+
options = ' '.join(arguments.split(' ')[-i:])
317+
297318
thread = ctx.thread
298319
silent = False
299320

300-
if specifics:
321+
if options:
301322
silent_words = ["silent", "silently"]
302-
silent = any(word in silent_words for word in specifics.split())
323+
silent = any(word in silent_words for word in options.split())
303324

304325
await thread.channel.edit(category=category, sync_permissions=True)
305326

0 commit comments

Comments
 (0)