A Discord bot, made with Gleam, designed to help manage a pixel art server.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

(fix) don't block the main process

Isaac 6bbb3598 fd8a0e2b

+21 -6
+1
compose.yml
··· 1 1 services: 2 2 pablo_pixarto_bot: 3 + container_name: pablo_pixarto 3 4 build: . 4 5 restart: unless-stopped 5 6 volumes:
+20 -6
src/pablo_pixarto.gleam
··· 16 16 import gleam/string 17 17 import gleam/time/timestamp.{type Timestamp} 18 18 import grom 19 + import grom/activity 19 20 import grom/gateway 20 21 import grom/gateway/intent 21 22 import grom/message ··· 57 58 logging.log(logging.Info, "Started the gateway!") 58 59 59 60 let state = check_and_post(state) 60 - schedule_check(state) 61 + process.spawn(fn() { schedule_check(state) }) 61 62 process.sleep_forever() 62 63 } 63 64 Error(err) -> { ··· 74 75 fn handle_event( 75 76 state: AppState, 76 77 event: gateway.Event, 77 - _connection: gateway.Connection(AppState), 78 + connection: gateway.Connection(AppState), 78 79 ) { 79 80 case event { 80 81 gateway.ErrorEvent(error) -> { 81 82 logging.log(logging.Error, "[discord] " <> string.inspect(error)) 82 83 gateway.continue(state) 83 84 } 84 - gateway.ReadyEvent(_) -> { 85 - logging.log(logging.Info, "Bot is ready!") 86 - gateway.continue(state) 87 - } 85 + gateway.ReadyEvent(_) -> on_ready(state, connection) 88 86 _ -> gateway.continue(state) 89 87 } 88 + } 89 + 90 + fn on_ready(state: AppState, connection: gateway.Connection(AppState)) { 91 + logging.log(logging.Info, "Ready!") 92 + 93 + connection 94 + |> gateway.update_presence(using: gateway.UpdatePresenceMessage( 95 + status: gateway.Online, 96 + since: option.None, 97 + activities: [ 98 + activity.new(named: "🖌️ Checking for themes...", type_: activity.Custom), 99 + ], 100 + is_afk: False, 101 + )) 102 + 103 + gateway.continue(state) 90 104 } 91 105 92 106 fn schedule_check(state: AppState) -> Nil {