From 45bd36ddf5ec9e9813e5f694946f8e67b1d2aea3 Mon Sep 17 00:00:00 2001 From: Mishio595 Date: Sun, 18 Nov 2018 19:13:35 -0700 Subject: Clean up example bot --- bin/bot.ml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/bot.ml b/bin/bot.ml index 56a1b6f..08a182e 100644 --- a/bin/bot.ml +++ b/bin/bot.ml @@ -2,12 +2,7 @@ open Async open Core open Disml -let main () = - let token = match Sys.getenv "DISCORD_TOKEN" with - | Some s -> s - | None -> failwith "No token" - in - let client = Client.make token in +let hook_events client = Client.on "MESSAGE_CREATE" client (fun msg -> let msg_time = Time.(to_span_since_epoch @@ now ()) in let content = Yojson.Basic.Util.(member "content" msg |> to_string) in @@ -25,6 +20,15 @@ let main () = ] >>> fun _ -> print_endline "Message Edited!" ); + Client.on "GUILD_CREATE" client (fun guild -> print_endline Yojson.Basic.Util.(member "name" guild |> to_string)) + +let main () = + let token = match Sys.getenv "DISCORD_TOKEN" with + | Some s -> s + | None -> failwith "No token" + in + let client = Client.make token in + hook_events client; Client.start client >>> fun client -> Clock.every -- cgit v1.2.3