Skip to content

Commit

Permalink
chore: try to add team stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
washbin committed Oct 7, 2022
1 parent 9ad44b5 commit 74fb416
Show file tree
Hide file tree
Showing 6 changed files with 256 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"nixEnvSelector.nixFile": "${workspaceRoot}/shell.nix"
"nixEnvSelector.nixFile": "${workspaceRoot}/shell.nix",
"editor.inlayHints.enabled": "off"
}
207 changes: 207 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ tokio = { version = "1.17.0", features=["macros", "rt-multi-thread"] }
serenity = { version = "0.11.1"}
serde = { version = "1.0.136", features=["derive"] }
dotenvy = "0.15.5"
envy = "0.4.2"
envy = "0.4.2"
reqwest = "0.11.12"
1 change: 1 addition & 0 deletions src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pub mod id;
pub mod team;
40 changes: 40 additions & 0 deletions src/commands/team.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
use serenity::builder::CreateApplicationCommand;
use serenity::model::prelude::command::CommandOptionType;
use serenity::model::prelude::interaction::application_command::{
CommandDataOption, CommandDataOptionValue,
};

pub async fn run(options: &[CommandDataOption]) -> String {
let option = options
.get(0)
.expect("Expected String Option")
.resolved
.as_ref()
.expect("Expected string object");

if let CommandDataOptionValue::String(team_id) = option {
let response = reqwest::get(format!("https://www.hacksquad.dev/api/team?id={}", team_id))
.await
.unwrap()
.text()
.await
.unwrap();

format!("team information is {}", response)
} else {
"Please provide a valid user".to_string()
}
}

pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicationCommand {
command
.name("team")
.description("Get a teams information")
.create_option(|option| {
option
.name("id")
.description("The id of the team to look for")
.kind(CommandOptionType::String)
.required(true)
})
}
Loading

0 comments on commit 74fb416

Please sign in to comment.