View Source Xhawn.Consumer (xhawn_bot v0.1.0)

Consumer Module

This module handles various events from Discord using pattern matching and event-specific handlers.

Event Handling

Each handle_event/1 function follows this pattern:

The function head pattern matches on the first argument to trigger the correct event handler.

The second argument contains the relevant Nostrum.Struct.

The third argument represents the WebSocket state.

The body of each handle_event/1 function triggershandle/1 function in Xhawn.Consumer.

Struct Match at Entry Point

Each handle/1 function pattern matches on the relevant struct.

Example

For a message creation event:

def handle_event({:MESSAGE_CREATE, %Nostrum.Struct.Message{} = msg, _ws_state}) do
  MessageCreate.handle(msg)
end

Summary

Functions

Returns a specification to start this module under a supervisor.

Handles any unmatched events.

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Handles any unmatched events.

This function is called for any event that doesn't match the other handle_event/1 functions.

Parameters

  • _event: The unmatched event data.

Return

:noop (no operation).