chore: move app-commands script to rust

This commit is contained in:
alyssa 2025-10-15 21:15:54 +00:00
parent c0a5bc81a0
commit 83dd880374
13 changed files with 71 additions and 139 deletions

View 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 }

View 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(())
}