Webhook classserver
Part of Flow
A Discord webhook that the server can post messages to. The class is also the registry of
the webhooks: Webhook:add stores a webhook under an ID, and Webhook:get, Webhook:all
and Webhook:get_type look the stored ones up. Every webhook lists the types of messages it
accepts, so that a message of some type can be posted to all of the webhooks that want it.
Flux creates the webhooks listed in the settings of the server and posts log messages to
them with Log:to_discord.
Summary
Methods
Methods
Adds a webhook to the list of registered webhooks.
Webhook:add(id, Webhook.new(data.id, data.key, data.types))
Parameters
- id String ID to store the webhook under
- webhook Webhook/Function optional, defaults to
nilwebhook or a function that returns one, a blank webhook is created if omitted
Returns
- Webhook the stored webhook
Returns all of the registered webhooks.
Returns
- Map webhooks by ID
Returns the registered webhook with the specified ID. Also available as Webhook#find and Webhook#find_by_id.
Parameters
- id String
Returns
- Webhook the webhook, or nil if there is no such webhook
Returns the registered webhooks that accept messages of the specified type.
Parameters
- message_type String message type
Returns
- List<Webhook>
Creates a new Discord webhook.
Parameters
- id String optional, defaults to
''ID of the Discord webhook - key String optional, defaults to
''token of the Discord webhook - types List<String> optional, defaults to
{}types of messages the webhook accepts, 'all' for any type
Checks whether this webhook accepts messages of the specified type.
Parameters
- message_type String message type
Returns
- Boolean
Checks whether a webhook with the specified ID is registered. Also available as Webhook#exists and Webhook#exist.
Parameters
- id String
Returns
- Boolean
Posts a message to the Discord webhook.
Parameters
- message String
- data Map optional, defaults to
{}optional username, avatar_url and tts fields of the message