Clean up 5æm code from last night
This commit is contained in:
parent
634e8508d4
commit
238f8f9593
32
src/main.rs
32
src/main.rs
|
@ -6,7 +6,10 @@ extern crate lazy_static;
|
|||
use colored::*;
|
||||
use rand::Rng;
|
||||
use serenity::{
|
||||
client::{Client, bridge::gateway::{ShardId, ShardManager}},
|
||||
client::{
|
||||
bridge::gateway::{ShardId, ShardManager},
|
||||
Client,
|
||||
},
|
||||
framework::standard::{
|
||||
macros::{check, command, group},
|
||||
Args, CheckResult, CommandError, CommandOptions, CommandResult, DispatchError, Reason,
|
||||
|
@ -144,8 +147,10 @@ fn ping(ctx: &mut Context, message: &Message) -> CommandResult {
|
|||
let shard_manager = match data.get::<ShardManagerContainer>() {
|
||||
Some(v) => v,
|
||||
None => {
|
||||
return Err(CommandError("There was a problem getting the shard manager!".to_string()));
|
||||
},
|
||||
return Err(CommandError(
|
||||
"There was a problem getting the shard manager!".to_string(),
|
||||
))
|
||||
}
|
||||
};
|
||||
|
||||
let manager = shard_manager.lock();
|
||||
|
@ -153,12 +158,15 @@ fn ping(ctx: &mut Context, message: &Message) -> CommandResult {
|
|||
|
||||
let runner = match runners.get(&ShardId(ctx.shard_id)) {
|
||||
Some(v) => v,
|
||||
None => {
|
||||
return Err(CommandError("No shard found!".to_string()));
|
||||
}
|
||||
None => return Err(CommandError("No shard found!".to_string())),
|
||||
};
|
||||
|
||||
let _ = message.reply(&ctx, format!("Pong! Latency: {:?}", runner.latency));
|
||||
let ping = match runner.latency {
|
||||
Some(v) => v.as_millis(),
|
||||
None => return Err(CommandError("Could not get latency!".to_string())),
|
||||
};
|
||||
|
||||
let _ = message.reply(&ctx, format!("Pong! Latency: {}ms", ping));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -435,14 +443,14 @@ fn uwu(ctx: &mut Context, message: &Message) -> CommandResult {
|
|||
"https://i.redd.it/ifwsmbme48q41.jpg"
|
||||
];
|
||||
let num = rand::thread_rng().gen_range(0, images.len());
|
||||
let _ = message
|
||||
.channel_id
|
||||
.send_message(&ctx.http, |m| m.embed(|e| {
|
||||
let _ = message.channel_id.send_message(&ctx.http, |m| {
|
||||
m.embed(|e| {
|
||||
e.image(images[num]);
|
||||
e.footer(|f| f.text(format!("Source: {}", images[num])));
|
||||
|
||||
e
|
||||
}));
|
||||
})
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -524,7 +532,7 @@ fn help(ctx: &mut Context, message: &Message) -> CommandResult {
|
|||
#[command]
|
||||
fn info(ctx: &mut Context, message: &Message, args: Args) -> CommandResult {
|
||||
if !args.is_empty() {
|
||||
return Err(CommandError("Error: Called with args!".to_string()));
|
||||
return Err(CommandError("Called with args!".to_string()));
|
||||
}
|
||||
|
||||
let num = ctx.cache.read().guilds.len();
|
||||
|
|
Loading…
Reference in New Issue