summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorseth <[email protected]>2023-11-16 23:19:29 -0500
committerseth <[email protected]>2023-11-18 01:42:03 +0000
commit13b54108494b7492b3772ff477ed9a02c56c7972 (patch)
tree416247f2cb3404613f60373b59f65c592ce19173 /src
parent86318aa4aa8a7547e6398342a0c7b609e307dd5d (diff)
chore: cleanup imports
Diffstat (limited to 'src')
-rw-r--r--src/commands/ask.rs4
-rw-r--r--src/commands/convert.rs6
-rw-r--r--src/commands/copypasta.rs7
-rw-r--r--src/handler/pinboard.rs9
-rw-r--r--src/utils.rs5
5 files changed, 16 insertions, 15 deletions
diff --git a/src/commands/ask.rs b/src/commands/ask.rs
index 5075b9d..7cc82a1 100644
--- a/src/commands/ask.rs
+++ b/src/commands/ask.rs
@@ -1,5 +1,5 @@
use crate::consts;
-use crate::utils::random_choice;
+use crate::utils;
use crate::{Context, Error};
/// ask teawie a question!
@@ -10,7 +10,7 @@ pub async fn ask(
#[rename = "question"]
_question: String,
) -> Result<(), Error> {
- match random_choice(consts::RESPONSES) {
+ match utils::random_choice(consts::RESPONSES) {
Ok(resp) => {
ctx.say(resp).await?;
Ok(())
diff --git a/src/commands/convert.rs b/src/commands/convert.rs
index 4e5d71c..1f39ae4 100644
--- a/src/commands/convert.rs
+++ b/src/commands/convert.rs
@@ -1,5 +1,5 @@
use crate::{Context, Error};
-use bottomify::bottom::{decode_string, encode_string};
+use bottomify::bottom;
#[poise::command(
slash_command,
@@ -37,7 +37,7 @@ pub async fn to_bottom(
ctx: Context<'_>,
#[description = "what teawie will translate into bottom"] message: String,
) -> Result<(), Error> {
- let encoded = encode_string(&message);
+ let encoded = bottom::encode_string(&message);
ctx.say(encoded).await?;
Ok(())
}
@@ -48,7 +48,7 @@ pub async fn from_bottom(
ctx: Context<'_>,
#[description = "what teawie will translate from bottom"] message: String,
) -> Result<(), Error> {
- let d = decode_string(&message);
+ let d = bottom::decode_string(&message);
match d {
Ok(decoded) => {
ctx.say(decoded).await?;
diff --git a/src/commands/copypasta.rs b/src/commands/copypasta.rs
index 90d3b0a..14a6673 100644
--- a/src/commands/copypasta.rs
+++ b/src/commands/copypasta.rs
@@ -1,8 +1,9 @@
-use crate::utils;
-use crate::{Context, Error};
+use crate::{utils, Context, Error};
+
+use std::collections::HashMap;
+
use include_dir::{include_dir, Dir};
use log::*;
-use std::collections::HashMap;
const FILES: Dir = include_dir!("src/copypastas");
diff --git a/src/handler/pinboard.rs b/src/handler/pinboard.rs
index 56f53b4..02dfdf9 100644
--- a/src/handler/pinboard.rs
+++ b/src/handler/pinboard.rs
@@ -1,4 +1,5 @@
-use crate::utils::{floor_char_boundary, parse_snowflake_from_env, parse_snowflakes_from_env};
+use crate::utils;
+
use log::*;
use poise::serenity_prelude::model::prelude::*;
use poise::serenity_prelude::Context;
@@ -10,10 +11,10 @@ pub struct PinBoard {
}
impl PinBoard {
pub fn new() -> Option<Self> {
- let Some(target) = parse_snowflake_from_env("PIN_BOARD_TARGET", ChannelId) else {
+ let Some(target) = utils::parse_snowflake_from_env("PIN_BOARD_TARGET", ChannelId) else {
return None;
};
- let sources = parse_snowflakes_from_env("PIN_BOARD_SOURCES", ChannelId);
+ let sources = utils::parse_snowflakes_from_env("PIN_BOARD_SOURCES", ChannelId);
Some(Self { sources, target })
}
@@ -43,7 +44,7 @@ impl PinBoard {
async fn redirect(&self, ctx: &Context, pin: &Message, pinner: Option<UserId>) {
let pinner = pinner.map_or("*someone*".to_owned(), |u| format!("<@{u}>"));
- let truncation_point = floor_char_boundary(&pin.content, 700);
+ let truncation_point = utils::floor_char_boundary(&pin.content, 700);
let truncated_content = if pin.content.len() <= truncation_point {
pin.content.to_string()
} else {
diff --git a/src/utils.rs b/src/utils.rs
index 8773b14..780ecc9 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -1,5 +1,4 @@
-use crate::consts::*;
-use crate::Error;
+use crate::{consts, Error};
use once_cell::sync::Lazy;
use poise::serenity_prelude::GuildId;
@@ -46,7 +45,7 @@ pub fn floor_char_boundary(s: &str, index: usize) -> usize {
pub fn is_guild_allowed(gid: GuildId) -> bool {
static ALLOWED_GUILDS: Lazy<Vec<GuildId>> = Lazy::new(|| {
parse_snowflakes_from_env("ALLOWED_GUILDS", GuildId)
- .unwrap_or_else(|| vec![TEAWIE_GUILD, GuildId(1091969030694375444)])
+ .unwrap_or_else(|| vec![consts::TEAWIE_GUILD, GuildId(1091969030694375444)])
});
ALLOWED_GUILDS.contains(&gid)