diff --git a/src/commands/mod.rs b/src/commands/mod.rs
index 91cb0be..6b37cb7 100644
--- a/src/commands/mod.rs
+++ b/src/commands/mod.rs
@@ -1,5 +1,4 @@
-use std::sync::atomic::{AtomicU64, Ordering};
-
+use anyhow::Result;
use serenity::all::{CommandInteraction, Context, CreateCommand};
use sqlx::PgPool;
@@ -11,6 +10,7 @@ include!("./mod_gen.rs");
pub enum CommandCategory {
Moderation,
Utils,
+ Gestion,
}
impl CommandCategory {
@@ -18,6 +18,7 @@ impl CommandCategory {
match self {
Self::Utils => "🌐",
Self::Moderation => "🛡️",
+ Self::Gestion => "👑",
}
}
@@ -25,6 +26,7 @@ impl CommandCategory {
match self {
Self::Utils => "Utils",
Self::Moderation => "Moderation",
+ Self::Gestion => "Gestion",
}
}
}
@@ -34,15 +36,6 @@ pub trait SlashCommand: Send + Sync {
fn name(&self) -> &'static str;
fn description(&self) -> &'static str;
fn category(&self) -> &'static CommandCategory;
- fn command_id_ref(&self) -> &AtomicU64;
-
- fn get_id(&self) -> u64 {
- self.command_id_ref().load(Ordering::Relaxed)
- }
-
- fn set_id(&self, id: u64) {
- self.command_id_ref().store(id, Ordering::Relaxed);
- }
fn register(&self) -> CreateCommand;
@@ -52,7 +45,7 @@ pub trait SlashCommand: Send + Sync {
command: &CommandInteraction,
database: &PgPool,
_emoji: &EmojiConfig,
- ) -> Result<(), serenity::Error>;
+ ) -> Result<()>;
}
pub struct CommandEntry {
diff --git a/src/commands/utils/ping.rs b/src/commands/utils/ping.rs
index 1a5919e..1c3cc86 100644
--- a/src/commands/utils/ping.rs
+++ b/src/commands/utils/ping.rs
@@ -1,7 +1,4 @@
use std::{
- sync::atomic::{
- AtomicU64,
- },
time::Instant,
};
@@ -17,19 +14,10 @@ use serenity::all::{
CreateInteractionResponseMessage, EditInteractionResponse,
};
use sqlx::PgPool;
-use tracing::info;
+use tracing::{debug, info};
+use anyhow::Result;
-pub struct Ping {
- pub command_id: AtomicU64,
-}
-
-impl Ping {
- pub fn new() -> Self {
- Self {
- command_id: AtomicU64::new(0),
- }
- }
-}
+pub struct Ping;
#[serenity::async_trait]
impl SlashCommand for Ping {
@@ -45,10 +33,6 @@ impl SlashCommand for Ping {
&CommandCategory::Utils
}
- fn command_id_ref(&self) -> &AtomicU64 {
- &self.command_id
- }
-
fn register(&self) -> CreateCommand {
info!("\t✅ | {}", self.name());
CreateCommand::new(self.name()).description(self.description())
@@ -60,7 +44,8 @@ impl SlashCommand for Ping {
command: &CommandInteraction,
_database: &PgPool,
_emoji: &EmojiConfig,
- ) -> Result<(), serenity::Error> {
+ ) -> Result<()> {
+ debug!("Ping command called");
let message: CreateInteractionResponseMessage = CreateInteractionResponseMessage::new()
.content("🏓 | Pong!")
.ephemeral(true);
@@ -81,5 +66,5 @@ impl SlashCommand for Ping {
}
inventory::submit! {
- CommandEntry { create: || Box::new(Ping::new()) }
+ CommandEntry { create: || Box::new(Ping) }
}
diff --git a/src/database/bot.rs b/src/database/bot.rs
index 5819933..c895ec3 100644
--- a/src/database/bot.rs
+++ b/src/database/bot.rs
@@ -1,16 +1,17 @@
use sqlx::{PgPool, query, query_as};
use crate::models::bot::{DbBot, BotPresence, BotActivity};
+use anyhow::Result;
const BOT_ID: i32 = 1;
-pub async fn init(db: &PgPool) -> Result<(), sqlx::Error> {
+pub async fn init(db: &PgPool) -> Result<()> {
query!("INSERT INTO bots (id) VALUES ($1) ON CONFLICT DO NOTHING", BOT_ID)
.execute(db)
.await?;
Ok(())
}
-pub async fn get(db: &PgPool) -> Result