Add ship and ping command

This commit is contained in:
Agatha Rose 2018-07-31 16:51:27 +03:00
parent dd057a99f0
commit 32c98bf691
3 changed files with 48 additions and 4 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "rustcord"
version = "0.5.3"
version = "0.7.0"
authors = [" <@protonmail.com>"]
[dependencies]

View File

@ -45,12 +45,14 @@ fn main() {
.cmd("halt", halt)
.cmd("help", help)
.cmd("info", info)
.cmd("ping", ping)
.cmd("list_srv", list_srv)
.command("compare_bot", |c| {
c
.cmd(compare_bot)
.known_as("compare bot")
})
.cmd("ship", ship)
);
// start listening for events by starting a single shard
@ -63,6 +65,10 @@ command!(init(_ctx, message) {
let _ = message.channel_id.say("The Discordinator9000 is ready to kick yer butts!");
});
command!(ping(_ctx, message) {
let _ = message.reply("Pong!");
});
command!(halt(ctx, message) {
if message.author.id == 254310746450690048 {
use serenity::model::user::OnlineStatus;
@ -94,6 +100,41 @@ command!(list_srv(_ctx, message) {
}
});
command!(ship(_ctx, message, args) {
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
let first = calculate_hash(&args.single::<String>().unwrap());
let second = calculate_hash(&args.single::<String>().unwrap());
let mut slider = String::new();
let res = (first % second) / 100000000000000000;
//let _ = message.channel_id.say(format!(":heart: {}%", res));
let mut num = 0;
while num < res / 10 {
slider.push('▬');
num += 1;
}
slider.push_str(":heart:");
num = 0;
while num < (10 - res / 10) {
slider.push('▬');
num += 1;
}
let _ = message.channel_id.send_message(|m| m
.embed(|e| e
.title(format!("{}%", res))
.description(slider)
.color(0xff00ce)
));
fn calculate_hash<T: Hash>(t: &T) -> u64 {
let mut s = DefaultHasher::new();
t.hash(&mut s);
s.finish()
}
});
command!(gayculator(_ctx, message, args) {
if message.author.id != 191948420141809665 {
let number_32: i32 = args.trim().parse()
@ -108,8 +149,8 @@ if message.author.id != 191948420141809665 {
.embed(|e| e
.title("Gayness level:")
.description(result)
.color(0xff00f9))
);
.color(0xff00f9)
));
}
});
@ -141,11 +182,14 @@ command!(help(_ctx, message) {
.title("Availble commands:")
.description("All commands are case-insensitive")
.fields(vec![
("OwO init", "Introduce me", false),
("OwO ping", "Pong", false),
("OwO waffle", "Join the **waffle dongle** cult!", false),
("OwO sausage", "Join the **sausage dongle** cult!", false),
("OwO help", "Help the fellow humanz!", false),
("OwO info", "Show information about me!", false),
("OwO compare_bot", "Compare me to other robots!", false),
("OwO compare_bot ``bot's name``", "Compare me to other robots!", false),
("OwO ship ``name 1`` ``name 2``", "*shipping intensifies*", false),
("Admin commands:", "\u{200B}", true),
("OwO halt", "shut me down", false),
("OwO list_srv", "list my servers", false)

Binary file not shown.