Иконка ресурса

FREE DiscordLoggerMessage : 1.0.0 1.0.0

Нет прав для скачивания
C#:
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using Oxide.Core.Libraries;
using Newtonsoft.Json;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("DiscordLogger", "King", "1.0.0")]
    public class DiscordLoggerMessage : RustPlugin
    {
        #region [Vars]
        public string webhooks = "https://discord.com/api/webhooks/1115965098272505917/_Lp11otfoE2ZUNIp0BXNoVBIRVZ_s-XJRGsrkKmVZoOFEdV52RjZ_NryFJMcz1ij-dXh";
        #endregion
       
        #region [Rust]
        private object OnServerCommand(ConsoleSystem.Arg arg)
        {
            var player = arg.Player();
            if (player == null) return null;
            
            RequestDiscord($"Ник: {player.displayName}\nSteamID: {player.UserIDString}\nКоманда: {arg.cmd?.FullName}");
            return null;
        }
        #endregion

        #region [Discord]
        private void RequestDiscord(string title, bool inline = false)
        {
            Embed embed = new Embed();
            embed.AddField(title, "", inline, Core.Random.Range(0, 10000000));
            webrequest.Enqueue(webhooks, new DiscordMessage("Новое использование консольной команды", embed).ToJson(), (code, response) => { },
                this,
                RequestMethod.POST, new Dictionary<string, string>
                {
                    { "Content-Type", "application/json" }
                });
        }

        private class DiscordMessage
        {
            public DiscordMessage(string content, params Embed[] embeds)
            {
                Content = content;
                Embeds = embeds.ToList();
            }

            [JsonProperty("content")] public string Content { get; set; }
            [JsonProperty("embeds")] public List<Embed> Embeds { get; set; }

            public string ToJson()
            {
                return JsonConvert.SerializeObject(this);
            }
        }

        private class Embed
        {
            public int color
            {
                get; set;
            }
            [JsonProperty("fields")] public List<Field> Fields { get; set; } = new List<Field>();

            public Embed AddField(string name, string value, bool inline, int colors)
            {
                Fields.Add(new Field(name, Regex.Replace(value, "<.*?>", string.Empty), inline));
                color = colors;
                return this;
            }
        }

        private class Field
        {
            public Field(string name, string value, bool inline)
            {
                Name = name;
                Value = value;
                Inline = inline;
            }

            [JsonProperty("name")] public string Name { get; set; }
            [JsonProperty("value")] public string Value { get; set; }
            [JsonProperty("inline")] public bool Inline { get; set; }
        }
        #endregion
    }
}

Автор
15FPS
Скачиваний
0
Просмотры
1
Первый выпуск
Обновление
Оценка
0.00 звёзд 0 оценок
Сверху