Refactored GeoffreyBot module layout

main
Joey Hines 2021-12-03 19:33:29 -07:00
parent d3b8b4ae1d
commit 8d858bdfd3
No known key found for this signature in database
GPG Key ID: 80F567B5C968F91B
7 changed files with 61 additions and 45 deletions

View File

@ -1,7 +1,4 @@
use crate::commands::bot_command::{BotCommand, CommandError};
use async_trait::async_trait; use async_trait::async_trait;
use geoffrey_models::models::locations::Location;
use geoffrey_models::models::parameters::add_item_params::AddItemParams;
use reqwest::Method; use reqwest::Method;
use serenity::client::Context; use serenity::client::Context;
use serenity::model::interactions::application_command::{ use serenity::model::interactions::application_command::{
@ -9,6 +6,11 @@ use serenity::model::interactions::application_command::{
}; };
use serenity::model::prelude::application_command::ApplicationCommandInteractionDataOptionValue; use serenity::model::prelude::application_command::ApplicationCommandInteractionDataOptionValue;
use geoffrey_models::models::locations::Location;
use geoffrey_models::models::parameters::add_item_params::AddItemParams;
use crate::bot::commands::{BotCommand, CommandError};
pub struct AddItemCommand; pub struct AddItemCommand;
#[async_trait] #[async_trait]

View File

@ -1,8 +1,6 @@
use crate::commands::bot_command::{BotCommand, CommandError}; use std::str::FromStr;
use async_trait::async_trait; use async_trait::async_trait;
use geoffrey_models::models::locations::{Location, LocationType};
use geoffrey_models::models::parameters::add_location_params::AddLocationParams;
use geoffrey_models::models::{Dimension, Position};
use reqwest::Method; use reqwest::Method;
use serenity::client::Context; use serenity::client::Context;
use serenity::model::interactions::application_command::{ use serenity::model::interactions::application_command::{
@ -10,7 +8,12 @@ use serenity::model::interactions::application_command::{
ApplicationCommandOptionType, ApplicationCommandOptionType,
}; };
use serenity::model::prelude::application_command::ApplicationCommandInteractionDataOptionValue; use serenity::model::prelude::application_command::ApplicationCommandInteractionDataOptionValue;
use std::str::FromStr;
use geoffrey_models::models::{Dimension, Position};
use geoffrey_models::models::locations::{Location, LocationType};
use geoffrey_models::models::parameters::add_location_params::AddLocationParams;
use crate::bot::commands::{BotCommand, CommandError};
pub struct AddLocationCommand; pub struct AddLocationCommand;

View File

@ -1,14 +1,17 @@
use crate::commands::bot_command::{BotCommand, CommandError}; use std::fmt::Write;
use async_trait::async_trait; use async_trait::async_trait;
use geoffrey_models::models::locations::Location;
use geoffrey_models::models::parameters::find_params::FindParams;
use reqwest::Method; use reqwest::Method;
use serenity::client::Context; use serenity::client::Context;
use serenity::model::interactions::application_command::{ use serenity::model::interactions::application_command::{
ApplicationCommand, ApplicationCommandInteraction, ApplicationCommandOptionType, ApplicationCommand, ApplicationCommandInteraction, ApplicationCommandOptionType,
}; };
use serenity::model::prelude::application_command::ApplicationCommandInteractionDataOptionValue; use serenity::model::prelude::application_command::ApplicationCommandInteractionDataOptionValue;
use std::fmt::Write;
use geoffrey_models::models::locations::Location;
use geoffrey_models::models::parameters::find_params::FindParams;
use crate::bot::commands::{BotCommand, CommandError};
pub struct FindCommand; pub struct FindCommand;

View File

@ -1,17 +1,25 @@
use crate::context::GeoffreyContext; use std::fmt::{Display, Formatter};
use async_trait::async_trait; use async_trait::async_trait;
use reqwest::Error;
use serde::de::DeserializeOwned;
use serde::Serialize;
use serenity::client::Context;
use serenity::Error as SerenityError;
use serenity::model::interactions::application_command::{ApplicationCommand, ApplicationCommandInteraction};
use geoffrey_models::models::parameters::CommandRequest; use geoffrey_models::models::parameters::CommandRequest;
use geoffrey_models::models::player::UserID; use geoffrey_models::models::player::UserID;
use geoffrey_models::models::response::api_error::GeoffreyAPIError; use geoffrey_models::models::response::api_error::GeoffreyAPIError;
use geoffrey_models::models::response::APIResponse; use geoffrey_models::models::response::APIResponse;
use reqwest::Error;
use serde::de::DeserializeOwned; use crate::context::GeoffreyContext;
use serde::Serialize;
use serenity::model::prelude::application_command::{ pub mod add_item;
ApplicationCommand, ApplicationCommandInteraction, pub mod add_location;
}; mod arg_parse;
use serenity::prelude::{Context, SerenityError}; pub mod find;
use std::fmt::{Display, Formatter}; pub mod selling;
#[derive(Debug)] #[derive(Debug)]
pub enum CommandError { pub enum CommandError {

View File

@ -1,15 +1,18 @@
use crate::commands::bot_command::{BotCommand, CommandError}; use std::fmt::Write;
use std::str::FromStr;
use async_trait::async_trait; use async_trait::async_trait;
use geoffrey_models::models::parameters::selling_params::{ItemSort, Order, SellingParams};
use geoffrey_models::models::response::selling_listing::SellingListing;
use reqwest::Method; use reqwest::Method;
use serenity::client::Context; use serenity::client::Context;
use serenity::model::interactions::application_command::{ use serenity::model::interactions::application_command::{
ApplicationCommand, ApplicationCommandInteraction, ApplicationCommandOptionType, ApplicationCommand, ApplicationCommandInteraction, ApplicationCommandOptionType,
}; };
use serenity::model::prelude::application_command::ApplicationCommandInteractionDataOptionValue; use serenity::model::prelude::application_command::ApplicationCommandInteractionDataOptionValue;
use std::fmt::Write;
use std::str::FromStr; use geoffrey_models::models::parameters::selling_params::{ItemSort, Order, SellingParams};
use geoffrey_models::models::response::selling_listing::SellingListing;
use crate::bot::commands::{BotCommand, CommandError};
pub struct SellingCommand; pub struct SellingCommand;

View File

@ -1,17 +1,14 @@
pub mod add_item;
pub mod add_location;
pub mod bot_command;
pub mod find;
pub mod selling;
use crate::commands::add_item::AddItemCommand;
use crate::commands::add_location::AddLocationCommand;
use crate::commands::bot_command::{BotCommand, CommandError};
use crate::commands::find::FindCommand;
use crate::commands::selling::SellingCommand;
use serenity::model::interactions::application_command::ApplicationCommand; use serenity::model::interactions::application_command::ApplicationCommand;
use serenity::prelude::*; use serenity::prelude::*;
use commands::{BotCommand, CommandError};
use commands::add_item::AddItemCommand;
use commands::add_location::AddLocationCommand;
use commands::find::FindCommand;
use commands::selling::SellingCommand;
pub mod commands;
pub async fn create_commands(ctx: &Context) -> Result<Vec<ApplicationCommand>, CommandError> { pub async fn create_commands(ctx: &Context) -> Result<Vec<ApplicationCommand>, CommandError> {
let mut commands: Vec<ApplicationCommand> = Vec::new(); let mut commands: Vec<ApplicationCommand> = Vec::new();

View File

@ -1,13 +1,13 @@
mod commands; mod bot;
mod configs; mod configs;
mod context; mod context;
use crate::commands::add_item::AddItemCommand; use bot::commands::add_item::AddItemCommand;
use crate::commands::add_location::AddLocationCommand; use bot::commands::add_location::AddLocationCommand;
use crate::commands::bot_command::BotCommand; use bot::commands::BotCommand;
use crate::commands::create_commands; use crate::bot::create_commands;
use crate::commands::find::FindCommand; use bot::commands::find::FindCommand;
use crate::commands::selling::SellingCommand; use bot::commands::selling::SellingCommand;
use crate::configs::GeoffreyBotConfig; use crate::configs::GeoffreyBotConfig;
use crate::context::GeoffreyContext; use crate::context::GeoffreyContext;
use geoffrey_models::models::player::UserID; use geoffrey_models::models::player::UserID;
@ -44,7 +44,7 @@ impl EventHandler for Handler {
println!("{} is connected!", ready.user.name); println!("{} is connected!", ready.user.name);
let commands = create_commands(&ctx).await.unwrap(); let commands = create_commands(&ctx).await.unwrap();
println!("The following commands have been registered:"); println!("The following bot have been registered:");
for command in commands { for command in commands {
println!( println!(