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
|
use crate::utils;
use serenity::builder::CreateApplicationCommand;
use serenity::http::client::Http;
use serenity::model::id::ChannelId;
use serenity::model::prelude::command::CommandOptionType;
use serenity::model::prelude::interaction::application_command::{
CommandDataOption, CommandDataOptionValue,
};
use std::sync::Arc;
pub async fn run(options: &[CommandDataOption], channel_id: ChannelId, http: &Arc<Http>) -> String {
let err_msg = "expected a copyasta";
let option = options
.get(0)
.expect(err_msg)
.resolved
.as_ref()
.expect(err_msg);
if let CommandDataOptionValue::String(copypasta) = option {
let replies = utils::get_copypasta(copypasta).await;
if replies.len() > 1 {
for reply in replies {
let resp = channel_id.send_message(&http, |m| m.content(reply)).await;
match resp {
Ok(_) => continue,
Err(why) => {
println!("couldn't send message: {:?}", why);
return "something went wrong!".to_string();
}
}
}
return "here's your copypasta:".to_string(); // yes this causes the
// application to not respond.
// no i don't care.
}
return replies[0].to_string();
}
"couldn't find a copypasta".to_string()
}
pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicationCommand {
command
.name("copypasta")
.description("send funni copypasta")
.create_option(|option| {
option
.name("copypasta")
.description("the copypasta you want to send")
.kind(CommandOptionType::String)
.required(true)
.add_string_choice("astral", "astral")
.add_string_choice("dvd", "dvd")
.add_string_choice("egrill", "egrill")
.add_string_choice("happymeal", "happymeal")
.add_string_choice("ismah", "ismah")
.add_string_choice("sus", "sus")
.add_string_choice("ticktock", "ticktock")
.add_string_choice("twitter", "twitter")
})
}
|