Browse Source

Update all dependencies, refactor some of the code;

Fix animated emotes displaying as png
master
Agatha Lovelace 10 months ago
parent
commit
9563b32eb9
  1. 1
      .rustfmt.toml
  2. 553
      Cargo.lock
  3. 16
      Cargo.toml
  4. 2
      src/commands/ship.rs
  5. 25
      src/main.rs

1
.rustfmt.toml

@ -0,0 +1 @@
fn_args_layout = "Compressed"

553
Cargo.lock
File diff suppressed because it is too large
View File

16
Cargo.toml

@ -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.9.1"
rand = "0.7.3"
toml = "0.5.7"
serenity = "0.10.2"
rand = "0.8.2"
toml = "0.5.8"
sys-info = "0.7.0"
urbandict = "0.2.0"
owoify = "0.1.5"
@ -17,20 +17,20 @@ lazy_static = "1.4.0"
colored = "2.0.0"
brainfrick = "1.1.2"
percent-encoding = "2.1.0"
regex = "1.4.2"
regex = "1.4.3"
[patch.crates-io]
openssl = { git = "https://github.com/ishitatsuyuki/rust-openssl", branch = "0.9.x" }
[dependencies.serde]
version = "1.0.117"
version = "1.0.118"
features = ["derive"]
[dependencies.reqwest]
version = "0.10.9"
version = "0.10.10"
features = ["blocking", "json"]
[dependencies.tokio]
version = "0.2.23"
features = ["macros"]
version = "1.1.0"
features = ["macros", "rt-multi-thread"]

2
src/commands/ship.rs

@ -13,7 +13,7 @@ async fn ship(ctx: &Context, message: &Message, args: Args) -> CommandResult {
// Get input names
let names: String = args.rest().trim().to_string();
// Calculate compatibility based on hash
let compat: u64 = StdRng::seed_from_u64(calculate_hash(&names)).gen_range(50, 100);
let compat: u64 = StdRng::seed_from_u64(calculate_hash(&names)).gen_range(50..100);
// Initialize a bar to display compatibility percentage
let mut compbar = String::from("----------");

25
src/main.rs

@ -14,7 +14,7 @@ use serenity::{
},
framework::standard::{
macros::{check, command, group, hook},
Args, CheckResult, CommandOptions, CommandResult, DispatchError, Reason, StandardFramework,
Args, CommandOptions, CommandResult, DispatchError, Reason, StandardFramework,
},
model::{
channel::{Message, ReactionType},
@ -170,18 +170,25 @@ async fn main() {
#[check]
#[name = "Owner"]
async fn owner_check(_: &Context, msg: &Message, _: &mut Args, _: &CommandOptions) -> CheckResult {
async fn owner_check(
_: &Context, msg: &Message, _: &mut Args, _: &CommandOptions,
) -> Result<(), Reason> {
if OWNERS.clone().contains(&msg.author.id) {
CheckResult::Success
Ok(())
} else {
CheckResult::Failure(Reason::Unknown)
Err(Reason::Unknown)
}
}
#[check]
#[name = "Server"]
async fn server_check(_: &Context, msg: &Message, _: &mut Args, _: &CommandOptions) -> CheckResult {
(msg.guild_id == Some(serenity::model::id::GuildId(687011389294116875))).into()
async fn server_check(
_: &Context, msg: &Message, _: &mut Args, _: &CommandOptions,
) -> Result<(), Reason> {
match msg.guild_id == Some(serenity::model::id::GuildId(687011389294116875)) {
true => Ok(()),
false => Err(Reason::Unknown),
}
}
#[command]
@ -191,7 +198,7 @@ async fn init(ctx: &Context, message: &Message) -> CommandResult {
"Nyaa~!",
"Hewwo uwu",
];
let num = rand::thread_rng().gen_range(0, responses.len());
let num = rand::thread_rng().gen_range(0..responses.len());
let _ = message.channel_id.say(&ctx.http, responses[num]).await;
Ok(())
@ -354,7 +361,7 @@ async fn bottom_rng(ctx: &Context, message: &Message, mut args: Args) -> Command
for msg in messages {
input += &format!("{} ", msg.content);
}
let result: u64 = StdRng::seed_from_u64(calculate_hash(&input)).gen_range(0, 100);
let result: u64 = StdRng::seed_from_u64(calculate_hash(&input)).gen_range(0..100);
let _ = message
.channel_id
.send_message(&ctx.http, |m| {
@ -419,7 +426,7 @@ async fn uwu(ctx: &Context, message: &Message) -> CommandResult {
"https://preview.redd.it/fcfrmarhj9s41.jpg?width=640&crop=smart&auto=webp&s=5a4ff9a471dca7cad61b8e56bc65876ef083304a",
"https://i.redd.it/ifwsmbme48q41.jpg"
];
let num = rand::thread_rng().gen_range(0, images.len());
let num = rand::thread_rng().gen_range(0..images.len());
let _ = message
.channel_id
.send_message(&ctx.http, |m| {

Loading…
Cancel
Save