21 个版本
0.16.0-rc.1 | 2024年5月16日 |
---|---|
0.15.2 | 2023年6月23日 |
0.15.1 | 2023年3月26日 |
0.14.2 | 2022年11月27日 |
0.7.2 | 2021年11月23日 |
439 在 网页编程 类别中
每月下载量:174
61KB
829 行
Twilight interactions
twilight-interactions
是一个宏和实用工具集合,用于使用 twilight
与 Discord Interactions 一起工作。
注意: 此包与 twilight
项目无关。
功能
- 斜杠命令解析:使用
CommandModel
宏将交互数据解析为类型化结构体。 - 斜杠命令创建:使用
CreateCommand
宏从您的结构体中创建命令。命令通过属性进行配置。
use twilight_interactions::command::{CommandModel, CreateCommand, ResolvedUser};
#[derive(CommandModel, CreateCommand)]
#[command(name = "hello", desc = "Say hello to other members")]
struct HelloCommand {
/// Message to send
message: String,
/// User to send the message to
user: Option<ResolvedUser>
}
安装
要安装 twilight-interactions
,请将以下内容添加到您的 Cargo.toml
[dependencies]
twilight-interactions = "0.15"
该包的主版本号遵循官方 Twilight 包的版本。当前的最小支持 Rust 版本(MSRV)是 1.67
。
文档
API 文档可在 docs.rs 上找到:[twilight-interactions 文档](https://docs.rs/twilight-interactions/)
示例可在 examples
目录中找到。
贡献
没有特定的贡献指南,欢迎提交新 PR 以改进代码。如果您想引入新功能,请先创建一个 issue。
特别感谢 LeSeulArtichaut,他首先参与了此项目。
依赖关系
~3.5MB
~74K SLoC