2

fleffing discord bot in c sharp can yuo please let my title through

Free lines C# 1 revisions 123 3 months ago 3 months ago
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;

using Discord;
using Discord.Commands;
using Discord.WebSocket;
using Microsoft.Extensions.DependencyInjection;


namespace KevBot
{
    class Program
    {
        private DiscordSocketClient Client;
        private CommandService Commands;
        private IServiceProvider Service;

        static void Main(string[] args)
        => new Program().mainAsync().GetAwaiter().GetResult();

        public async Task mainAsync()
        {
            Client = new DiscordSocketClient(new DiscordSocketConfig
            {
                LogLevel = LogSeverity.Debug             
                
            });

            Commands = new CommandService(new CommandServiceConfig
            {
                CaseSensitiveCommands = false,
                DefaultRunMode = RunMode.Async,
                LogLevel = LogSeverity.Debug

            });

            Service = new ServiceCollection().BuildServiceProvider();

            Client.MessageReceived += Client_MessageRecieved;
            await Commands.AddModulesAsync(Assembly.GetEntryAssembly(), Service);

            Client.Ready += Client_Ready;
            Client.Log += Client_Log;

            string token = "my token is a secret, you idiot";
            await Client.LoginAsync(TokenType.Bot, token);
            await Client.StartAsync();

            await Task.Delay(-1);
        }



        private async Task Client_Log(LogMessage Message)
        {
            Console.WriteLine($"{DateTime.Now} at {Message.Source}] {Message.Message}");
        }

        private async Task Client_Ready()
        {
            await Client.SetGameAsync("lol");
        }

        private async Task Client_MessageRecieved(SocketMessage MessageParam)
            {
                var Message = MessageParam as SocketUserMessage;
                var Context = new SocketCommandContext(Client, Message);

                if (Context.Message == null || Context.Message.Content == "") return;
                if (Context.User.IsBot) return;

                int ArgPos = 0;
                if (!(Message.HasStringPrefix("c!", ref ArgPos) || Message.HasMentionPrefix(Client.CurrentUser, ref ArgPos))) return;

                var Result = await Commands.ExecuteAsync(Context, ArgPos, Service);
                if (!Result.IsSuccess)
                    Console.WriteLine($"{DateTime.Now} at  Commands] Something went wrong with executing a command. Text: {Context.Message.Content} Error: {Result.ErrorReason} ");

            }
        
        

        
    }
}

an initialization of a really bad bot