diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs index 02914f87d7..6f7ad59c5a 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs @@ -218,6 +218,22 @@ namespace Tgstation.Server.Host.Components.Chat.Providers var channelsClient = serviceProvider.GetRequiredService(); async ValueTask SendToChannel(Snowflake channelId) { + if (message.Text == null) + { + Logger.LogWarning( + "Failed to send to channel {channelId}: Message was null!", + channelId); + + await channelsClient.CreateMessageAsync( + channelId, + "TGS: Could not send message to Discord. Message was `null`!", + messageReference: replyToReference, + allowedMentions: allowedMentions, + ct: cancellationToken); + + return; + } + var result = await channelsClient.CreateMessageAsync( channelId, message.Text, @@ -940,7 +956,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers /// The to convert. /// The parameter for sending a single . #pragma warning disable CA1502 - Optional> ConvertEmbed(ChatEmbed embed) + Optional> ConvertEmbed(ChatEmbed? embed) { if (embed == null) return default; diff --git a/src/Tgstation.Server.Host/Components/Interop/MessageContent.cs b/src/Tgstation.Server.Host/Components/Interop/MessageContent.cs index 73e2980906..6b04fb10ae 100644 --- a/src/Tgstation.Server.Host/Components/Interop/MessageContent.cs +++ b/src/Tgstation.Server.Host/Components/Interop/MessageContent.cs @@ -1,6 +1,4 @@ -#nullable disable - -namespace Tgstation.Server.Host.Components.Interop +namespace Tgstation.Server.Host.Components.Interop { /// /// Represents a message to send to a chat provider. @@ -10,11 +8,11 @@ namespace Tgstation.Server.Host.Components.Interop /// /// The message . /// - public string Text { get; set; } + public string? Text { get; set; } /// /// The . /// - public ChatEmbed Embed { get; set; } + public ChatEmbed? Embed { get; set; } } }