From 5399372c053d43bd92b3511156cd2ee1f05f7767 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 30 May 2025 20:52:33 -0500 Subject: [PATCH] fix: don't make rest api client dependent on instrumentation --- src/src/StevesBot.Library/Discord/ServicesExtensions.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/src/StevesBot.Library/Discord/ServicesExtensions.cs b/src/src/StevesBot.Library/Discord/ServicesExtensions.cs index 542dcd5..71a9183 100644 --- a/src/src/StevesBot.Library/Discord/ServicesExtensions.cs +++ b/src/src/StevesBot.Library/Discord/ServicesExtensions.cs @@ -17,9 +17,10 @@ public static class ServicesExtensions c.BaseAddress = new Uri(discordOptions.ApiUrl); c.DefaultRequestHeaders.Authorization = new("Bot", discordOptions.AppToken); - var instrumentation = sp.GetRequiredService(); + var instrumentation = sp.GetService(); + var version = instrumentation?.SourceVersion ?? "0.0.0"; - var userAgentString = $"DiscordBot (https://github.com/StevanFreeborn/steves-bot, {instrumentation.SourceVersion})"; + var userAgentString = $"DiscordBot (https://github.com/StevanFreeborn/steves-bot, {version})"; c.DefaultRequestHeaders.Add("User-Agent", userAgentString); }) .AddStandardResilienceHandler();