Add WIP owo!emote

This commit is contained in:
Agatha Lovelace 2020-10-04 04:01:16 +03:00
parent 193dfdd383
commit e16905f821
No known key found for this signature in database
GPG Key ID: 2DB18BA2E0A80BC3
4 changed files with 46 additions and 2 deletions

36
src/commands/emote.rs Normal file
View File

@ -0,0 +1,36 @@
use regex::Regex;
use serenity::{
framework::standard::{macros::command, Args, CommandError, CommandResult},
model::channel::Message,
prelude::*,
utils::parse_emoji,
};
#[command]
#[aliases("e")]
fn emote(ctx: &mut Context, message: &Message, args: Args) -> CommandResult {
let input = match args.rest().trim() {
"" => {
return Err(CommandError(s!("Called without input!")));
}
v => v,
};
dbg!(input);
let re = Regex::new(r"<a{0,1}:\w+:\d+>").unwrap();
let emojis = match re.captures(input) {
None => {
return Err(CommandError(s!("No custom emojis found in the message!")));
}
Some(v) => v,
};
dbg!(&emojis);
let url = parse_emoji(&emojis[0]).unwrap().url();
let _ = message.channel_id.say(&ctx.http, url);
Ok(())
}

View File

@ -38,6 +38,11 @@ fn help(ctx: &mut Context, message: &Message) -> CommandResult {
("owo!headpat ``name``", "Headpat someone", true),
("owo!owo ``text``", "owoify input text", true),
("owo!lyrics ``name``", "Get song lyrics", true),
(
"owo!e ``emote``",
"Get a bigger version of a custom emote",
true,
),
("\u{200B}", "**Admin commands:**", false),
("owo!halt", "Kill the bot process", true),
("owo!status ``[args]``", "Sets the bot status", true),

View File

@ -1,6 +1,7 @@
pub mod brainfuck;
pub mod define;
pub mod embed;
pub mod emote;
pub mod help;
pub mod lyrics;
pub mod pinned;

View File

@ -26,7 +26,9 @@ mod utils;
use utils::*;
mod commands;
use commands::{brainfuck::*, define::*, embed::*, help::*, lyrics::*, pinned::*, ship::*};
use commands::{
brainfuck::*, define::*, embed::*, emote::*, help::*, lyrics::*, pinned::*, ship::*,
};
struct Handler;
@ -65,7 +67,7 @@ impl EventHandler for Handler {
#[group]
#[commands(
init, ping, halt, servers, host, status, ship, bottom_rng, headpat, uwu, gayculator, sausage,
help, embed, define, owo, info, echo, desc, pinned, brainfuck, pfp, lyrics
help, embed, define, owo, info, echo, desc, pinned, brainfuck, pfp, lyrics, emote
)]
struct General;