feat: Discord webhook integration for in-game events#38
Conversation
Allow cargo ship markers (type 5) to scale naturally with zoom by using a linear scaling factor (exp=0.5) instead of the exponential scaling used for other markers. This makes cargo ships grow/shrink more intuitively on the map as the user zooms in/out.
- Update version to 4.2.0 in project file and installer script - Set BitmapCreateOptions.IgnoreColorProfile and BitmapScalingMode.HighQuality for map images - Update patch notes with details for the "High-Fidelity Update"
Update the title and feature list for version 4.2.0 to better reflect the implemented changes. The update emphasizes high-fidelity rendering and animation improvements, and provides more detailed and descriptive explanations of each new feature.
- fix: fixed Cargiship icon size scaling to make feel more natural on the map and improve map image rendering quality for less pixelation when zoming in
Added details about the Cargo Ship overhaul, including smart cargo tracking features, cargo chat notifications, and oil rig crate countdown.
Pushes embed alerts (Cargo, Heli, deaths, etc.) to a Discord channel via webhook. Single global URL works across every paired server, the embed shows which server fired the event, and a single right-click on a server in the list mutes alerts from just that server. What's added - DiscordWebhookService: singleton with HttpClient, async queue and rate limiter (25 msgs/min, well under Discord's webhook cap), embed builder, redacted URL logging. - Settings -> Discord Webhook section: URL field + Test button. The test sends a one-off "Webhook test successful" embed so users can confirm the URL before relying on it. - New "Discord" checkbox in the map controls bar, parallel to "Chat Alerts". Same three-state behavior, same right-click context menu with the full event list. Independent of the chat-alert toggles, so a user can route deaths to Discord only and Cargo to chat only. - Per-server mute via right-click on a server in the paired list: "Send Discord alerts" toggles the alerts for that one server. Default is on. Settings persisted on TrackingService: - DiscordWebhookUrl (string) - DiscordMaster (bool) - DiscordEventEnabled (Dictionary<tag,bool>) - DiscordServerMuted (Dictionary<host,bool>) Wired event sites - Cargo: dock, arrival warning, egress warning, generic spawn - Patrol Heli: spawn + crash detection - Chinook, Vendor: spawn - Oil Rig: trigger + interval updates - Deep Sea: spawn - Shops: new shop, suspicious shop - Players: online, offline, death, respawn (self + team) The Discord toggles are independent of the existing AnnounceX chat toggles. Detection logic was lifted out of the chat-alert if-blocks where needed so that toggling chat off doesn't suppress Discord. As a side effect the cargo dock-detection flag now sets reliably even when chat alerts are off (previously it silently re-fired every poll). Webhook URL is treated as a credential and never echoed in logs.
|
Hey @0xSteph, this is also a very interesting feature. Thank you again. I can definitely see the value here, especially for teams that already coordinate through Discord. Having Cargo/Heli/Oil Rig/death/player alerts pushed into a Discord channel could make Rust+ Desk much more useful for groups, not just solo users. I’d like to keep this separate from the i18n PR and test it as its own feature release. Since #35 is still in progress and may affect some of the same MainWindow areas, I’d prefer to resolve/merge the refactoring first, then rebase this PR on top of the cleaned-up structure. Before merging, I’ll need to do a local Windows build and test webhook URLs, toggles, rate limiting etc. etc. Overall: I like the idea a lot. I just want to merge it carefully and probably ship it as its own headline feature rather than mixing it with i18n or refactoring. |
|
Thanks, glad you like it. Sequencing makes sense. I'll watch #35 and rebase once it lands. If MainWindow gets reshuffled a lot, ping me and I'll redo the wiring. Quick notes for testing:
Happy to split UI from notification logic if that's easier to review. Otherwise I'll leave it as is. |
What this is
Pushes in-game events (Cargo, Heli, deaths, etc.) to a Discord channel via webhook. One global URL works across every paired server, the embed shows which server fired the event, and a right-click on a server mutes alerts from just that one.
Filing as draft because I don't have a Windows machine in this environment to compile and runtime-test the build. All XAML is well-formed (validated), the C# follows existing patterns, and the wiring is straightforward, but you'll want a local
dotnet buildplus a smoke test before review. Testing checklist below.This is a separate feature from PR #37 (i18n). The two don't share code, the maintainer can merge them in either order.
Setup, from a user's perspective
That's the entire setup. No per-server URLs to fill in.
Architecture
DiscordWebhookService(RustPlusDesktop/DiscordWebhookService.cs): singleton withHttpClient, async queue (BlockingCollection), and a 25-messages-per-minute rate limiter so a chaotic raid never breaches Discord's webhook cap.TrackingServicegains four persisted fields:DiscordWebhookUrl,DiscordMaster,DiscordEventEnabled(per-tag dictionary),DiscordServerMuted(per-host dictionary).MainWindow.xaml.csgets aDiscordSendEvent(eventTag, title, description, color, gridCoord)helper. Every existing chat-alert site got a parallel call to this helper. The service drops the message silently if the URL is empty, the per-server mute is on, or the per-event toggle is off.What does an embed look like
Title: ""Cargo Ship docked"". Description: ""Anchored at Harbor 2 (E14)"". Sidebar color: orange for cargo, red for deaths and heli kills, blue for events, green for player online, grey for offline, amber for shops, purple for vendor. Footer: ""Rust+ Desktop"". Server name and grid coords go into named fields.
Wired event sites
CargoDockCargoArrivalCargoEgressCargoSpawnHeliChinookVendorOilRigDeepSeaNewShopsSuspiciousShopsPlayerOnline/PlayerOfflinePlayerDeathSelf/PlayerDeathTeamPlayerRespawnSelf/PlayerRespawnTeamPer-server mute
Right-click a paired server in the list, click "Send Discord alerts" to toggle. Default on. Stored per server host so muting persists across sessions. Same context-menu pattern the Listen pairing button already uses, no new UI.
Things to know
state.AnnouncedDock = truewas previously only set when chat alerts were on, so with chat off the same dock event would re-fire every poll. The refactor sets the flag at detection time, independent of either alert sink.Out of scope (deliberately)
@everyone,@<role-id>) on critical events. Adds another text field and another toggle for niche value. Easy to add later if anyone asks.Testing checklist (for the maintainer)
dotnet buildclean, no new warnings.Mechanics
Branched from current
master. Independent of PR #37 (i18n localization). Hardcoded English strings for now; if i18n lands first I'll do a tiny follow-up to migrate them to keys.