Crates.io | discordinteractions |
lib.rs | discordinteractions |
version | 1.0.1 |
source | src |
created_at | 2023-05-18 09:52:59.886942 |
updated_at | 2023-05-18 09:54:06.130334 |
description | A library to declare Discord Interactions easily in Rust, with support for Serde |
homepage | https://github.com/wosher-co/discordinteractions |
repository | https://github.com/wosher-co/discordinteractions |
max_upload_size | |
id | 867658 |
size | 10,462 |
A simple library for declaring Discord interactions.
Add the serde_support
to your Cargo.toml
to enable serde support.
discordinteractions = { version = "1", features = ["serde_support"] }
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();