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.

dont just update, silly, actually edit it to work with the latest lib version

+29 -21
+29 -21
src/pablo_pixarto.gleam
··· 44 44 let #(uris, last_updated) = load_cache() 45 45 46 46 let client = grom.Client(token:) 47 + 48 + // Make sure we have the correct intents for our identity 47 49 let identify = 48 50 client 49 51 |> gateway.identify(intents: [intent.Guilds, intent.GuildMessages]) 50 52 51 - let state = AppState(client, last_updated, uris, channel_id) 53 + // Create our central app state 54 + let assert Ok(data) = gateway.get_data(client) 55 + 52 56 let gateway_start_result = 53 - gateway.new(identify, state) 57 + gateway.new_with_initializer( 58 + fn(gateway) { 59 + Ok(AppState(client, last_updated, uris, channel_id, gateway)) 60 + }, 61 + identify, 62 + data, 63 + ) 54 64 |> gateway.on_event(handle_event) 55 65 |> gateway.start() 56 66 57 67 case gateway_start_result { 58 68 Ok(_) -> { 59 69 logging.log(logging.Info, "Started the gateway!") 60 - 61 - process.spawn(fn() { schedule_check(state) }) 62 - process.sleep_forever() 63 70 } 64 71 Error(err) -> { 65 72 logging.log( ··· 72 79 Nil 73 80 } 74 81 75 - fn handle_event( 76 - state: AppState, 77 - event: gateway.Event, 78 - connection: gateway.Connection(AppState), 79 - ) { 82 + fn handle_event(state: AppState, event: gateway.Event) { 80 83 case event { 81 84 gateway.ErrorEvent(error) -> { 82 85 logging.log(logging.Error, "[discord] " <> string.inspect(error)) 83 86 gateway.continue(state) 84 87 } 85 - gateway.ReadyEvent(_) -> on_ready(state, connection) 88 + gateway.ReadyEvent(_) | gateway.AllShardsReadyEvent(_) -> on_ready(state) 86 89 _ -> gateway.continue(state) 87 90 } 88 91 } 89 92 90 - fn on_ready(state: AppState, connection: gateway.Connection(AppState)) { 93 + fn on_ready(state: AppState) -> gateway.Next(AppState) { 91 94 logging.log(logging.Info, "Ready!") 92 95 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 - )) 96 + gateway.update_presence( 97 + state.gateway, 98 + using: gateway.UpdatePresenceMessage( 99 + status: gateway.Online, 100 + since: option.None, 101 + activities: [ 102 + activity.new(named: "🖌️ Checking for themes...", type_: activity.Custom), 103 + ], 104 + is_afk: False, 105 + ), 106 + ) 107 + 108 + process.spawn(fn() { schedule_check(state) }) 102 109 103 110 gateway.continue(state) 104 111 } ··· 156 163 last_updated: Timestamp, 157 164 posted_uris: Set(String), 158 165 channel_id: String, 166 + gateway: process.Subject(gateway.Message), 159 167 ) 160 168 } 161 169