mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
chore: move app-commands script to rust
This commit is contained in:
parent
c0a5bc81a0
commit
83dd880374
13 changed files with 71 additions and 139 deletions
14
crates/app-commands/Cargo.toml
Normal file
14
crates/app-commands/Cargo.toml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
[package]
|
||||
name = "app-commands"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
libpk = { path = "../libpk" }
|
||||
anyhow = { workspace = true }
|
||||
futures = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
twilight-http = { workspace = true }
|
||||
twilight-model = { workspace = true }
|
||||
twilight-util = { workspace = true }
|
||||
41
crates/app-commands/src/main.rs
Normal file
41
crates/app-commands/src/main.rs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
use twilight_model::{
|
||||
application::command::{Command, CommandType},
|
||||
guild::IntegrationApplication,
|
||||
};
|
||||
use twilight_util::builder::command::CommandBuilder;
|
||||
|
||||
#[libpk::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
let discord = twilight_http::Client::builder()
|
||||
.token(
|
||||
libpk::config
|
||||
.discord
|
||||
.as_ref()
|
||||
.expect("missing discord config")
|
||||
.bot_token
|
||||
.clone(),
|
||||
)
|
||||
.build();
|
||||
|
||||
let interaction = discord.interaction(twilight_model::id::Id::new(
|
||||
libpk::config
|
||||
.discord
|
||||
.as_ref()
|
||||
.expect("missing discord config")
|
||||
.client_id
|
||||
.clone()
|
||||
.get(),
|
||||
));
|
||||
|
||||
let commands = vec![
|
||||
// message commands
|
||||
// description must be empty string
|
||||
CommandBuilder::new("\u{2753} Message info", "", CommandType::Message).build(),
|
||||
CommandBuilder::new("\u{274c} Delete message", "", CommandType::Message).build(),
|
||||
CommandBuilder::new("\u{1f514} Ping author", "", CommandType::Message).build(),
|
||||
];
|
||||
|
||||
interaction.set_global_commands(&commands).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue