summaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
authorseth <[email protected]>2023-12-15 03:17:20 -0500
committerseth <[email protected]>2023-12-15 16:41:13 -0500
commit8d22f09089b13d013cf94526c205f374bdf873c3 (patch)
tree505c864e5683e6ece7d2ead2f9e019b8cc797548 /src/commands
parentebdcc85dc7c80796446535fa2799bb62f2c12aac (diff)
enable clippy::all, clippy::pedantic, & clippy::perf
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/general/ask.rs4
-rw-r--r--src/commands/general/config.rs43
-rw-r--r--src/commands/general/convert.rs1
-rw-r--r--src/commands/general/random.rs1
-rw-r--r--src/commands/mod.rs4
-rw-r--r--src/commands/optional/copypasta.rs8
-rw-r--r--src/commands/optional/teawiespam.rs2
7 files changed, 30 insertions, 33 deletions
diff --git a/src/commands/general/ask.rs b/src/commands/general/ask.rs
index 3f225bb..ba18bdd 100644
--- a/src/commands/general/ask.rs
+++ b/src/commands/general/ask.rs
@@ -6,9 +6,7 @@ use color_eyre::eyre::{Context as _, Result};
#[poise::command(prefix_command, slash_command)]
pub async fn ask(
ctx: Context<'_>,
- #[description = "The question you want to ask teawie"]
- #[rename = "Question"]
- _question: String,
+ #[description = "The question you want to ask teawie"] _question: String,
) -> Result<()> {
let resp = utils::random_choice(consts::RESPONSES)
.wrap_err("Couldn't choose from random responses!")?;
diff --git a/src/commands/general/config.rs b/src/commands/general/config.rs
index f308f31..358ee69 100644
--- a/src/commands/general/config.rs
+++ b/src/commands/general/config.rs
@@ -1,13 +1,13 @@
use std::str::FromStr;
use crate::{storage, Context};
-use storage::{Settings, SettingsProperties};
+use storage::{Properties, Settings};
use color_eyre::eyre::{eyre, Result};
-use log::*;
+use log::debug;
use poise::serenity_prelude::{GuildChannel, ReactionType};
-fn split_argument<T>(list: String) -> Vec<T>
+fn split_argument<T>(list: &str) -> Vec<T>
where
T: FromStr,
{
@@ -16,24 +16,23 @@ where
.collect()
}
-fn prop_to_val(setting: &SettingsProperties, settings: &Settings) -> String {
+fn prop_to_val(setting: &Properties, settings: &Settings) -> String {
match setting {
- SettingsProperties::GuildId => settings.guild_id.to_string(),
- SettingsProperties::PinBoardChannel => format!("{:#?}", settings.pinboard_channel),
- SettingsProperties::PinBoardWatch => format!("{:#?}", settings.pinboard_watch),
- SettingsProperties::PinBoardEnabled => settings.pinboard_enabled.to_string(),
- SettingsProperties::ReactBoardChannel => format!("{:#?}", settings.reactboard_channel),
- SettingsProperties::ReactBoardRequirement => {
+ Properties::GuildId => settings.guild_id.to_string(),
+ Properties::PinBoardChannel => format!("{:#?}", settings.pinboard_channel),
+ Properties::PinBoardWatch => format!("{:#?}", settings.pinboard_watch),
+ Properties::PinBoardEnabled => settings.pinboard_enabled.to_string(),
+ Properties::ReactBoardChannel => format!("{:#?}", settings.reactboard_channel),
+ Properties::ReactBoardRequirement => {
format!("{:?}", settings.reactboard_requirement)
}
- SettingsProperties::ReactBoardReactions => format!("{:?}", settings.reactboard_reactions),
- SettingsProperties::ReactBoardEnabled => settings.reactboard_enabled.to_string(),
- SettingsProperties::OptionalCommandsEnabled => {
- settings.optional_commands_enabled.to_string()
- }
+ Properties::ReactBoardReactions => format!("{:?}", settings.reactboard_reactions),
+ Properties::ReactBoardEnabled => settings.reactboard_enabled.to_string(),
+ Properties::OptionalCommandsEnabled => settings.optional_commands_enabled.to_string(),
}
}
+#[allow(clippy::unused_async)]
#[poise::command(
slash_command,
prefix_command,
@@ -84,7 +83,7 @@ pub async fn set(
}
if let Some(watch) = pinboard_watch {
- let channels = split_argument(watch);
+ let channels = split_argument(&watch);
debug!("Setting pinboard_watch to {channels:#?} for {gid}");
settings.pinboard_watch = Some(channels);
@@ -123,14 +122,14 @@ pub async fn set(
settings.optional_commands_enabled = enabled;
}
- if previous_settings != settings {
- debug!("Updating settings key for {gid}");
- storage.create_guild_settings(settings).await?;
- ctx.reply("Configuration updated!").await?;
- } else {
+ if previous_settings == settings {
debug!("Not updating settings key for {gid} since no changes were made");
ctx.reply("No changes made, so i'm not updating anything")
.await?;
+ } else {
+ debug!("Updating settings key for {gid}");
+ storage.create_guild_settings(settings).await?;
+ ctx.reply("Configuration updated!").await?;
}
Ok(())
@@ -146,7 +145,7 @@ pub async fn set(
)]
pub async fn get(
ctx: Context<'_>,
- #[description = "The setting you want to get"] setting: SettingsProperties,
+ #[description = "The setting you want to get"] setting: Properties,
) -> Result<()> {
let gid = &ctx
.guild_id()
diff --git a/src/commands/general/convert.rs b/src/commands/general/convert.rs
index c00b4b8..5c41dfd 100644
--- a/src/commands/general/convert.rs
+++ b/src/commands/general/convert.rs
@@ -3,6 +3,7 @@ use crate::Context;
use bottomify::bottom;
use color_eyre::eyre::Result;
+#[allow(clippy::unused_async)]
#[poise::command(
slash_command,
subcommands("to_fahrenheit", "to_celsius", "to_bottom", "from_bottom")
diff --git a/src/commands/general/random.rs b/src/commands/general/random.rs
index 286d04e..477001e 100644
--- a/src/commands/general/random.rs
+++ b/src/commands/general/random.rs
@@ -2,6 +2,7 @@ use crate::{api, consts, utils, Context};
use color_eyre::eyre::Result;
+#[allow(clippy::unused_async)]
#[poise::command(slash_command, subcommands("lore", "teawie", "shiggy"))]
pub async fn random(_ctx: Context<'_>) -> Result<()> {
Ok(())
diff --git a/src/commands/mod.rs b/src/commands/mod.rs
index df2d857..b20258c 100644
--- a/src/commands/mod.rs
+++ b/src/commands/mod.rs
@@ -6,10 +6,10 @@ use poise::Command;
mod general;
mod optional;
-pub fn to_global_commands() -> Vec<Command<Data, Report>> {
+pub fn global() -> Vec<Command<Data, Report>> {
general::to_comands()
}
-pub fn to_optional_commands() -> Vec<Command<Data, Report>> {
+pub fn optional() -> Vec<Command<Data, Report>> {
optional::to_commands()
}
diff --git a/src/commands/optional/copypasta.rs b/src/commands/optional/copypasta.rs
index 54b6194..6ed4f95 100644
--- a/src/commands/optional/copypasta.rs
+++ b/src/commands/optional/copypasta.rs
@@ -4,7 +4,7 @@ use std::collections::HashMap;
use color_eyre::eyre::{eyre, Result};
use include_dir::{include_dir, Dir};
-use log::*;
+use log::debug;
const FILES: Dir = include_dir!("src/copypastas");
@@ -34,7 +34,7 @@ impl Copypastas {
}
}
-fn get_copypasta(name: Copypastas) -> Result<String> {
+fn get_copypasta(name: &Copypastas) -> Result<String> {
let mut files: HashMap<&str, &str> = HashMap::new();
for file in FILES.files() {
@@ -66,8 +66,6 @@ pub async fn copypasta(
ctx: Context<'_>,
#[description = "the copypasta you want to send"] copypasta: Copypastas,
) -> Result<()> {
- debug!("Running copypasta command with copypasta {copypasta}");
-
let gid = ctx.guild_id().unwrap_or_default();
let settings = ctx.data().storage.get_guild_settings(&gid).await?;
@@ -76,7 +74,7 @@ pub async fn copypasta(
return Ok(());
}
- ctx.say(get_copypasta(copypasta)?).await?;
+ ctx.say(get_copypasta(&copypasta)?).await?;
Ok(())
}
diff --git a/src/commands/optional/teawiespam.rs b/src/commands/optional/teawiespam.rs
index a876d09..fd635ff 100644
--- a/src/commands/optional/teawiespam.rs
+++ b/src/commands/optional/teawiespam.rs
@@ -1,7 +1,7 @@
use crate::Context;
use color_eyre::eyre::Result;
-use log::*;
+use log::debug;
/// teawie will spam you.
#[poise::command(slash_command, prefix_command)]