Make more args reqd

This commit is contained in:
shibedrill 2024-04-25 15:18:14 -04:00
parent 23d84511c9
commit b6d6581301

View File

@ -54,13 +54,11 @@ pub async fn info(ctx: Context<'_>) -> Result<(), Error> {
#[poise::command(slash_command)] #[poise::command(slash_command)]
pub async fn add_channel( pub async fn add_channel(
ctx: Context<'_>, ctx: Context<'_>,
#[description = "Selected channel"] channel: Option<serenity::Channel>, #[description = "Selected channel"] channel: serenity::Channel,
) -> Result<(), Error> { ) -> Result<(), Error> {
ctx.defer_ephemeral().await?;
if let Some(channel_ok) = channel {
let config = &mut ctx.data().config_manager.lock().await; let config = &mut ctx.data().config_manager.lock().await;
let channel_id = { u64::from(channel_ok.id()) }; let channel_id = { u64::from(channel.id()) };
config.channels.push(channel_ok); config.channels.push(channel);
config.store().unwrap(); config.store().unwrap();
ctx.say(format!( ctx.say(format!(
"Successfully added <#{}> to the channel registry.", "Successfully added <#{}> to the channel registry.",
@ -68,10 +66,6 @@ pub async fn add_channel(
)) ))
.await?; .await?;
info!("Executed command `add_channel` successfully"); info!("Executed command `add_channel` successfully");
} else {
ctx.say("Channel with supplied ID was not found.").await?;
error!("Failed to execute command `add_channel`");
}
Ok(()) Ok(())
} }
@ -79,13 +73,12 @@ pub async fn add_channel(
#[poise::command(slash_command)] #[poise::command(slash_command)]
pub async fn remove_channel( pub async fn remove_channel(
ctx: Context<'_>, ctx: Context<'_>,
#[description = "Selected channel"] channel: Option<serenity::Channel>, #[description = "Selected channel"] channel: serenity::Channel,
) -> Result<(), Error> { ) -> Result<(), Error> {
ctx.defer_ephemeral().await?; ctx.defer_ephemeral().await?;
if let Some(channel_ok) = channel {
let config = &mut ctx.data().config_manager.lock().await; let config = &mut ctx.data().config_manager.lock().await;
let channel_id = { u64::from(channel_ok.id()) }; let channel_id = { u64::from(channel.id()) };
config.channels.retain(|c| c.id() != channel_ok.id()); config.channels.retain(|c| c.id() != channel.id());
config.store().unwrap(); config.store().unwrap();
ctx.say(format!( ctx.say(format!(
"Successfully removed <#{}> from the channel registry.", "Successfully removed <#{}> from the channel registry.",
@ -93,10 +86,6 @@ pub async fn remove_channel(
)) ))
.await?; .await?;
info!("Executed command `remove_channel` successfully"); info!("Executed command `remove_channel` successfully");
} else {
ctx.say("Channel with supplied ID was not found.").await?;
error!("Failed to execute command `remove_channel`.");
}
Ok(()) Ok(())
} }