Class: Findbug::Alerts::Channels::Discord

Inherits:
Base
  • Object
show all
Defined in:
lib/findbug/alerts/channels/discord.rb

Overview

Discord sends alerts via Discord webhooks.

CONFIGURATION

config.alerts do |alerts|
  alerts.discord(
    enabled: true,
    webhook_url: ENV["DISCORD_WEBHOOK_URL"],
    username: "Findbug",  # optional
    avatar_url: "https://..." # optional
  )
end

SETTING UP DISCORD WEBHOOK

  1. Go to your Discord server settings

  2. Navigate to Integrations > Webhooks

  3. Create a new webhook

  4. Copy the webhook URL

Discord webhooks are similar to Slack but use a different payload format.

Instance Attribute Summary

Attributes inherited from Base

#config

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Findbug::Alerts::Channels::Base

Instance Method Details

#send_alert(error_event) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/findbug/alerts/channels/discord.rb', line 35

def send_alert(error_event)
  webhook_url = config[:webhook_url]
  return if webhook_url.blank?

  payload = build_payload(error_event)
  post_to_webhook(webhook_url, payload)
end