diff --git a/Content.Packaging/ServerPackaging.cs b/Content.Packaging/ServerPackaging.cs index 3ca53225de..947a12601c 100644 --- a/Content.Packaging/ServerPackaging.cs +++ b/Content.Packaging/ServerPackaging.cs @@ -47,6 +47,7 @@ public static class ServerPackaging // Python script had Npgsql. though we want Npgsql.dll as well soooo "Npgsql", "Microsoft", + "Discord", }; private static readonly List ServerNotExtraAssemblies = new() diff --git a/Content.Server/Discord/DiscordLink/DiscordChatLink.cs b/Content.Server/Discord/DiscordLink/DiscordChatLink.cs index 5460c9e274..5a2c064e4d 100644 --- a/Content.Server/Discord/DiscordLink/DiscordChatLink.cs +++ b/Content.Server/Discord/DiscordLink/DiscordChatLink.cs @@ -8,12 +8,15 @@ using Robust.Shared.Configuration; namespace Content.Server.Discord.DiscordLink; -public sealed class DiscordChatLink +public sealed class DiscordChatLink : IPostInjectInit { [Dependency] private readonly DiscordLink _discordLink = default!; [Dependency] private readonly IConfigurationManager _configurationManager = default!; [Dependency] private readonly IChatManager _chatManager = default!; [Dependency] private readonly ITaskManager _taskManager = default!; + [Dependency] private readonly ILogManager _logManager = default!; + + private ISawmill _sawmill = default!; private ulong? _oocChannelId; private ulong? _adminChannelId; @@ -73,7 +76,7 @@ public sealed class DiscordChatLink } } - public async Task SendMessage(string message, string author, ChatChannel channel) + public async void SendMessage(string message, string author, ChatChannel channel) { var channelId = channel switch { @@ -91,6 +94,18 @@ public sealed class DiscordChatLink // @ and < are both problematic for discord due to pinging. / is sanitized solely to kneecap links to murder embeds via blunt force message = message.Replace("@", "\\@").Replace("<", "\\<").Replace("/", "\\/"); - await _discordLink.SendMessageAsync(channelId.Value, $"**{channel.GetString()}**: `{author}`: {message}"); + try + { + await _discordLink.SendMessageAsync(channelId.Value, $"**{channel.GetString()}**: `{author}`: {message}"); + } + catch (Exception e) + { + _sawmill.Error($"Error while sending Discord message: {e}"); + } + } + + void IPostInjectInit.PostInject() + { + _sawmill = _logManager.GetSawmill("discord.chat"); } } diff --git a/Content.Server/Discord/DiscordLink/DiscordLink.cs b/Content.Server/Discord/DiscordLink/DiscordLink.cs index a9172c98f7..abf3189a99 100644 --- a/Content.Server/Discord/DiscordLink/DiscordLink.cs +++ b/Content.Server/Discord/DiscordLink/DiscordLink.cs @@ -103,7 +103,11 @@ public sealed class DiscordLink : IPostInjectInit _client = new DiscordSocketClient(new DiscordSocketConfig() { - GatewayIntents = GatewayIntents.All + GatewayIntents = GatewayIntents.Guilds + | GatewayIntents.GuildMembers + | GatewayIntents.GuildMessages + | GatewayIntents.MessageContent + | GatewayIntents.DirectMessages, }); _client.Log += Log; _client.MessageReceived += OnCommandReceivedInternal; diff --git a/Content.Shared/Chat/ChatChannel.cs b/Content.Shared/Chat/ChatChannel.cs index 88218c0bfa..faed544b82 100644 --- a/Content.Shared/Chat/ChatChannel.cs +++ b/Content.Shared/Chat/ChatChannel.cs @@ -107,7 +107,7 @@ namespace Content.Shared.Chat return channel switch { ChatChannel.OOC => Loc.GetString("chat-channel-humanized-ooc"), - ChatChannel.Admin => Loc.GetString("chat-channel-humanized-admin"), + ChatChannel.AdminChat => Loc.GetString("chat-channel-humanized-admin"), _ => throw new ArgumentOutOfRangeException(nameof(channel), channel, null) }; }