added template roster and gamedetail commands
This commit is contained in:
parent
031b2be817
commit
5e6ea6a57d
@ -73,7 +73,7 @@ pub async fn run(options: &[ResolvedOption<'_>]) -> String {
|
||||
|
||||
pub fn register() -> CreateCommand {
|
||||
CreateCommand::new("game")
|
||||
.description("Get the next game's information by specifying a team name")
|
||||
.description("Get the upcoming/current NFL game information given a NFL team")
|
||||
.add_option(
|
||||
CreateCommandOption::new(
|
||||
CommandOptionType::String,
|
||||
|
46
src/commands/gamedetail.rs
Normal file
46
src/commands/gamedetail.rs
Normal file
@ -0,0 +1,46 @@
|
||||
use crate::{
|
||||
types,
|
||||
util::{junk, nfl, request},
|
||||
};
|
||||
|
||||
use serenity::builder::{CreateCommand, CreateCommandOption};
|
||||
use serenity::model::application::{CommandOptionType, ResolvedOption, ResolvedValue};
|
||||
|
||||
pub async fn run(options: &[ResolvedOption<'_>]) -> String {
|
||||
if let Some(ResolvedOption {
|
||||
value: ResolvedValue::String(team),
|
||||
..
|
||||
}) = options.first()
|
||||
{
|
||||
// TODO: get game detail here, like total score, game leaders, play by play, etc.
|
||||
String::new()
|
||||
} else {
|
||||
junk::get_random_insult()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn register() -> CreateCommand {
|
||||
CreateCommand::new("gamedetail")
|
||||
.description("Get the upcoming/current NFL game details given a NFL team such as total score, game leaders, play-by-play, and more")
|
||||
.add_option(
|
||||
CreateCommandOption::new(CommandOptionType::String, "team", "The team to query")
|
||||
.required(true),
|
||||
)
|
||||
}
|
||||
|
||||
pub struct GameDetailDiscordResponse {
|
||||
pub team_name: String,
|
||||
pub record: String,
|
||||
pub next_event: String,
|
||||
pub game_date: String,
|
||||
pub standing: String,
|
||||
}
|
||||
|
||||
impl GameDetailDiscordResponse {
|
||||
pub fn format(&self) -> String {
|
||||
format!(
|
||||
"## {:}\nSeason Record (W-L): {:}\nNext Game: {:}\nNext Game Date: {:}\nStanding: {:}",
|
||||
self.team_name, self.record, self.next_event, self.game_date, self.standing
|
||||
)
|
||||
}
|
||||
}
|
@ -1,3 +1,6 @@
|
||||
pub mod about;
|
||||
pub mod game;
|
||||
pub mod gamedetail;
|
||||
pub mod roster;
|
||||
pub mod team;
|
||||
|
||||
|
47
src/commands/roster.rs
Normal file
47
src/commands/roster.rs
Normal file
@ -0,0 +1,47 @@
|
||||
use crate::{
|
||||
types,
|
||||
util::{junk, nfl, request},
|
||||
};
|
||||
|
||||
use serenity::builder::{CreateCommand, CreateCommandOption};
|
||||
use serenity::model::application::{CommandOptionType, ResolvedOption, ResolvedValue};
|
||||
|
||||
pub async fn run(options: &[ResolvedOption<'_>]) -> String {
|
||||
if let Some(ResolvedOption {
|
||||
value: ResolvedValue::String(team),
|
||||
..
|
||||
}) = options.first()
|
||||
{
|
||||
// TODO: get team roster and each players info if important
|
||||
String::new()
|
||||
} else {
|
||||
junk::get_random_insult()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn register() -> CreateCommand {
|
||||
CreateCommand::new("roster")
|
||||
.description("Get the current NFL team's roster given a NFL team")
|
||||
.add_option(
|
||||
CreateCommandOption::new(CommandOptionType::String, "team", "The team to query")
|
||||
.required(true),
|
||||
)
|
||||
}
|
||||
|
||||
pub struct RosterDiscordResponse {
|
||||
pub team_name: String,
|
||||
pub record: String,
|
||||
pub next_event: String,
|
||||
pub game_date: String,
|
||||
pub standing: String,
|
||||
}
|
||||
|
||||
impl RosterDiscordResponse {
|
||||
// TODO: get needed field for response and format them
|
||||
pub fn format(&self) -> String {
|
||||
format!(
|
||||
"## {:}\nSeason Record (W-L): {:}\nNext Game: {:}\nNext Game Date: {:}\nStanding: {:}",
|
||||
self.team_name, self.record, self.next_event, self.game_date, self.standing
|
||||
)
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ pub async fn run(options: &[ResolvedOption<'_>]) -> String {
|
||||
.await
|
||||
.unwrap();
|
||||
let team_name = results.team.display_name;
|
||||
let record = results.team.record.items[1].summary.clone();
|
||||
let record = results.team.record.items[0].summary.clone();
|
||||
let next_event = results.team.next_event[0].name.clone();
|
||||
let game_date_raw = results.team.next_event[0].date.clone();
|
||||
let game_date = junk::flexible_to_epoch_seconds(game_date_raw.as_str()).unwrap();
|
||||
@ -44,7 +44,7 @@ pub async fn run(options: &[ResolvedOption<'_>]) -> String {
|
||||
|
||||
pub fn register() -> CreateCommand {
|
||||
CreateCommand::new("team")
|
||||
.description("Get team members for current season")
|
||||
.description("Get NFL team information for current season")
|
||||
.add_option(
|
||||
CreateCommandOption::new(CommandOptionType::String, "team", "The team to query")
|
||||
.required(true),
|
||||
|
@ -58,7 +58,7 @@ impl EventHandler for Handler {
|
||||
)
|
||||
.await;
|
||||
|
||||
println!("Registered guild slash commands: {commands:#?}");
|
||||
println!("{} is ready to rock and roll!", ready.user.name);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user