-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8de9cb9
commit 673030b
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//! js command | ||
//! | ||
//! usage: ```!js``` | ||
//! | ||
//! author: Cathyprime | ||
use super::ChatCommand; | ||
use anyhow::anyhow; | ||
use rand::seq::SliceRandom; | ||
use tracing::{debug, error}; | ||
|
||
pub struct MostlyJs {} | ||
|
||
impl ChatCommand for MostlyJs { | ||
fn new() -> Self { | ||
Self {} | ||
} | ||
|
||
fn names() -> Vec<String> { | ||
vec!["js".to_string()] | ||
} | ||
|
||
fn help(&self) -> String { | ||
"usage: !js".to_string() | ||
} | ||
|
||
fn handle( | ||
&mut self, | ||
api: &mut super::TwitchApiWrapper, | ||
ctx: &twitcheventsub::MessageData, | ||
) -> anyhow::Result<()> { | ||
let msgs = vec!["Undefined", "[object Object]", "x === y"]; | ||
let js = msgs.choose(&mut rand::thread_rng()); | ||
let msg = format!("\"{}\" does not exist", js.unwrap()); | ||
|
||
match api.send_chat_message_with_reply(&msg, Some(&ctx.message_id)) { | ||
Ok(s) => { | ||
debug!(reply = %s); | ||
Ok(()) | ||
} | ||
Err(e) => { | ||
error!(error = ?e); | ||
Err(anyhow!("{:?}", e)) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters