Skip to content

Commit c8ca64e

Browse files
authored
Merge pull request #220 from Rustmail/219-release-command
feat(commands): add release command
2 parents 4d25e70 + 05dda65 commit c8ca64e

54 files changed

Lines changed: 439 additions & 117 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

rustmail/src/api/handler/auth/login.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use crate::api::utils::get_user_id_from_session::get_user_id_from_session;
21
use crate::BotState;
2+
use crate::api::utils::get_user_id_from_session::get_user_id_from_session;
33
use axum::extract::{Query, State};
44
use axum::response::Redirect;
55
use axum_extra::extract::CookieJar;
6-
use sqlx::{query, Row};
6+
use sqlx::{Row, query};
77
use std::collections::HashMap;
88
use std::sync::Arc;
99
use tokio::sync::Mutex;

rustmail/src/bot.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::commands::CommandRegistry;
12
use crate::commands::add_reminder::slash_command::add_reminder::AddReminderCommand;
23
use crate::commands::add_staff::slash_command::add_staff::AddStaffCommand;
34
use crate::commands::alert::slash_command::alert::AlertCommand;
@@ -11,14 +12,14 @@ use crate::commands::logs::slash_command::logs::LogsCommand;
1112
use crate::commands::move_thread::slash_command::move_thread::MoveCommand;
1213
use crate::commands::new_thread::slash_command::new_thread::NewThreadCommand;
1314
use crate::commands::recover::slash_command::recover::RecoverCommand;
15+
use crate::commands::release::slash_command::release::ReleaseCommand;
1416
use crate::commands::remove_reminder::slash_command::remove_reminder::RemoveReminderCommand;
1517
use crate::commands::remove_staff::slash_command::remove_staff::RemoveStaffCommand;
1618
use crate::commands::reply::slash_command::reply::ReplyCommand;
1719
use crate::commands::take::slash_command::take::TakeCommand;
18-
use crate::commands::CommandRegistry;
1920
use crate::config::load_config;
20-
use crate::errors::types::ConfigError;
2121
use crate::errors::ModmailError;
22+
use crate::errors::types::ConfigError;
2223
use crate::handlers::guild_handler::GuildHandler;
2324
use crate::handlers::guild_interaction_handler::InteractionHandler;
2425
use crate::handlers::guild_members_handler::GuildMembersHandler;
@@ -29,7 +30,7 @@ use crate::handlers::ready_handler::ReadyHandler;
2930
use crate::handlers::typing_proxy_handler::TypingProxyHandler;
3031
use crate::panel_commands::user::is_member::is_member;
3132
use crate::types::logs::PaginationContext;
32-
use crate::{db, BotCommand, BotState, BotStatus};
33+
use crate::{BotCommand, BotState, BotStatus, db};
3334
use base64::Engine;
3435
use rand::RngCore;
3536
use serenity::all::{ClientBuilder, GatewayIntents};
@@ -162,6 +163,7 @@ pub async fn run_bot(
162163
registry.register_command(RemoveReminderCommand);
163164
registry.register_command(LogsCommand);
164165
registry.register_command(TakeCommand);
166+
registry.register_command(ReleaseCommand);
165167

166168
let registry = Arc::new(registry);
167169

rustmail/src/commands/add_reminder/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::config::Config;
2-
use crate::db::reminders::{is_reminder_active, update_reminder_status, Reminder};
2+
use crate::db::reminders::{Reminder, is_reminder_active, update_reminder_status};
33
use crate::utils::conversion::hex_string_to_int::hex_string_to_int;
44
use crate::utils::message::message_builder::MessageBuilder;
55
use chrono::Local;

rustmail/src/commands/add_reminder/slash_command/add_reminder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ use crate::commands::add_reminder::common::{
33
};
44
use crate::commands::{BoxFuture, RegistrableCommand};
55
use crate::config::Config;
6-
use crate::db::reminders::{insert_reminder, Reminder};
6+
use crate::db::reminders::{Reminder, insert_reminder};
77
use crate::db::threads::get_thread_by_user_id;
8-
use crate::errors::{common, CommandError, ModmailError, ModmailResult, ThreadError};
8+
use crate::errors::{CommandError, ModmailError, ModmailResult, ThreadError, common};
99
use crate::handlers::guild_interaction_handler::InteractionHandler;
1010
use crate::i18n::get_translated_message;
1111
use crate::utils::command::defer_response::defer_response;
1212
use chrono::{Local, NaiveTime, TimeZone};
1313
use regex::Regex;
14+
use serenity::FutureExt;
1415
use serenity::all::{
1516
CommandDataOptionValue, CommandInteraction, CommandOptionType, Context, CreateCommand,
1617
CreateCommandOption, ResolvedOption,
1718
};
18-
use serenity::FutureExt;
1919
use std::sync::Arc;
2020

2121
pub struct AddReminderCommand;

rustmail/src/commands/add_reminder/text_command/add_reminder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ use crate::commands::add_reminder::common::{
22
send_register_confirmation_from_message, spawn_reminder,
33
};
44
use crate::config::Config;
5-
use crate::db::reminders::{insert_reminder, Reminder};
5+
use crate::db::reminders::{Reminder, insert_reminder};
66
use crate::db::threads::get_thread_by_user_id;
7-
use crate::errors::{common, CommandError, ModmailError, ModmailResult, ThreadError};
7+
use crate::errors::{CommandError, ModmailError, ModmailResult, ThreadError, common};
88
use crate::handlers::guild_messages_handler::GuildMessagesHandler;
99
use crate::utils::command::extract_reply_content::extract_reply_content;
1010
use chrono::{Local, NaiveTime, TimeZone};

rustmail/src/commands/add_staff/slash_command/add_staff.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ use crate::config::Config;
44
use crate::db::thread_exists;
55
use crate::errors::CommandError::InvalidFormat;
66
use crate::errors::ThreadError::NotAThreadChannel;
7-
use crate::errors::{common, CommandError, ModmailError, ModmailResult};
7+
use crate::errors::{CommandError, ModmailError, ModmailResult, common};
88
use crate::handlers::guild_interaction_handler::InteractionHandler;
99
use crate::i18n::get_translated_message;
1010
use crate::utils::command::defer_response::defer_response;
1111
use crate::utils::message::message_builder::MessageBuilder;
12+
use serenity::FutureExt;
1213
use serenity::all::{
1314
CommandDataOptionValue, CommandInteraction, CommandOptionType, Context, CreateCommand,
1415
CreateCommandOption, ResolvedOption,
1516
};
1617
use std::collections::HashMap;
1718
use std::sync::Arc;
18-
use serenity::FutureExt;
1919

2020
pub struct AddStaffCommand;
2121

rustmail/src/commands/add_staff/text_command/add_staff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::config::Config;
44
use crate::db::thread_exists;
55
use crate::errors::CommandError::InvalidFormat;
66
use crate::errors::ThreadError::NotAThreadChannel;
7-
use crate::errors::{common, ModmailError, ModmailResult};
7+
use crate::errors::{ModmailError, ModmailResult, common};
88
use crate::handlers::guild_messages_handler::GuildMessagesHandler;
99
use crate::utils::message::message_builder::MessageBuilder;
1010
use serenity::all::{Context, Message, UserId};

rustmail/src/commands/alert/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::db::{cancel_alert_for_staff, get_user_id_from_channel_id, set_alert_f
33
use crate::errors::CommandError::AlertDoesNotExist;
44
use crate::errors::DatabaseError::QueryFailed;
55
use crate::errors::DiscordError::ApiError;
6-
use crate::errors::{common, ModmailError, ModmailResult};
6+
use crate::errors::{ModmailError, ModmailResult, common};
77
use crate::utils::message::message_builder::MessageBuilder;
88
use serenity::all::colours::branding::GREEN;
99
use serenity::all::{CommandInteraction, Context, CreateInteractionResponse, Message};

rustmail/src/commands/alert/slash_command/alert.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ use crate::commands::alert::common::{
44
};
55
use crate::commands::{BoxFuture, RegistrableCommand};
66
use crate::config::Config;
7-
use crate::errors::{common, CommandError, ModmailError, ModmailResult};
7+
use crate::errors::{CommandError, ModmailError, ModmailResult, common};
88
use crate::handlers::guild_interaction_handler::InteractionHandler;
99
use crate::i18n::get_translated_message;
1010
use crate::utils::command::defer_response::defer_response;
11+
use serenity::FutureExt;
1112
use serenity::all::{
1213
CommandDataOptionValue, CommandInteraction, CommandOptionType, Context, CreateCommand,
1314
CreateCommandOption, ResolvedOption,
1415
};
1516
use std::sync::Arc;
16-
use serenity::FutureExt;
1717

1818
pub struct AlertCommand;
1919

@@ -24,9 +24,8 @@ impl RegistrableCommand for AlertCommand {
2424
}
2525

2626
fn doc<'a>(&self, config: &'a Config) -> BoxFuture<'a, String> {
27-
async move {
28-
get_translated_message(config, "help.alert", None, None, None, None).await
29-
}.boxed()
27+
async move { get_translated_message(config, "help.alert", None, None, None, None).await }
28+
.boxed()
3029
}
3130

3231
fn register(&self, config: &Config) -> BoxFuture<'_, Vec<CreateCommand>> {

rustmail/src/commands/alert/text_command/alert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::commands::alert::common::{
33
handle_set_alert_from_msg,
44
};
55
use crate::config::Config;
6-
use crate::errors::{common, ModmailResult};
6+
use crate::errors::{ModmailResult, common};
77
use crate::handlers::guild_messages_handler::GuildMessagesHandler;
88
use serenity::all::{Context, Message};
99
use std::sync::Arc;

0 commit comments

Comments
 (0)