A Discord API Library for Gleam! 💫
0

Configure Feed

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

rename state to context

+6 -6
+6 -6
examples/http_interactions/src/http_interactions.gleam
··· 235 235 } 236 236 237 237 fn start_interaction_handler( 238 - state: InteractionHandlerContext, 238 + context: InteractionHandlerContext, 239 239 interaction: Interaction, 240 240 ) -> Result( 241 241 actor.Started(process.Subject(InteractionHandlerMessage)), ··· 251 251 // Let's send a message on actor start-up. 252 252 process.send(subject, InteractionCreated(interaction)) 253 253 254 - actor.initialised(state) 254 + actor.initialised(context) 255 255 |> actor.returning(subject) 256 256 |> actor.selecting(selector) 257 257 |> Ok ··· 261 261 } 262 262 263 263 fn handle_interaction_handler_message( 264 - state: InteractionHandlerContext, 264 + context: InteractionHandlerContext, 265 265 message: InteractionHandlerMessage, 266 266 ) -> actor.Next(InteractionHandlerContext, a) { 267 267 // We only deal with one type of message here, 268 268 // but the case statement exists for future-proofing. 269 269 case message { 270 - InteractionCreated(interaction) -> handle_interaction(state, interaction) 270 + InteractionCreated(interaction) -> handle_interaction(context, interaction) 271 271 } 272 272 } 273 273 274 274 // Finally, we get to handle our interaction. 275 275 fn handle_interaction( 276 - state: InteractionHandlerContext, 276 + context: InteractionHandlerContext, 277 277 interaction: Interaction, 278 278 ) -> actor.Next(InteractionHandlerContext, a) { 279 279 // At this step, you'd: ··· 283 283 // But here, let's skip all that and just immediately respond with "Pong!" to every interaction 284 284 // sent to our bot. 285 285 let _result = 286 - state.client 286 + context.client 287 287 |> interaction.respond( 288 288 to: interaction, 289 289 using: interaction.RespondWithChannelMessageWithSource(