mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-07-15 10:03:02 +01:00
Nullify MessageContent
This commit is contained in:
@@ -218,6 +218,22 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
var channelsClient = serviceProvider.GetRequiredService<IDiscordRestChannelAPI>();
|
||||
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
|
||||
/// <param name="embed">The <see cref="ChatEmbed"/> to convert.</param>
|
||||
/// <returns>The parameter for sending a single <see cref="IEmbed"/>.</returns>
|
||||
#pragma warning disable CA1502
|
||||
Optional<IReadOnlyList<IEmbed>> ConvertEmbed(ChatEmbed embed)
|
||||
Optional<IReadOnlyList<IEmbed>> ConvertEmbed(ChatEmbed? embed)
|
||||
{
|
||||
if (embed == null)
|
||||
return default;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#nullable disable
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Interop
|
||||
namespace Tgstation.Server.Host.Components.Interop
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a message to send to a chat provider.
|
||||
@@ -10,11 +8,11 @@ namespace Tgstation.Server.Host.Components.Interop
|
||||
/// <summary>
|
||||
/// The message <see cref="string"/>.
|
||||
/// </summary>
|
||||
public string Text { get; set; }
|
||||
public string? Text { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ChatEmbed"/>.
|
||||
/// </summary>
|
||||
public ChatEmbed Embed { get; set; }
|
||||
public ChatEmbed? Embed { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user