Skip to content

Commit ec93e67

Browse files
committed
fix: solve zeitwerk scrims issues
1 parent bb648ce commit ec93e67

1 file changed

Lines changed: 31 additions & 35 deletions

File tree

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,41 @@
11
# frozen_string_literal: true
22

3-
module Scrims
4-
module Services
5-
# Sends Discord webhook notifications for scrim-related events.
6-
# Webhook URL is configured via SCRIMS_LOL_DISCORD_WEBHOOK_URL env variable.
7-
class DiscordWebhookService
8-
WEBHOOK_URL = ENV.fetch('SCRIMS_LOL_DISCORD_WEBHOOK_URL', nil)
3+
# Sends Discord webhook notifications for scrim-related events.
4+
# Webhook URL is configured via SCRIMS_LOL_DISCORD_WEBHOOK_URL env variable.
5+
class DiscordWebhookService
6+
WEBHOOK_URL = ENV.fetch('SCRIMS_LOL_DISCORD_WEBHOOK_URL', nil)
97

10-
def self.notify_scrim_created(scrim)
11-
return unless WEBHOOK_URL.present?
8+
def self.notify_scrim_created(scrim)
9+
return unless WEBHOOK_URL.present?
1210

13-
org_name = scrim.organization.name
14-
opponent = scrim.opponent_team&.name || 'TBD'
15-
scheduled = scrim.scheduled_at&.strftime('%d/%m %H:%M') || 'TBD'
11+
org_name = scrim.organization.name
12+
opponent = scrim.opponent_team&.name || 'TBD'
13+
scheduled = scrim.scheduled_at&.strftime('%d/%m %H:%M') || 'TBD'
1614

17-
payload = {
18-
embeds: [{
19-
title: '📅 New Scrim Scheduled',
20-
color: 0xC89B3C,
21-
fields: [
22-
{ name: 'Team', value: org_name, inline: true },
23-
{ name: 'Opponent', value: opponent, inline: true },
24-
{ name: 'Scheduled', value: scheduled, inline: true }
25-
],
26-
footer: { text: 'scrims.lol — powered by ProStaff.gg' },
27-
timestamp: Time.current.iso8601
28-
}]
29-
}
15+
payload = {
16+
embeds: [{
17+
title: 'New Scrim Scheduled',
18+
color: 0xC89B3C,
19+
fields: [
20+
{ name: 'Team', value: org_name, inline: true },
21+
{ name: 'Opponent', value: opponent, inline: true },
22+
{ name: 'Scheduled', value: scheduled, inline: true }
23+
],
24+
footer: { text: 'scrims.lol — powered by ProStaff.gg' },
25+
timestamp: Time.current.iso8601
26+
}]
27+
}
3028

31-
post_webhook(payload)
32-
end
29+
post_webhook(payload)
30+
end
3331

34-
def self.post_webhook(payload)
35-
conn = Faraday.new(url: WEBHOOK_URL) do |f|
36-
f.request :json
37-
f.adapter Faraday.default_adapter
38-
end
39-
conn.post('', payload)
40-
rescue Faraday::Error => e
41-
Rails.logger.warn("[ScrimsDiscordWebhook] #{e.message}")
42-
end
32+
def self.post_webhook(payload)
33+
conn = Faraday.new(url: WEBHOOK_URL) do |f|
34+
f.request :json
35+
f.adapter Faraday.default_adapter
4336
end
37+
conn.post('', payload)
38+
rescue Faraday::Error => e
39+
Rails.logger.warn("[ScrimsDiscordWebhook] #{e.message}")
4440
end
4541
end

0 commit comments

Comments
 (0)