Merge branch 'master' into osu

This commit is contained in:
Natsu Kagami 2020-01-16 01:58:26 -05:00
commit ce09a76dc7
12 changed files with 434 additions and 686 deletions

1048
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -7,9 +7,9 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
serenity = "0.7" serenity = "0.8"
chrono = "0.4.10" chrono = "0.4.10"
reqwest = "0.9.24" reqwest = "0.10.1"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
bitflags = "1" bitflags = "1"

View file

@ -8,7 +8,7 @@ mod test;
use models::*; use models::*;
use request::builders::*; use request::builders::*;
use request::*; use request::*;
use reqwest::Client as HTTPClient; use reqwest::blocking::{Client as HTTPClient, RequestBuilder, Response};
use serenity::framework::standard::CommandError as Error; use serenity::framework::standard::CommandError as Error;
use std::convert::TryInto; use std::convert::TryInto;
@ -35,11 +35,7 @@ impl Client {
} }
} }
fn build_request( fn build_request(&self, c: &HTTPClient, r: RequestBuilder) -> Result<Response, Error> {
&self,
c: &HTTPClient,
r: reqwest::RequestBuilder,
) -> Result<reqwest::Response, Error> {
let v = r.query(&[("k", &self.key)]).build()?; let v = r.query(&[("k", &self.key)]).build()?;
dbg!(v.url()); dbg!(v.url());
Ok(c.execute(v)?) Ok(c.execute(v)?)

View file

@ -1,6 +1,6 @@
use crate::models::{Mode, Mods}; use crate::models::{Mode, Mods};
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};
use reqwest::{Client, RequestBuilder}; use reqwest::blocking::{Client, RequestBuilder};
trait ToQuery { trait ToQuery {
fn to_query(&self) -> Vec<(&'static str, String)>; fn to_query(&self) -> Vec<(&'static str, String)>;

View file

@ -7,13 +7,13 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
serenity = "0.7" serenity = "0.8"
dotenv = "0.15" dotenv = "0.15"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
chrono = "0.4.9" chrono = "0.4.9"
rand = "0.7.2" rand = "0.7.2"
static_assertions = "1.1.0" static_assertions = "1.1.0"
reqwest = "0.9.24" reqwest = "0.10.1"
regex = "1" regex = "1"
lazy_static = "1" lazy_static = "1"
youmubot-osu = { path = "../youmubot-osu" } youmubot-osu = { path = "../youmubot-osu" }

View file

@ -15,13 +15,10 @@ use std::{thread::sleep, time::Duration};
mod soft_ban; mod soft_ban;
pub use soft_ban::watch_soft_bans; pub use soft_ban::watch_soft_bans;
group!({ #[group]
name: "admin", #[description = "Administrative commands for the server."]
options: { #[commands(clean, ban, kick, soft_ban, soft_ban_init)]
description: "Administrative commands for the server.", struct Admin;
},
commands: [clean, ban, kick, soft_ban, soft_ban_init],
});
#[command] #[command]
#[aliases("cleanall")] #[aliases("cleanall")]

View file

@ -19,14 +19,11 @@ mod votes;
use votes::VOTE_COMMAND; use votes::VOTE_COMMAND;
group!({ #[group]
name: "community", #[description = "Community related commands. Usually comes with some sort of delays, since it involves pinging"]
options: { #[only_in("guilds")]
only_in: "guilds", #[commands(choose, vote)]
description: "Community related commands. Usually comes with some sort of delays, since it involves pinging", struct Community;
},
commands: [choose, vote],
});
#[command] #[command]
#[description = r"👑 Randomly choose an active member and mention them! #[description = r"👑 Randomly choose an active member and mention them!

View file

@ -1,5 +1,5 @@
use crate::http::HTTP; use crate::http::HTTP;
use reqwest::Client as HTTPClient; use reqwest::blocking::Client as HTTPClient;
use serde::Deserialize; use serde::Deserialize;
use serenity::framework::standard::CommandError as Error; use serenity::framework::standard::CommandError as Error;
use serenity::prelude::*; use serenity::prelude::*;

View file

@ -17,13 +17,10 @@ mod names;
use images::*; use images::*;
group!({ #[group]
name: "fun", #[description = "Random commands"]
options: { #[commands(roll, pick, name, image, nsfw)]
description: "Random commands", struct Fun;
},
commands: [roll, pick, name, image, nsfw],
});
#[command] #[command]
#[description = "🎲 Rolls a dice that gives you a random number."] #[description = "🎲 Rolls a dice that gives you a random number."]

View file

@ -23,14 +23,11 @@ mod hook;
use embeds::{beatmap_embed, score_embed, user_embed}; use embeds::{beatmap_embed, score_embed, user_embed};
pub use hook::hook; pub use hook::hook;
group!({ #[group]
name: "osu", #[prefix = "osu"]
options: { #[description = "osu! related commands."]
prefix: "osu", #[commands(std, taiko, catch, mania, save, recent, last, check, top)]
description: "osu! related commands.", struct Osu;
},
commands: [std, taiko, catch, mania, save, recent, last, check, top],
});
#[command] #[command]
#[aliases("osu", "osu!")] #[aliases("osu", "osu!")]

View file

@ -4,7 +4,7 @@ use youmubot_osu::Client as OsuClient;
pub(crate) struct HTTP; pub(crate) struct HTTP;
impl TypeMapKey for HTTP { impl TypeMapKey for HTTP {
type Value = reqwest::Client; type Value = reqwest::blocking::Client;
} }
pub(crate) struct Osu; pub(crate) struct Osu;

View file

@ -45,7 +45,7 @@ fn main() {
// Setup shared instances of things // Setup shared instances of things
{ {
let mut data = client.data.write(); let mut data = client.data.write();
data.insert::<http::HTTP>(reqwest::Client::new()); data.insert::<http::HTTP>(reqwest::blocking::Client::new());
data.insert::<http::Osu>(OsuClient::new( data.insert::<http::Osu>(OsuClient::new(
var("OSU_API_KEY").expect("Please set OSU_API_KEY as osu! api key."), var("OSU_API_KEY").expect("Please set OSU_API_KEY as osu! api key."),
)); ));