aboutsummaryrefslogtreecommitdiff
path: root/src/modules/commands/general/animals.rs
blob: 91349df14e5be92b8211f1fdf44cf6bae444bcc9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
// use crate::core::colours;
use crate::core::consts::*;
use crate::core::model::*;
use serenity::framework::standard::{
    Args,
    Command,
    CommandError,
    CommandOptions
};
use serenity::model::channel::Message;
use serenity::prelude::Context;
use std::sync::Arc;

// pub struct Bunny;
// impl Command for Bunny {
//     fn options(&self) -> Arc<CommandOptions> {
//         let default = CommandOptions::default();
//         let options = CommandOptions {
//             desc: Some("One bouncy animal for you.".to_string()),
//             ..default
//         };
//         Arc::new(options)
//     }

//     fn execute(&self, ctx: &mut Context, message: &Message, _: Args) -> Result<(), CommandError> {
//         let data = ctx.data.lock();
//         if let Some(api) = data.get::<ApiClient>() {
//             let res = api.bunny()?;
//             message.channel_id.send_message(|m| m
//                 .embed(|e| e
//                     .image(&res.media[0])
//             ))?;
//         } else { failed!(API_FAIL); }

//         Ok(())
//     }
// }

pub struct Cat;
impl Command for Cat {
    fn options(&self) -> Arc<CommandOptions> {
        let default = CommandOptions::default();
        let options = CommandOptions {
            desc: Some("Enjoy a random cat.".to_string()),
            ..default
        };
        Arc::new(options)
    }

    fn execute(&self, ctx: &mut Context, message: &Message, _: Args) -> Result<(), CommandError> {
        let data = ctx.data.lock();
        if let Some(api) = data.get::<ApiClient>() {
            let res = api.cat()?;
            message.channel_id.send_message(|m| m
                .embed(|e| e
                    .image(res.file)
            ))?;
        } else { failed!(API_FAIL); }

        Ok(())
    }
}

pub struct Dog;
impl Command for Dog {
    fn options(&self) -> Arc<CommandOptions> {
        let default = CommandOptions::default();
        let options = CommandOptions {
            desc: Some("Cats aren't enough for you? Have a dog!".to_string()),
            ..default
        };
        Arc::new(options)
    }

    fn execute(&self, ctx: &mut Context, message: &Message, _: Args) -> Result<(), CommandError> {
        let data = ctx.data.lock();
        if let Some(api) = data.get::<ApiClient>() {
            let res = api.dog()?;
            message.channel_id.send_message(|m| m
                .embed(|e| e
                    .image(res.message)
            ))?;
        } else { failed!(API_FAIL); }

        Ok(())
    }
}

pub struct Duck;
impl Command for Duck {
    fn options(&self) -> Arc<CommandOptions> {
        let default = CommandOptions::default();
        let options = CommandOptions {
            desc: Some("Have a duck, pog.".to_string()),
            ..default
        };
        Arc::new(options)
    }

    fn execute(&self, ctx: &mut Context, message: &Message, _: Args) -> Result<(), CommandError> {
        let data = ctx.data.lock();
        if let Some(api) = data.get::<ApiClient>() {
            let res = api.duck()?;
            message.channel_id.send_message(|m| m
                .embed(|e| e
                    .image(res.url)
            ))?;
        } else { failed!(API_FAIL); }

        Ok(())
    }
}

pub struct Fox;
impl Command for Fox {
    fn options(&self) -> Arc<CommandOptions> {
        let default = CommandOptions::default();
        let options = CommandOptions {
            desc: Some("A fox, thats it.".to_string()),
            ..default
        };
        Arc::new(options)
    }

    fn execute(&self, ctx: &mut Context, message: &Message, _: Args) -> Result<(), CommandError> {
        let data = ctx.data.lock();
        if let Some(api) = data.get::<ApiClient>() {
            let res = api.fox()?;
            message.channel_id.send_message(|m| m
                .embed(|e| e
                    .image(res.image)
            ))?;
        } else { failed!(API_FAIL); }

        Ok(())
    }
}

pub struct Owl;
impl Command for Owl {
    fn options(&self) -> Arc<CommandOptions> {
        let default = CommandOptions::default();
        let options = CommandOptions {
            desc: Some("Why an owl?".to_string()),
            ..default
        };
        Arc::new(options)
    }

    fn execute(&self, ctx: &mut Context, message: &Message, _: Args) -> Result<(), CommandError> {
        let data = ctx.data.lock();
        if let Some(api) = data.get::<ApiClient>() {
            let res = api.owl()?;
            message.channel_id.send_message(|m| m
                .embed(|e| e
                    .image(res.image)
            ))?;
        } else { failed!(API_FAIL); }

        Ok(())
    }
}

pub struct UglyCat;
impl Command for UglyCat {
    fn options(&self) -> Arc<CommandOptions> {
        let default = CommandOptions::default();
        let options = CommandOptions {
            desc: Some("UGLY CAT!".to_string()),
            ..default
        };
        Arc::new(options)
    }

    fn execute(&self, _ctx: &mut Context, message: &Message, _: Args) -> Result<(), CommandError> {
        message.channel_id.send_message(|m| m
            .embed(|e| e
                .image("https://i.pinimg.com/originals/4d/19/0f/4d190f1307b35e7155bb4b898e19d545.jpg")
        ))?;

        Ok(())
    }
}