Use Serenity from Poise package directly

This commit is contained in:
toast 2024-03-21 09:03:09 +11:00
parent ee9143ef0a
commit 62f62c674f
3 changed files with 5 additions and 39 deletions

34
Cargo.lock generated
View File

@ -202,17 +202,6 @@ dependencies = [
"windows-targets 0.48.5", "windows-targets 0.48.5",
] ]
[[package]]
name = "command_attr"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32f08c85a02e066b7b4f7dcb60eee6ae0793ef7d6452a3547d1f19665df070a9"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]] [[package]]
name = "core-foundation" name = "core-foundation"
version = "0.9.4" version = "0.9.4"
@ -758,12 +747,6 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "levenshtein"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db13adb97ab515a3691f56e4dbab09283d0b86cb45abd991d8634a9d6f501760"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.153" version = "0.2.153"
@ -1156,7 +1139,6 @@ dependencies = [
"cargo_toml", "cargo_toml",
"once_cell", "once_cell",
"poise", "poise",
"serenity",
"sysinfo", "sysinfo",
"tempfile", "tempfile",
"tokio", "tokio",
@ -1358,12 +1340,10 @@ dependencies = [
"bitflags 2.4.2", "bitflags 2.4.2",
"bytes", "bytes",
"chrono", "chrono",
"command_attr",
"dashmap", "dashmap",
"flate2", "flate2",
"futures", "futures",
"fxhash", "fxhash",
"levenshtein",
"mime_guess", "mime_guess",
"parking_lot", "parking_lot",
"percent-encoding", "percent-encoding",
@ -1371,7 +1351,6 @@ dependencies = [
"secrecy", "secrecy",
"serde", "serde",
"serde_json", "serde_json",
"static_assertions",
"time", "time",
"tokio", "tokio",
"tokio-tungstenite", "tokio-tungstenite",
@ -1379,7 +1358,6 @@ dependencies = [
"typemap_rev", "typemap_rev",
"typesize", "typesize",
"url", "url",
"uwl",
] ]
[[package]] [[package]]
@ -1458,12 +1436,6 @@ version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]] [[package]]
name = "strsim" name = "strsim"
version = "0.10.0" version = "0.10.0"
@ -1913,12 +1885,6 @@ version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
[[package]]
name = "uwl"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4bf03e0ca70d626ecc4ba6b0763b934b6f2976e8c744088bb3c1d646fbb1ad0"
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.4" version = "0.9.4"

View File

@ -7,7 +7,6 @@ edition = "2021"
cargo_toml = "0.19.2" cargo_toml = "0.19.2"
once_cell = "1.19.0" once_cell = "1.19.0"
poise = "0.6.1" poise = "0.6.1"
serenity = "0.12.1"
sysinfo = "0.30.7" sysinfo = "0.30.7"
tempfile = "3.10.1" tempfile = "3.10.1"
tokio = { version = "1.36.0", features = ["macros", "signal", "rt-multi-thread"] } tokio = { version = "1.36.0", features = ["macros", "signal", "rt-multi-thread"] }

View File

@ -1,12 +1,11 @@
mod commands; mod commands;
mod internals; mod internals;
use poise::serenity_prelude::{self as serenity};
use std::{ use std::{
env::var, env::var,
error error
}; };
use serenity::{ use poise::serenity_prelude::{
builder::{ builder::{
CreateMessage, CreateMessage,
CreateEmbed, CreateEmbed,
@ -15,6 +14,8 @@ use serenity::{
Context, Context,
Ready, Ready,
ClientBuilder, ClientBuilder,
ChannelId,
Command,
GatewayIntents GatewayIntents
}; };
@ -35,13 +36,13 @@ async fn on_ready(
.thumbnail(ready.user.avatar_url().unwrap_or_default()) .thumbnail(ready.user.avatar_url().unwrap_or_default())
.author(CreateEmbedAuthor::new(format!("{} is ready!", ready.user.name)).clone()); .author(CreateEmbedAuthor::new(format!("{} is ready!", ready.user.name)).clone());
serenity::ChannelId::new(BOT_READY_NOTIFY).send_message(&ctx.http, message.add_embed(ready_embed)).await?; ChannelId::new(BOT_READY_NOTIFY).send_message(&ctx.http, message.add_embed(ready_embed)).await?;
let register_commands = var("REGISTER_CMDS").unwrap_or_else(|_| String::from("true")).parse::<bool>().unwrap_or(true); let register_commands = var("REGISTER_CMDS").unwrap_or_else(|_| String::from("true")).parse::<bool>().unwrap_or(true);
if register_commands { if register_commands {
let builder = poise::builtins::create_application_commands(&framework.options().commands); let builder = poise::builtins::create_application_commands(&framework.options().commands);
let commands = serenity::Command::set_global_commands(&ctx.http, builder).await; let commands = Command::set_global_commands(&ctx.http, builder).await;
match commands { match commands {
Ok(cmdmap) => for command in cmdmap.iter() { Ok(cmdmap) => for command in cmdmap.iter() {