diff options
| author | 2025-05-17 09:54:10 +0100 | |
|---|---|---|
| committer | 2025-05-17 10:03:43 +0100 | |
| commit | 0113d8262df65956e6f84bd52d032434ccdd93d7 (patch) | |
| tree | 0f9f7a89d45b932e40f9914c33ddd37d93c5adde | |
| parent | Dynamically get the default snekbox Python version by looking at the first su... (diff) | |
Move snekbox help docs to the @command decorator
This allows us to use a f-string to get the supported Python versions, instead of hard coding
Diffstat (limited to '')
| -rw-r--r-- | bot/exts/utils/snekbox/_cog.py | 43 | ||||
| -rw-r--r-- | bot/exts/utils/snekbox/_eval.py | 2 | 
2 files changed, 25 insertions, 20 deletions
| diff --git a/bot/exts/utils/snekbox/_cog.py b/bot/exts/utils/snekbox/_cog.py index 35a5c5e60..0afd3c408 100644 --- a/bot/exts/utils/snekbox/_cog.py +++ b/bot/exts/utils/snekbox/_cog.py @@ -569,7 +569,29 @@ class Snekbox(Cog):                  break              log.info(f"Re-evaluating code from message {ctx.message.id}:\n{job}") -    @command(name="eval", aliases=("e",), usage="[python_version] <code, ...>") +    @command( +        name="eval", +        aliases=("e",), +        usage="[python_version] <code, ...>", +        help=f""" +            Run Python code and get the results. + +            This command supports multiple lines of code, including formatted code blocks. +            Code can be re-evaluated by editing the original message within 10 seconds and +            clicking the reaction that subsequently appears. + +            The starting working directory `/home`, is a writeable temporary file system. +            Files created, excluding names with leading underscores, will be uploaded in the response. + +            If multiple codeblocks are in a message, all of them will be joined and evaluated, +            ignoring the text outside them. + +            The currently supported versions are {", ".join(get_args(SupportedPythonVersions))}. + +            We've done our best to make this sandboxed, but do let us know if you manage to find an +            issue with it! +        """ +    )      @guild_only()      @redirect_output(          destination_channel=Channels.bot_commands, @@ -585,24 +607,7 @@ class Snekbox(Cog):          *,          code: CodeblockConverter      ) -> None: -        """ -        Run Python code and get the results. - -        This command supports multiple lines of code, including formatted code blocks. -        Code can be re-evaluated by editing the original message within 10 seconds and -        clicking the reaction that subsequently appears. - -        The starting working directory `/home`, is a writeable temporary file system. -        Files created, excluding names with leading underscores, will be uploaded in the response. - -        If multiple codeblocks are in a message, all of them will be joined and evaluated, -        ignoring the text outside them. - -        The currently supported verisons are 3.12, 3.13, and 3.13t. - -        We've done our best to make this sandboxed, but do let us know if you manage to find an -        issue with it! -        """ +        """Run Python code and get the results."""          code: list[str]          python_version = python_version or get_args(SupportedPythonVersions)[0]          job = EvalJob.from_code("\n".join(code)).as_version(python_version) diff --git a/bot/exts/utils/snekbox/_eval.py b/bot/exts/utils/snekbox/_eval.py index fa377488d..6136b6a81 100644 --- a/bot/exts/utils/snekbox/_eval.py +++ b/bot/exts/utils/snekbox/_eval.py @@ -26,7 +26,7 @@ class EvalJob:      args: list[str]      files: list[FileAttachment] = field(default_factory=list)      name: str = "eval" -    version: SupportedPythonVersions = "3.12" +    version: SupportedPythonVersions = "3.13"      @classmethod      def from_code(cls, code: str, path: str = "main.py") -> EvalJob: | 
