Turn AoC commands into hybrid commands#101
Turn AoC commands into hybrid commands#101n0Oo0Oo0b wants to merge 10 commits intopython-discord:mainfrom
Conversation
Robin5605
left a comment
There was a problem hiding this comment.
Making this into a hybrid command should cut down on code duplication. I believe Kat wanted them to be hybrid anyway, so that works out nicely. Do you mind condensing the slash command and text command into a hybrid command?
|
You can't turn individual commandss into hybrid commands afaict, but using a hybrid group should turn all the commands into hybrid commands, which should work anyway. |
&aoc countdown|
The latest commits should turn all the AoC commands into hybrid commands. Everything looks ok from my testing other than the channel restrictions, which don't work for text commands on my bot either, so it seems like something to do with my environment. |
There was a problem hiding this comment.
So an issue with the current approach, is that &aoc link still works as a regular command and is not ephemeral only. I would like to convert this completely over to a slash-only is possible. If it's not the most feasible then that's fine.
Additionally, with the hybrid group, I would prefer the prefix to be /aoc instead of the wordy /adventofcode
For the channel restrictions, that's not working because we're missing code that wraps the extensions with the whitelist command.
Sir-Lancebot runs very restricted and each command is restricted and then given an channel overrides: https://github.com/python-discord/sir-lancebot/blob/main/bot/__main__.py#L76-L80
I'm okay with taking a similar approach and stealing that functionality/code-snippet from Sir-Lancebot.
You will run into an issue with a missing code jam constant if you do run it, so feel free to create a new constant for the Code Jam categories:
class Categories(NamedTuple):
codejam_categories_name = "CODE JAM"We will have to adapt the output when a command is run doesn't pass the role check. Currently this is the output:

|
Pushed commit 619a1db that makes link/unlink commands slash-command only as requested by Kat. Would like some feedback here on the technical side - I've used the self.app_command = app_commands.Group(
name=self._locale_name or self.name,
description=self._locale_description or self.description or self.short_doc or '…',
guild_ids=guild_ids,
guild_only=guild_only,
default_permissions=default_permissions,
nsfw=nsfw,
) |
|
I know this is probably stale but for slash we probably don't need the channel checks, we can just use ephemeral responses if the user can't use the command there. |
Closes #97
I feel like duplicating the code isn't the best way to go about this, but I couldn't really think of anything else. Any suggestions to avoid it are welcome.