Skip to content

Commit a72646b

Browse files
Make channel option in Archive command
1 parent 6b27c5c commit a72646b

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

cogs/archive.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ async def archive_category(
222222
description="The channel to archive.",
223223
input_type=str,
224224
autocomplete=discord.utils.basic_autocomplete(autocomplete_get_non_archived_channels),
225-
required=True,
225+
required=False,
226226
parameter_name="str_channel_id",
227227
)
228228
@discord.option(
@@ -236,17 +236,21 @@ async def archive_category(
236236
@CommandChecks.check_interaction_user_has_committee_role
237237
@CommandChecks.check_interaction_user_in_main_guild
238238
async def archive_channel(
239-
self, ctx: "TeXBotApplicationContext", str_channel_id: str, str_category_id: str
239+
self, ctx: "TeXBotApplicationContext", str_channel_id: str | None, str_category_id: str
240240
) -> None:
241241
"""
242242
Definition & callback response of the "archive-channel" command.
243243
244244
The "archive-channel" command moves the channel into the selected category
245-
and syncs the permissions to the category's permissions.
245+
and syncs the permissions to the category's permissions. Defaults to current
246+
channel if no channel is provided.
246247
"""
247248
# NOTE: Shortcut accessors are placed at the top of the function so that the exceptions they raise are displayed before any further errors may be sent
248249
main_guild: discord.Guild = self.bot.main_guild
249250

251+
if not str_channel_id:
252+
str_channel_id = str(ctx.channel_id)
253+
250254
if not re.fullmatch(r"\A\d{17,20}\Z", str_channel_id):
251255
await self.command_send_error(
252256
ctx, message=f"{str_channel_id!r} is not a valid channel ID."
@@ -277,6 +281,7 @@ async def archive_channel(
277281
await self.command_send_error(
278282
ctx, message=f"{str_category_id!r} is not a valid category ID."
279283
)
284+
return
280285

281286
category_id: int = int(str_category_id)
282287

0 commit comments

Comments
 (0)