2个稳定版本
使用旧Rust 2015
1.0.1 | 2023年5月18日 |
---|
#71 在 #interaction
11KB
156 行
Discord交互
一个简单的用于声明Discord交互的库。
Serde支持
将serde_support
添加到您的Cargo.toml
中,以启用Serde支持。
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,
};
使用reqwest发送交互
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();
依赖项
~0–310KB