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
[dependencies]
serenity = "0.7"
serenity = "0.8"
chrono = "0.4.10"
reqwest = "0.9.24"
reqwest = "0.10.1"
serde = { version = "1.0", features = ["derive"] }
bitflags = "1"

View file

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

View file

@ -1,6 +1,6 @@
use crate::models::{Mode, Mods};
use chrono::{DateTime, Utc};
use reqwest::{Client, RequestBuilder};
use reqwest::blocking::{Client, RequestBuilder};
trait ToQuery {
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
[dependencies]
serenity = "0.7"
serenity = "0.8"
dotenv = "0.15"
serde = { version = "1.0", features = ["derive"] }
chrono = "0.4.9"
rand = "0.7.2"
static_assertions = "1.1.0"
reqwest = "0.9.24"
reqwest = "0.10.1"
regex = "1"
lazy_static = "1"
youmubot-osu = { path = "../youmubot-osu" }

View file

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

View file

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

View file

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

View file

@ -17,13 +17,10 @@ mod names;
use images::*;
group!({
name: "fun",
options: {
description: "Random commands",
},
commands: [roll, pick, name, image, nsfw],
});
#[group]
#[description = "Random commands"]
#[commands(roll, pick, name, image, nsfw)]
struct Fun;
#[command]
#[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};
pub use hook::hook;
group!({
name: "osu",
options: {
prefix: "osu",
description: "osu! related commands.",
},
commands: [std, taiko, catch, mania, save, recent, last, check, top],
});
#[group]
#[prefix = "osu"]
#[description = "osu! related commands."]
#[commands(std, taiko, catch, mania, save, recent, last, check, top)]
struct Osu;
#[command]
#[aliases("osu", "osu!")]

View file

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

View file

@ -45,7 +45,7 @@ fn main() {
// Setup shared instances of things
{
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(
var("OSU_API_KEY").expect("Please set OSU_API_KEY as osu! api key."),
));