This is supposed to crash
This commit is contained in:
30
src/main.rs
30
src/main.rs
@@ -15,15 +15,18 @@ impl EventHandler for Handler {
|
|||||||
// Event handlers are dispatched through a threadpool, and so multiple
|
// Event handlers are dispatched through a threadpool, and so multiple
|
||||||
// events can be dispatched simultaneously.
|
// events can be dispatched simultaneously.
|
||||||
async fn message(&self, ctx: Context, msg: Message) {
|
async fn message(&self, ctx: Context, msg: Message) {
|
||||||
let mut phrase = String::from("not pog");
|
let text = msg.content.to_string();
|
||||||
if msg.content == "hello" {
|
let phrase = ungabunga(&text);
|
||||||
phrase = "http://nohello.com".to_string();
|
|
||||||
}
|
// This code was written by idiot (me)
|
||||||
else if msg.content == "help"
|
// if msg.content == "hello" {
|
||||||
{
|
// phrase = "http://nohello.com".to_string();
|
||||||
phrase = "https://dontasktoask.com/".to_string();
|
// }
|
||||||
}
|
// else if msg.content == "help"
|
||||||
else if msg.content == "!help"
|
// {
|
||||||
|
// phrase = "https://dontasktoask.com/".to_string();
|
||||||
|
// }
|
||||||
|
if msg.content == "!help"
|
||||||
{
|
{
|
||||||
let dm = msg.author.dm(&ctx, |m| m.content("I hate you")).await;
|
let dm = msg.author.dm(&ctx, |m| m.content("I hate you")).await;
|
||||||
if let Err(why) = dm {
|
if let Err(why) = dm {
|
||||||
@@ -77,3 +80,12 @@ async fn main() {
|
|||||||
println!("Client error: {:?}", why);
|
println!("Client error: {:?}", why);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fn ungabunga(txt: &str) -> String {
|
||||||
|
match txt {
|
||||||
|
"hello" | "hi" | "hey" => return "https://nohello.com".to_string(),
|
||||||
|
"help" | "can anyone help?" | "helppp" => return "https://dontasktoask.com".to_string(),
|
||||||
|
_ => return "not pog".to_string(),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user