diff options
| author | Fuwn <[email protected]> | 2020-10-30 12:58:50 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2020-10-30 12:58:50 -0700 |
| commit | 3ca642734629b108ece241ea9644f5ed1ee339cb (patch) | |
| tree | 515fc5c33c62eb4ab970f3d3e5bb7f40ff417df1 /src/modules/plugins/random_hi.rs | |
| parent | chore: change cc env vars file type, (md -> txt) (diff) | |
| download | dep-core-next-3ca642734629b108ece241ea9644f5ed1ee339cb.tar.xz dep-core-next-3ca642734629b108ece241ea9644f5ed1ee339cb.zip | |
feat (desc)
feat:
- add `Procfile` and `app.json` to "prep" for heroku (probably not going to go to heroku though).
- implement a plugin system and enable `random_hi` plugin.
- move webserver to seperate location
Diffstat (limited to 'src/modules/plugins/random_hi.rs')
| -rw-r--r-- | src/modules/plugins/random_hi.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/modules/plugins/random_hi.rs b/src/modules/plugins/random_hi.rs new file mode 100644 index 0000000..ff2b7e5 --- /dev/null +++ b/src/modules/plugins/random_hi.rs @@ -0,0 +1,18 @@ +use serenity::model::channel::Message; +use serenity::prelude::Context; +use rand::{thread_rng, Rng}; + +pub fn on_message(_ctx: &Context, message: &Message) { + let greatings = vec!["hi", "hey", "hello", "hei", "yo"]; + let message_content: &str = &message.content.to_lowercase(); + if !greatings.contains(&message_content) || message.author.bot { + return (); + } + + let mut rng = thread_rng(); + let n: u32 = rng.gen_range(0, 16); + + if n == 1 { + let _ = message.channel_id.say("Hi!"); + } +} |