shardlab / discordrb

Discord API for Ruby
MIT License
525 stars 95 forks source link

Support new slash commands #5

Closed xbenjii closed 3 years ago

xbenjii commented 3 years ago

Describe your feature request in as much detail as you can here.

https://discord.com/developers/docs/interactions/slash-commands

The python example is

url = "https://discord.com/api/v8/applications/<my_application_id>/commands"

json = {
    "name": "blep",
    "description": "Send a random adorable animal photo",
    "options": [
        {
            "name": "animal",
            "description": "The type of animal",
            "type": 3,
            "required": True,
            "choices": [
                {
                    "name": "Dog",
                    "value": "animal_dog"
                },
                {
                    "name": "Cat",
                    "value": "animal_dog"
                },
                {
                    "name": "Penguin",
                    "value": "animal_penguin"
                }
            ]
        },
        {
            "name": "only_smol",
            "description": "Whether to show only baby animals",
            "type": 5,
            "required": False
        }
    ]
}

# For authorization, you can use either your bot token 
headers = {
    "Authorization": "Bot 123456"
}

# or a client credentials token for your app with the applications.commmands.update scope
headers = {
    "Authorization": "Bearer abcdefg"
}

r = requests.post(url, headers=headers, json=json)
swarley commented 3 years ago

Anyone waiting for this feature can view our project for it to see the progress. I hope to get this finished by Jan 2021.