FoxyBot Discord
csharp
using Discord;
using Discord.Commands;
using Discord.WebSocket;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Reflection;
using System.Threading.Tasks;

namespace FoxBot
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Title = "FoxyBot";
            new Program().RunBotAsync().GetAwaiter().GetResult();
        }

        private DiscordSocketClient _client;
        private CommandService _commands;
        private IServiceProvider _services;

        public async Task RunBotAsync()
        {
            _client = new DiscordSocketClient();
            _commands = new CommandService();

            _services = new ServiceCollection()
                .AddSingleton(_client)
                .AddSingleton(_commands)
                .BuildServiceProvider();

            string token = "4npXyc";

            _client.Log += _client_Log;

            await RegisterCommandsAsync();

            await _client.LoginAsync(TokenType.Bot, token);

            await _client.StartAsync();

            await Task.Delay(-1);

        }

        private Task _client_Log(LogMessage arg)
        {
            Console.WriteLine(arg);
            return Task.CompletedTask;
        }

        public async Task RegisterCommandsAsync()
        {
            _client.MessageReceived += HandleCommandAsync;
            _client.SlashCommandExecuted += _client_SlashCommandExecuted;
            await _commands.AddModulesAsync(Assembly.GetEntryAssembly(), _services);
        }

        private async Task _client_SlashCommandExecuted(SocketSlashCommand arg)
        {
            //var slash = arg as SocketSlashCommand;
            //var context = new SocketSlashCommandData(_client, slash);
        }

        private async Task HandleCommandAsync(SocketMessage arg)
        {
            var message = arg as SocketUserMessage;
            //SocketCommandContext context = new SocketCommandContext(_client,message);
            var context = new SocketCommandContext(_client, message);
            if (message.Author.IsBot) return;

            int argPos = 0;
            if (message.HasStringPrefix("", ref argPos))
            {
                // LOGS ============================================
                Console.ForegroundColor = ConsoleColor.Magenta; Console.Write(context.Guild.Name);
                Console.ForegroundColor = ConsoleColor.White; Console.Write(" -> ");
                Console.ForegroundColor = ConsoleColor.Yellow; Console.Write(message.Channel.Name);
                Console.ForegroundColor = ConsoleColor.White; Console.Write(" -> ");
                Console.ForegroundColor = ConsoleColor.Cyan; Console.Write(message.Author.Username);
                Console.ForegroundColor = ConsoleColor.White; Console.Write(": ");
                Console.ForegroundColor = ConsoleColor.Green; Console.Write(message);
                Console.WriteLine(); Console.ResetColor();
                // LOGS ============================================

                var result = await _commands.ExecuteAsync(context, argPos, _services);

                /*if (!result.IsSuccess)
                {
                    await message.Channel.SendMessageAsync("Данная команда полная хуйня! Попробуй `/fh help`");
                }*/

                if (result.Error.Equals(CommandError.UnmetPrecondition)) await message.Channel.SendMessageAsync(result.ErrorReason);
            }
        }
    }
}