diff --git a/Helper.cs b/Helper.cs index 7a38528..d2d9641 100644 --- a/Helper.cs +++ b/Helper.cs @@ -7,6 +7,8 @@ using CounterStrikeSharp.API.Modules.Entities; using CounterStrikeSharp.API.Modules.Memory; using CounterStrikeSharp.API.Modules.Menu; using Discord; +using Discord.Webhook; +using Microsoft.Extensions.Localization; using Microsoft.Extensions.Logging; using System.Reflection; using System.Runtime.CompilerServices; @@ -196,6 +198,16 @@ namespace CS2_SimpleAdmin return new List { embed.Build() }; } + public static void SendDiscordLogMessage(CCSPlayerController? caller, CommandInfo command, DiscordWebhookClient? discordWebhookClientLog, IStringLocalizer? localizer) + { + if (discordWebhookClientLog != null && localizer != null) + { + string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : ""; + string callerName = caller != null ? caller.PlayerName : "Console"; + discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString])); + } + } + public static string GenerateMessageDiscord(string message) { string? hostname = ConVar.Find("hostname")!.StringValue ?? CS2_SimpleAdmin._localizer?["sa_unknown"] ?? "Unknown";