aboutsummaryrefslogtreecommitdiff
path: root/src/modules/commands/general/nsfw.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2020-10-26 19:03:53 -0700
committerFuwn <[email protected]>2020-10-26 19:03:53 -0700
commit9742614a1dc4699c1f2c69d923d402237672335d (patch)
treea49f7d834372f37cef06b30a28ff1b40bdfaa079 /src/modules/commands/general/nsfw.rs
parentCreate README.md (diff)
downloaddep-core-next-9742614a1dc4699c1f2c69d923d402237672335d.tar.xz
dep-core-next-9742614a1dc4699c1f2c69d923d402237672335d.zip
repo: push main from local to remote
Diffstat (limited to 'src/modules/commands/general/nsfw.rs')
-rw-r--r--src/modules/commands/general/nsfw.rs50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/modules/commands/general/nsfw.rs b/src/modules/commands/general/nsfw.rs
new file mode 100644
index 0000000..1a699d0
--- /dev/null
+++ b/src/modules/commands/general/nsfw.rs
@@ -0,0 +1,50 @@
+use crate::core::model::ApiClient;
+use crate::core::consts::*;
+use serenity::framework::standard::{
+ Args,
+ Command,
+ CommandError,
+ CommandOptions
+};
+use serenity::model::channel::Message;
+use serenity::prelude::Context;
+use std::sync::Arc;
+
+pub struct Furry;
+impl Command for Furry {
+ fn options(&self) -> Arc<CommandOptions> {
+ let default = CommandOptions::default();
+ let options = CommandOptions {
+ desc: Some("I see your a individual of culture...".to_string()),
+ usage: Some("[tags]".to_string()),
+ example: Some("minecraft".to_string()),
+ aliases: vec!["furry"].iter().map(|e| e.to_string()).collect(),
+ owner_privileges: false,
+ ..default
+ };
+ Arc::new(options)
+ }
+
+ fn execute(&self, ctx: &mut Context, message: &Message, args: Args) -> Result<(), CommandError> {
+ let data = ctx.data.lock();
+ message.channel_id.broadcast_typing()?;
+ if let Some(api) = data.get::<ApiClient>() {
+ let res = api.furry(args.full(), 1)?;
+ let post = &res[0];
+ message.channel_id.send_message(|m| m
+ .embed(|e| e
+ .image(&post.file_url)
+ .description(format!("**Tags:** {}\n**Post:** [{}]({})\n**Artist:** {}\n**Score::** {}",
+ &post.tags.replace("_", "\\_"),
+ &post.id,
+ format!("https://e621.net/post/show/{}", &post.id),
+ &post.artist[0],
+ &post.score
+ )
+ )
+ ))?;
+ } else { failed!(API_FAIL); }
+
+ Ok(())
+ }
+}