discordinteractions

Crates.iodiscordinteractions
lib.rsdiscordinteractions
version1.0.1
sourcesrc
created_at2023-05-18 09:52:59.886942
updated_at2023-05-18 09:54:06.130334
descriptionA library to declare Discord Interactions easily in Rust, with support for Serde
homepagehttps://github.com/wosher-co/discordinteractions
repositoryhttps://github.com/wosher-co/discordinteractions
max_upload_size
id867658
size10,462
Pol Vallverdu (polvallverdu)

documentation

README

Discord Interactions

A simple library for declaring Discord interactions.

Serde Support

Add the serde_support to your Cargo.toml to enable serde support.

discordinteractions = { version = "1", features = ["serde_support"] }

Example

DiscordInteraction {
    name: "test".to_string(),
    name_localizations: None,
    description: Some("test".to_string()),
    description_localizations: None,
    options: Some(vec![
        DiscordInteractionOption {
            name: "test".to_string(),
            description: "test".to_string(),
            autocomplete: Some(false),
            required: Some(true),
            channel_types: None,
            choices: None,
            max_length: None,
            min_length: None,
            max_value: None,
            min_value: None,
            description_localizations: None,
            name_localizations: None,
            option_type: command_creator::DiscordInteractionOptionType::String,
            options: None,
        }
    ]),
    default_member_permissions: None,
    dm_permission: None,
    default_permission: true,
    nsfw: false,
};

Using reqwest to send the interaction:

client.post("https://discord.com/api/v10/applications/{app.id}/commands")
    .header("User-Agent", "DiscordBot (url, version)")
    .header("Authorization", format!("Bot {}", BOT_TOKEN))
    .json(&declared_interaction).send();
Commit count: 5

cargo fmt