question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

🔨 Implement command options (subcommands)

See original GitHub issue

Feature

Implement subcommands. So that eg the following data gets sent to discord:

{
    "name": "permissions",
    "description": "Get or edit permissions for a user or a role",
    "options": [
        {
            "name": "user",
            "description": "Get or edit permissions for a user",
            "type": 2, // 2 is type SUB_COMMAND_GROUP
            "options": [
                {
                    "name": "get",
                    "description": "Get permissions for a user",
                    "type": 1, // 1 is type SUB_COMMAND
                    "options": [
                        {
                            "name": "user",
                            "description": "The user to get",
                            "type": 6, // 6 is type USER
                            "required": true
                        },
                        {
                            "name": "channel",
                            "description": "The channel permissions to get. If omitted, the guild permissions will be returned",
                            "type": 7, // 7 is type CHANNEL
                            "required": false
                        }
                    ]
                },
                {
                    "name": "edit",
                    "description": "Edit permissions for a user",
                    "type": 1,
                    "options": [
                        {
                            "name": "user",
                            "description": "The user to edit",
                            "type": 6,
                            "required": true
                        },
                        {
                            "name": "channel",
                            "description": "The channel permissions to edit. If omitted, the guild permissions will be edited",
                            "type": 7,
                            "required": false
                        }
                    ]
                }
            ]
        },
        {
            "name": "role",
            "description": "Get or edit permissions for a role",
            "type": 2,
            "options": [
                {
                    "name": "get",
                    "description": "Get permissions for a role",
                    "type": 1,
                    "options": [
                        {
                            "name": "role",
                            "description": "The role to get",
                            "type": 8, // 8 is type ROLE
                            "required": true
                        },
                        {
                            "name": "channel",
                            "description": "The channel permissions to get. If omitted, the guild permissions will be returned",
                            "type": 7,
                            "required": false
                        }
                    ]
                },
                {
                    "name": "edit",
                    "description": "Edit permissions for a role",
                    "type": 1,
                    "options": [
                        {
                            "name": "role",
                            "description": "The role to edit",
                            "type": 8,
                            "required": true
                        },
                        {
                            "name": "channel",
                            "description": "The channel permissions to edit. If omitted, the guild permissions will be edited",
                            "type": 7,
                            "required": false
                        }
                    ]
                }
            ]
        }
    ]
}

Code implementation

Open for discussion, please post suggestions on how you’d like to use this in the lib.

Useful link(s)

https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
Arthurdwcommented, Oct 17, 2021

@mwath yeah, like I said I’d like to do it through type annotations. (So your Using the function as type hint). Which is a system that could work. But I also quote: I just haven't figured out yet how to do groups properly.

Thanks for the suggestions tho, and its great to see that we’re on the same page. 😊

0reactions
Lunarmagpiecommented, Dec 30, 2021

Guess ill go with that method since it seems really maintainable

Read more comments on GitHub >

github_iconTop Results From Across the Web

Clikt - Common Options With Subcommands
You can define your options on the root command and pass down the information via the context. With this design, you'll have to...
Read more >
How to add common options to sub commands which can go ...
Yes you can add common options to sub commands which can go after the name of the sub command. You ...
Read more >
Hammer cheat sheet - Red Hat Customer Portal
You can use Hammer to configure and manage a Red Hat Satellite Server through either CLI commands or automation in shell scripts. The...
Read more >
Enter Commands, Parameters, Subcommands, and Line ...
The COMMANDS command distinguishes the type of command to use. COMMANDS has PRI, FUNC, or SUB for Primary, Function, and Subcommand. PRI. The...
Read more >
Pixelmon spawn command - Divadonna.it
Note: Command syntax is displayed in the standard Minecraft command format. ... Place the disc on a Pixelmon anvil, and use a hammer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found