Skip to content

Commit

Permalink
small changes and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwai committed Feb 18, 2024
1 parent 09fdee8 commit 63d77cc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
7 changes: 6 additions & 1 deletion src/bot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ pub async fn entrypoint(database_pool: Pool<MySql>, redis_client: Client) {
let db_clone = database_pool.clone();
let framework = Framework::builder()
.options(poise::FrameworkOptions {
commands: vec![commands::ping(), commands::logger_pipe(), commands::shutdown(), commands::setup()],
commands: vec![
commands::ping(),
commands::logger_pipe(),
commands::shutdown(),
commands::setup(),
],
allowed_mentions: Some({
serenity::CreateAllowedMentions::default()
.replied_user(true)
Expand Down
20 changes: 9 additions & 11 deletions src/bot/setup_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,13 @@ async fn kick_setup(
KICK_BASE_STRING,
ctx.prefix(),
KICK_COMMAND,
warning_deadline,
warning_deadline + 1,
skip_message
))
.await;
}
Some(number) => {
if !(warning_deadline..=28).contains(&number) {
if !(warning_deadline + 1..=28).contains(&number) {
let _ = ctx
.say(format!(
"{}\n{}\n`{}{}`\n\
Expand All @@ -245,7 +245,7 @@ async fn kick_setup(
KICK_BASE_STRING,
ctx.prefix(),
KICK_COMMAND,
warning_deadline,
warning_deadline + 1,
skip_message
))
.await;
Expand Down Expand Up @@ -1472,9 +1472,14 @@ pub async fn setup(
role_mention: Option<Role>,
channel_mention: Option<GuildChannel>,
flag: Option<bool>,
number: Option<u32>,
mut number: Option<u32>,
rest: Option<String>,
) -> Result<(), Error> {
if number.is_none() {
if let Some(flag) = flag {
number = Some(flag.into());
}
}
// Check permissions
if !checks::is_owner(ctx).await && !checks::is_admin(ctx).await {
ctx.say("Missing permissions, requires admin permissions")
Expand Down Expand Up @@ -1939,12 +1944,5 @@ pub async fn setup(
}
}

let _ = ctx
.say(format!(
"**Role Mention:** {:?}\n**Channel Mention:** {:?}\n**Number** {:?}\n**Rest:** {:?}",
role_mention, channel_mention, number, rest
))
.await;

Ok(())
}
16 changes: 6 additions & 10 deletions src/mysql_lib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,17 +482,13 @@ pub async fn delete_guild(pool: &Pool<MySql>, guild_id: GuildId) -> Option<bool>
/// Gets the guild information from the Database
#[allow(dead_code)]
pub async fn get_guild(pool: &Pool<MySql>, guild_id: GuildId) -> Option<DatabaseGuild> {
match sqlx::query_as::<_, DatabaseGuild>("SELECT * FROM Guild WHERE guild_id=?")
sqlx::query_as::<_, DatabaseGuild>("SELECT * FROM Guild WHERE guild_id=?")
.bind(guild_id.get())
.fetch_one(pool)
.await
{
Ok(val) => Some(val),
Err(err) => {
error!(error = err.to_string(), "Problem executing query");
None
}
}
.fetch_optional(pool)
.await.unwrap_or_else(|err| {
error!(error = err.to_string(), "Problem executing query");
None
})
}

/// Gets the guild information from the Database
Expand Down

0 comments on commit 63d77cc

Please sign in to comment.