diff --git a/src/command/util.rs b/src/command/util.rs index 552e194..db8d22f 100644 --- a/src/command/util.rs +++ b/src/command/util.rs @@ -36,12 +36,14 @@ pub async fn add_channel( ) -> Result<(), Error> { if let Some(channel_ok) = channel { let config = &mut ctx.data().config_manager.lock().await; - let channel_id = { - u64::from(channel_ok.id()) - }; + let channel_id = { u64::from(channel_ok.id()) }; config.channels.push(channel_id); config.store().unwrap(); - ctx.say(format!("Successfully added <#{}> to the channel registry.", channel_id)).await?; + ctx.say(format!( + "Successfully added <#{}> to the channel registry.", + channel_id + )) + .await?; info!("Executed command `add_channel` successfully"); } else { ctx.say("Channel with supplied ID was not found.").await?; @@ -53,7 +55,11 @@ pub async fn add_channel( #[poise::command(slash_command)] pub async fn list_channels(ctx: Context<'_>) -> Result<(), Error> { let config = &mut ctx.data().config_manager.lock().await; - ctx.say(format!("Current channel IDs in registry: {:#?}", config.channels)).await?; + ctx.say(format!( + "Current channel IDs in registry: {:#?}", + config.channels + )) + .await?; info!("Executed command `list_channels` successfully"); Ok(()) -} \ No newline at end of file +} diff --git a/src/main.rs b/src/main.rs index 79e01df..2279180 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,4 @@ - -use std::sync::{Arc}; +use std::sync::Arc; use tokio::sync::Mutex; use dotenv::dotenv; @@ -13,12 +12,15 @@ extern crate log; use serde::*; mod command; -use crate::{command::{fun::*, util::*}, settings::SettingsManager}; +use crate::{ + command::{fun::*, util::*}, + settings::SettingsManager, +}; mod settings; struct Data { - config_manager: Arc>> + config_manager: Arc>>, } // User data, which is stored and accessible in all command invocations type Error = Box; type Context<'a> = poise::Context<'a, Data, Error>; @@ -54,7 +56,7 @@ async fn main() { .setup(|ctx, _ready, framework| { Box::pin(async move { poise::builtins::register_globally(ctx, &framework.options().commands).await?; - Ok(Data {config_manager}) + Ok(Data { config_manager }) }) }) .build(); diff --git a/src/settings.rs b/src/settings.rs index 4f0e647..ddaa68d 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -36,7 +36,7 @@ impl Deserialize<'a>> SettingsManager { /// Serialize settings structure to the stored path. Returns None if /// unsuccessful. pub fn store(&self) -> Option<()> { - let data = serde_json::to_string(&self.internal).ok()?; + let data = serde_json::to_string_pretty(&self.internal).ok()?; let mut file = std::fs::File::create(&self.path).ok()?; let _ = file.write(data.as_bytes()); Some(()) @@ -63,4 +63,4 @@ impl Deserialize<'a>> DerefMut for SettingsManager { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.internal } -} \ No newline at end of file +}