Skip to content

Commit

Permalink
Merge pull request #1627 from irismessage/postround-webhook
Browse files Browse the repository at this point in the history
Add dividers for postround chat
  • Loading branch information
formlessnameless authored Feb 9, 2025
2 parents 860ef4b + 4504b37 commit 62f5b41
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Content.Server/GameTicking/GameTicker.CVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public sealed partial class GameTicker

private WebhookIdentifier? _webhookIdentifier;

private WebhookIdentifier? _webhookIdentifierPostround;

[ViewVariables]
private string? RoundEndSoundCollection { get; set; }

Expand Down Expand Up @@ -63,6 +65,13 @@ private void InitializeCVars()
_discord.GetWebhook(value, data => _webhookIdentifier = data.ToIdentifier());
}
}, true);
Subs.CVar(_cfg, CCVars.DiscordPostroundChatWebhook, value =>
{
if (!string.IsNullOrWhiteSpace(value))
{
_discord.GetWebhook(value, data => _webhookIdentifierPostround = data.ToIdentifier());
}
}, true);
Subs.CVar(_cfg, CCVars.DiscordRoundEndRoleWebhook, value =>
{
DiscordRoundEndRole = value;
Expand Down
18 changes: 18 additions & 0 deletions Content.Server/GameTicking/GameTicker.RoundFlow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,15 @@ private async void SendRoundEndDiscordMessage()
payload.AllowedMentions.AllowRoleMentions();

await _discord.CreateMessage(_webhookIdentifier.Value, payload);

if (_webhookIdentifierPostround == null)
return;

content = Loc.GetString("discord-round-postround-end",
("id", RoundId));
payload = new WebhookPayload { Content = content };

await _discord.CreateMessage(_webhookIdentifierPostround.Value, payload);
}
catch (Exception e)
{
Expand Down Expand Up @@ -662,6 +671,15 @@ private async void SendRoundStartedDiscordMessage()
var payload = new WebhookPayload { Content = content };

await _discord.CreateMessage(_webhookIdentifier.Value, payload);

if (_webhookIdentifierPostround == null)
return;

content = Loc.GetString("discord-round-postround-started",
("id", RoundId));
payload = new WebhookPayload { Content = content };

await _discord.CreateMessage(_webhookIdentifierPostround.Value, payload);
}
catch (Exception e)
{
Expand Down
8 changes: 7 additions & 1 deletion Content.Shared/CCVar/CCVars.Discord.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Robust.Shared.Configuration;
using Robust.Shared.Configuration;

namespace Content.Shared.CCVar;

Expand Down Expand Up @@ -53,6 +53,12 @@ public sealed partial class CCVars
public static readonly CVarDef<string> DiscordRoundUpdateWebhook =
CVarDef.Create("discord.round_update_webhook", string.Empty, CVar.SERVERONLY | CVar.CONFIDENTIAL);

/// <summary>
/// URL of the Discord webhook which will relay round restart messages.
/// </summary>
public static readonly CVarDef<string> DiscordPostroundChatWebhook =
CVarDef.Create("discord.postround_chat_webhook", string.Empty, CVar.SERVERONLY | CVar.CONFIDENTIAL);

/// <summary>
/// Role id for the Discord webhook to ping when the round ends.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions Resources/Locale/en-US/discord/round-notifications.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ discord-round-notifications-started = Round #{$id} on map "{$map}" started.
discord-round-notifications-end = Round #{$id} has ended. It lasted for {$hours} hours, {$minutes} minutes, and {$seconds} seconds.
discord-round-notifications-end-ping = <@&{$roleId}>, the server will reboot shortly!
discord-round-notifications-unknown-map = Unknown
discord-round-postround-started = ```ROUND START: #{$id}```
discord-round-postround-end = ```ROUND END: #{$id}```

0 comments on commit 62f5b41

Please sign in to comment.