Example #1
0
        private Task Client_MessageCreated(DSharpPlus.EventArgs.MessageCreateEventArgs e)
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write($"@{e.Author.Username} #{e.Channel.Name} in {e.Guild.Name}:");
            Console.ForegroundColor = ConsoleColor.White;
            Console.Write($" {e.Message.Content}\n");

            if (e.Message.MentionedUsers.Contains(client.CurrentUser))
            {
                if (!SetupMode)
                {
                    ProcessCommand(e.Message.Content, e, CommandTrigger.BotMentioned);
                }
            }
            else if (e.Message.Content.StartsWith(config.Prefix)) // We check if the message received starts with our bot's command prefix. If it does...
            {
                if (SetupMode)
                {
                    string[] messageSplit = e.Message.Content.Split(' ');
                    if (messageSplit.Length == 2)
                    {
                        if (messageSplit[0] == $"{config.Prefix}authenticate" && messageSplit[1].Trim() == AuthorizationCode)
                        {
                            //we've authenticated!
                            SetupMode         = false;
                            AuthorizationCode = "";
                            config.OwnerID    = e.Message.Author.Id.ToString();
                            config.WriteConfig();
                            e.Channel.SendMessageAsync($"I'm all yours, {e.Message.Author.Mention}~!");
                            commandManager.AddPermission(e.Message.Author, PermissionType.Owner);
                            commandManager.WritePermissionsFile(); //Write the permissions file to the disk so she remembers who her owner is.

                            InitCommands();
                        }
                    }

                    return(Task.Delay(0));
                }
                // We move onto processing the command.
                // We pass in the MessageCreateEventArgs so we can get other information like channel, author, etc. The CommandsManager wants these things
                ProcessCommand(e.Message.Content, e, CommandTrigger.MessageCreate);
            }

            return(Task.Delay(0));
        }
Example #2
0
        private Task SetupEvents(CancellationToken token)
        {
            Console.ForegroundColor = ConsoleColor.White;
            return(Task.Run(() =>
            {
                client.MessageReceived += (sender, e) =>
                {
                    if (!doingInitialRun)
                    {
                        if (owner == null)
                        {
                            owner = client.GetServersList().Find(x => x.GetMemberByKey(config.OwnerID) != null).GetMemberByKey(config.OwnerID); //prays
                        }
                    }


                    if (e.Author == null)
                    {
                        string msg = $"Author had null id in message received!\nRaw JSON:\n```\n{e.RawJson}\n```\n";
                        msg += $"Args\nChannel: {e.Channel.Name}/{e.Channel.ID}\nMessage: {e.Message}";
                        try
                        {
                            owner.SlideIntoDMs(msg);
                        }
                        catch { }
                    }
                    else
                    {
                        Console.WriteLine($"[-- Message from {e.Author.Username} in #{e.Channel.Name} on {e.Channel.Parent.Name}: {e.Message.Content}");

                        if (doingInitialRun)
                        {
                            if (e.Message.Content.StartsWith("?authenticate"))
                            {
                                string[] split = e.Message.Content.Split(new char[] { ' ' }, 2);
                                if (split.Length > 1)
                                {
                                    if (codeToEnter.Trim() == split[1].Trim())
                                    {
                                        config.OwnerID = e.Author.ID;
                                        doingInitialRun = false;
                                        e.Channel.SendMessage("Authentication successful! **You are now my owner, " + e.Author.Username + ".**");
                                        CommandsManager.AddPermission(e.Author, PermissionType.Owner);
                                        owner = e.Author;
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (e.Message.Content.Length > 0 && (e.Message.Content[0] == config.CommandPrefix))
                            {
                                string rawCommand = e.Message.Content.Substring(1);
                                try
                                {
                                    CommandsManager.ExecuteOnMessageCommand(rawCommand, e.Channel, e.Author);
                                }
                                catch (UnauthorizedAccessException ex)
                                {
                                    e.Channel.SendMessage(ex.Message);
                                }
                                catch (ModuleNotEnabledException x)
                                {
                                    e.Channel.SendMessage($"{x.Message}");
                                }
                                catch (Exception ex)
                                {
                                    e.Channel.SendMessage("Exception occurred while running command:\n```" + ex.Message + "\n```");
                                }
                            }
                        }
                        //Now, for fun.
                        //if(e.author == owner)
                        //{
                        //    if (StringContainsObjectInArray(e.message.content.ToLower(), NaughtyWords))
                        //    {
                        //        try
                        //        {
                        //            var msg = client.GetMessageLog()[client.GetMessageLog().Count - 1].Value;
                        //            if (msg.author == owner
                        //                && client.GetLastMessageSent(e.Channel).content != null &&
                        //                client.GetLastMessageSent(e.Channel).content != "hey now")
                        //            {
                        //                //if(msg.timestamp.AddMinutes(1) < DateTime.Now)
                        //                int timebetween = (DateTime.Now.Minute - msg.timestamp.Minute);
                        //                if ((timebetween < 1) && (timebetween > -1)) //less than one minute between his message and my vulgarity
                        //                    e.Channel.SendMessage("hey now");
                        //            }
                        //        }
                        //        catch { }
                        //    }
                        //}

                        if (e.Channel.ID == "91265608326324224") //discord-sharp on discordapi
                        {
                            if (e.Author != owner)
                            {
                                if (e.Message.Content != null && e.Message.Content.ToLower().Contains("how"))
                                {
                                    if (e.Message.Content.ToLower().Contains("bot") && e.Message.Content.ToLower().Contains("tag"))
                                    {
                                        e.Channel.SendMessage($"<#124294271900712960>");//#api-changes
                                    }
                                }
                            }
                        }
                    }
                };
                client.VoiceClientDebugMessageReceived += (sender, e) =>
                {
                    if (e.message.Level != MessageLevel.Unecessary)
                    {
                        Console.WriteLine($"[{e.message.Level} {e.message.TimeStamp.ToString()}] {e.message.Message}");
                    }
                };
                client.VoiceClientConnected += (sender, e) =>
                {
                    try
                    {
                        owner.SlideIntoDMs($"Voice connection complete.");
                    }
                    catch { }
                    //player = new AudioPlayer(client.GetVoiceClient().VoiceConfig);
                    //bufferedWaveProvider = new BufferedWaveProvider(waveFormat);
                    //bufferedWaveProvider.BufferDuration = new TimeSpan(0, 0, 50);
                    //volumeProvider = new VolumeWaveProvider16(bufferedWaveProvider);
                    //volumeProvider.Volume = 1.1f;
                    //outputDevice.Init(volumeProvider);

                    //stutterReducingTimer = new System.Timers.Timer(500);
                    //stutterReducingTimer.Elapsed += StutterReducingTimer_Elapsed;
                    //PlayAudioAsync(cancelToken);
                };
                client.AudioPacketReceived += (sender, e) =>
                {
                    if (bufferedWaveProvider != null)
                    {
                        byte[] potential = new byte[4000];
                        int decodedFrames = client.GetVoiceClient().Decoder.DecodeFrame(e.OpusAudio, 0, e.OpusAudioLength, potential);
                        bufferedWaveProvider.AddSamples(potential, 0, decodedFrames);
                    }
                };
                client.GuildCreated += (sender, e) =>
                {
                    if (owner == null)
                    {
                        owner = client.GetServersList().Find(x => x.GetMemberByKey(config.OwnerID) != null).GetMemberByKey(config.OwnerID);
                    }
                    Console.WriteLine($"Joined server {e.Server.Name} ({e.Server.ID})");
                    try
                    {
                        owner.SlideIntoDMs($"Joined server {e.Server.Name} ({e.Server.ID})");
                    }
                    catch { }
                };
                client.GuildAvailable += (sender, e) =>
                {
                    Console.WriteLine($"Guild {e.Server.Name} became available.");
                };
                client.SocketClosed += (sender, e) =>
                {
                    Console.Title = "Luigibot - Discord - Socket Closed..";
                    if (!actuallyExit)
                    {
                        WriteError($"\n\nSocket Closed Unexpectedly! Code: {e.Code}. Reason: {e.Reason}. Clear: {e.WasClean}.\n\n");
                        Console.WriteLine("Waiting 6 seconds to reconnect..");
                        Thread.Sleep(6 * 1000);
                        LetsGoAgain();
                    }
                    else
                    {
                        Console.WriteLine($"Shutting down ({e.Code}, {e.Reason}, {e.WasClean})");
                    }
                };
                client.UnknownMessageTypeReceived += (sender, e) =>
                {
                    if (!Directory.Exists("dumps"))
                    {
                        Directory.CreateDirectory("dumps");
                    }
                    string message = $"Ahoy! An unknown message type `{e.RawJson["t"].ToString()}` was discovered with the contents: \n\n";
                    message += $"```\n{e.RawJson.ToString()}\n```\nIt's been dumped to `dumps/{e.RawJson["t"].ToString()}.json` for your viewing pleasure.";

                    string filename = $"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}dumps{Path.DirectorySeparatorChar}{e.RawJson["t"].ToString()}.json";
                    if (!File.Exists(filename))
                    {
                        File.WriteAllText(e.RawJson.ToString(), filename);
                        try
                        {
                            owner.SlideIntoDMs(message);
                        }
                        catch { }
                    }
                };
                client.TextClientDebugMessageReceived += (sender, e) =>
                {
                    if (e.message.Level == MessageLevel.Error || e.message.Level == MessageLevel.Critical)
                    {
                        WriteError($"(Logger Error) {e.message.Message}");
                        try
                        {
                            owner.SlideIntoDMs($"Bot error ocurred: ({e.message.Level.ToString()})```\n{e.message.Message}\n```");
                        }
                        catch { }
                    }
                    if (e.message.Level == MessageLevel.Warning)
                    {
                        WriteWarning($"(Logger Warning) {e.message.Message}");
                    }
                };
                client.Connected += (sender, e) =>
                {
                    Console.Title = "Luigibot - Discord - Logged in as " + e.User.Username;
                    Console.WriteLine("Connected as " + e.User.Username);
                    if (!String.IsNullOrEmpty(config.OwnerID))
                    {
                    }
                    else
                    {
                        doingInitialRun = true;
                        RandomCodeGenerator rcg = new RandomCodeGenerator();
                        codeToEnter = rcg.GenerateRandomCode();

                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.WriteLine("Important: ");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine("\tPlease authenticate yourself as owner by typing the following into any Discord server you and the bot are in: ");
                        Console.WriteLine($"\t{config.CommandPrefix}authenticate " + codeToEnter);
                    }
                    CommandsManager = new CommandsManager(client);
                    if (File.Exists("permissions.json"))
                    {
                        var permissionsDictionary = JsonConvert.DeserializeObject <Dictionary <string, PermissionType> >(File.ReadAllText("permissions.json"));
                        if (permissionsDictionary == null)
                        {
                            permissionsDictionary = new Dictionary <string, PermissionType>();
                        }
                        if (permissionsDictionary.Count == 0 && owner != null)
                        {
                            permissionsDictionary.Add(owner.ID, PermissionType.Owner);
                        }

                        CommandsManager.OverridePermissionsDictionary(permissionsDictionary);
                    }
                    SetupCommands();

                    if (config.ModulesDictionary != null)
                    {
                        CommandsManager.OverrideModulesDictionary(config.ModulesDictionary);
                    }

                    //client.UpdateCurrentGame($"DiscordSharp {typeof(DiscordClient).Assembly.GetName().Version.ToString()}");
                };
                if (client.SendLoginRequest() != null)
                {
                    client.Connect(UseBuiltInWebsocket);
                }
            }, token));
        }
Example #3
0
        private Task SetupEvents(CancellationToken token)
        {
            Console.ForegroundColor = ConsoleColor.White;
            return(Task.Run(() =>
            {
                client.MessageReceived += (sender, e) =>
                {
                    Console.WriteLine($"[-- Message from {e.author.Username} in #{e.Channel.Name} on {e.Channel.parent.name}: {e.message.content}");

                    if (doingInitialRun)
                    {
                        if (e.message.content.StartsWith("?authenticate"))
                        {
                            string[] split = e.message.content.Split(new char[] { ' ' }, 2);
                            if (split.Length > 1)
                            {
                                if (codeToEnter.Trim() == split[1].Trim())
                                {
                                    config.OwnerID = e.author.ID;
                                    doingInitialRun = false;
                                    e.Channel.SendMessage("Authentication successful! **You are now my owner, " + e.author.Username + ".**");
                                    CommandsManager.AddPermission(e.author, PermissionType.Owner);
                                    owner = e.author;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (e.message.content.Length > 0 && (e.message.content[0] == config.CommandPrefix))
                        {
                            string rawCommand = e.message.content.Substring(1);
                            try
                            {
                                CommandsManager.ExecuteCommand(rawCommand, e.Channel, e.author);
                            }
                            catch (UnauthorizedAccessException ex)
                            {
                                e.Channel.SendMessage(ex.Message);
                            }
                            catch (Exception ex)
                            {
                                e.Channel.SendMessage("Exception occurred while running command:\n```" + ex.Message + "\n```");
                            }
                        }
                    }
                };
                client.GuildCreated += (sender, e) =>
                {
                    Console.WriteLine("Joined server " + e.server.name);
                };
                client.Connected += (sender, e) =>
                {
                    Console.WriteLine("Connected as " + e.user.Username);
                    loginDate = DateTime.Now;

                    if (!String.IsNullOrEmpty(config.OwnerID))
                    {
                        owner = client.GetServersList().Find(x => x.members.Find(y => y.ID == config.OwnerID) != null).members.Find(x => x.ID == config.OwnerID);
                    }
                    else
                    {
                        doingInitialRun = true;
                        RandomCodeGenerator rcg = new RandomCodeGenerator();
                        codeToEnter = rcg.GenerateRandomCode();

                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.WriteLine("Important: ");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine("\tPlease authenticate yourself as owner by typing the following into any Discord server you and the bot are in: ");
                        Console.WriteLine($"\t{config.CommandPrefix}authenticate " + codeToEnter);
                    }
                    CommandsManager = new CommandsManager(client);
                    if (File.Exists("permissions.json"))
                    {
                        var permissionsDictionary = JsonConvert.DeserializeObject <Dictionary <string, PermissionType> >(File.ReadAllText("permissions.json"));
                        CommandsManager.OverridePermissionsDictionary(permissionsDictionary);
                    }
                    SetupCommands();
                };
                if (client.SendLoginRequest() != null)
                {
                    client.Connect();
                }
            }, token));
        }
Example #4
0
        public override void Install(CommandsManager manager)
        {
            manager.AddCommand(new CommandStub("uptime", "Check how long the bots been running for.", "No arguments", cmdArgs =>
            {
                TimeSpan uptime = DateTime.Now - mainEntry.ReadyTime;
                cmdArgs.Channel.SendMessageAsync($"I've been running for `{uptime.Days} days, {uptime.Hours} hrs, and {uptime.Minutes} mins`~");
            }, trigger: CommandTrigger.BotMentioned | CommandTrigger.MessageCreate), this);
            manager.AddCommand(new CommandStub("selfdestruct", "Shuts the bot down.", "", cmdArgs =>
            {
                mainEntry.Dispose();
            }, minPerm: PermissionType.Owner), this);
            manager.AddCommand(new CommandStub("reloadmodules", "Reloads the bot's modules", "No Arguments", cmdArgs =>
            {
                cmdArgs.Channel.SendMessageAsync($"Okay {cmdArgs.Author.Mention}~. Just give me one second!");
                cmdArgs.Channel.TriggerTypingAsync();
                int modulesLoaded = mainEntry.ReloadModules(true);
                Thread.Sleep(2000);
                cmdArgs.Channel.SendMessageAsync($"I'm back! I reloaded {modulesLoaded} module(s) for you!");
            }, PermissionType.Admin, trigger: CommandTrigger.BotMentioned | CommandTrigger.MessageCreate), this);
            manager.AddCommand(new CommandStub("removemodules", "Forces all modules out of memory (hopefully).", "No arguments", cmdArgs =>
            {
                cmdArgs.Channel.SendMessageAsync("Working on it....");
                cmdArgs.Channel.TriggerTypingAsync();
                int modulesLoaded = mainEntry.ReloadModules(false);
                cmdArgs.Channel.SendMessageAsync("Done~");
            }, PermissionType.Owner));
            manager.AddCommand(new CommandStub("giveperm", "Gives the perm to the specified user (bot scope)", "", e =>
            {
                //giveperm Admin <@2309208509852>
                if (e.Args.Count > 1)
                {
                    string permString   = e.Args[0];
                    PermissionType type = PermissionType.User;
                    switch (permString.ToLower())
                    {
                    case "admin":
                        type = PermissionType.Admin;
                        break;

                    case "mod":
                        type = PermissionType.Mod;
                        break;

                    case "none":
                        type = PermissionType.None;
                        break;

                    case "user":
                        type = PermissionType.User;
                        break;
                    }
                    string id = e.Args[1].Trim(new char[] { '<', '@', '>' });
                    manager.AddPermission(id, type);
                    e.Channel.SendMessageAsync($"Given permission {type.ToString().Substring(type.ToString().IndexOf('.') + 1)} to <@{id}>!");
                }
                File.WriteAllText("permissions.json", JsonConvert.SerializeObject(CommandsManager.UserRoles));
            }, PermissionType.Owner, 2), this);

            manager.AddCommand(new CommandStub("disablemodule", "Disables a module by name", "The module name is case insensitive.", cmdArgs =>
            {
                if (cmdArgs.Args[0].Length > 0)
                {
                    if (!manager.ModuleEnabled(cmdArgs.Args[0]))
                    {
                        cmdArgs.Channel.SendMessageAsync("Module already disabled!");
                        return;
                    }
                    try
                    {
                        manager.DisableModule(cmdArgs.Args[0]);
                        cmdArgs.Channel.SendMessageAsync($"Disabled {cmdArgs.Args[0]}.");
                    }
                    catch (Exception ex)
                    { cmdArgs.Channel.SendMessageAsync($"Couldn't disable module! {ex.Message}"); }
                }
                else
                {
                    cmdArgs.Channel.SendMessageAsync("What module?");
                }
            }, PermissionType.Owner, 1), this);

            manager.AddCommand(new CommandStub("enablemodule", "Disables a module by name", "The module name is case insensitive.", cmdArgs =>
            {
                if (cmdArgs.Args[0].Length > 0)
                {
                    if (manager.ModuleEnabled(cmdArgs.Args[0]))
                    {
                        cmdArgs.Channel.SendMessageAsync("Module already enabled!");
                        return;
                    }
                    try
                    {
                        manager.EnableModule(cmdArgs.Args[0]);
                        cmdArgs.Channel.SendMessageAsync($"Enabled {cmdArgs.Args[0]}.");
                    }
                    catch (Exception ex)
                    { cmdArgs.Channel.SendMessageAsync($"Couldn't enable module! {ex.Message}"); }
                }
                else
                {
                    cmdArgs.Channel.SendMessageAsync("What module?");
                }
            }, PermissionType.Owner, 1), this);

            manager.AddCommand(new CommandStub("modules", "Lists all the modules and whether or not they're enabled.", "", cmdArgs =>
            {
                string msg = $"**Modules**";
                foreach (var kvp in manager.Modules)
                {
                    msg += $"\n`{kvp.Key.Name}` - {(kvp.Value ? "Enabled" : "Disabled")}";
                    if (kvp.Key.ModuleKind == ModuleType.External)
                    {
                        msg += " - From DLL";
                    }
                }
                cmdArgs.Channel.SendMessageAsync(msg);
            }, PermissionType.Owner), this);
            manager.AddCommand(new CommandStub("commands", "Lists all of the available commands", "", cmdArgs =>
            {
                string msg = "**Commands**\n```";
                foreach (var command in manager.Commands)
                {
                    msg += command.Value.CommandName + ", ";
                }
                msg += "\n```";
                cmdArgs.Channel.SendMessageAsync(msg);
            }), this);
            manager.AddCommand(new CommandStub("changeprefix", "Changes the command prefix to a specified character.", "", cmdArgs =>
            {
                if (cmdArgs.Args.Count > 0)
                {
                    string oldPrefix = mainEntry.config.Prefix;
                    try
                    {
                        string newPrefix        = cmdArgs.Args[0];
                        mainEntry.config.Prefix = newPrefix;
                        mainEntry.config.WriteConfig();
                        cmdArgs.Channel.SendMessageAsync($"Command prefix changed to **{mainEntry.config.Prefix}** successfully!");
                    }
                    catch (Exception)
                    {
                        cmdArgs.Channel.SendMessageAsync($"Unable to change prefix to `{cmdArgs.Args[0]}`. Falling back to `{oldPrefix}`.");
                        mainEntry.config.Prefix = oldPrefix;
                    }
                }
                else
                {
                    cmdArgs.Channel.SendMessageAsync("What prefix?");
                }
            }, PermissionType.Owner, 1), this);

            manager.AddCommand(new CommandStub("cmdinfo", "Displays help for a command.", "Help", e =>
            {
                if (!String.IsNullOrEmpty(e.Args[0]))
                {
                    ICommand stub = manager.Commands.FirstOrDefault(x => x.Key == e.Args[0]).Value;

                    if (stub != null)
                    {
                        string msg = "**Help for " + stub.CommandName + "**";
                        msg       += $"\n{stub.Description}";
                        if (!String.IsNullOrEmpty(stub.HelpTag))
                        {
                            msg += $"\n\n{stub.HelpTag}";
                        }
                        if (stub.Parent != null)
                        {
                            msg += $"\nFrom module `{stub.Parent.Name}`";
                        }
                        if (stub.ID != null)
                        {
                            msg += $"\n`{stub.ID}`";
                        }
                        e.Channel.SendMessageAsync(msg);
                    }
                    else
                    {
                        e.Channel.SendMessageAsync("What command?");
                    }
                }
                else
                {
                    e.Channel.SendMessageAsync("What command?");
                }
            }, argCount: 1), this);

            manager.AddCommand(new CommandStub("os", "Displays OS info for the bot.", "OS information", e =>
            {
                e.Channel.SendMessageAsync($"I'm currently being hosted on a system running `{OperatingSystemDetermination.GetUnixName()}`~!");
                if (OperatingSystemDetermination.IsOnMac())
                {
                    Thread.Sleep(1500);
                    e.Channel.SendMessageAsync("My favourite!");
                }
            }), this);

            manager.AddCommand(new CommandStub("moduleinfo", "Shows information about a specific module.", "", cmdArgs =>
            {
                if (cmdArgs.Args.Count > 0 && cmdArgs.Args[0].Length > 0)
                {
                    foreach (var module in manager.Modules.ToList())
                    {
                        if (module.Key.Name.ToLower().Trim() == cmdArgs.Args[0].ToLower().Trim())
                        {
                            string msg = $"**About Module {module.Key.Name}**";

                            msg += $"\n{module.Key.Description}\nEnabled: {module.Value}";
                            msg += $"\nCommands ({module.Key.Commands.Count} Total): ";

                            foreach (var command in module.Key.Commands)
                            {
                                msg += $"{command.CommandName}, ";
                            }

                            cmdArgs.Channel.SendMessageAsync(msg);
                            break;
                        }
                    }
                }
            }, argCount: 1), this);

            manager.AddCommand(new CommandStub("changepic", "Changes the bot's guild pic test.", "Test", async cmdArgs =>
            {
                if (cmdArgs.Client == null)
                {
                    await cmdArgs.Channel.SendMessageAsync("Uh oh, the client argument was null?!?! :(");
                }
                Regex linkParser = new Regex(@"\b(?:https?://|www\.)\S+\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
                if (cmdArgs.Message.Attachments != null && cmdArgs.Message.Attachments.Count > 0)
                {
                    foreach (var emb in cmdArgs.Message.Attachments)
                    {
                        if (emb != null)
                        {
                            using (HttpClient htc = new HttpClient())
                            {
                                Stream imageStream = htc.GetStreamAsync(emb.Url).Result;
                                if (imageStream != null)
                                {
                                    try
                                    {
                                        MemoryStream memStream = new MemoryStream();
                                        imageStream.CopyTo(memStream);

                                        await cmdArgs.Client.EditCurrentUserAsync(avatar: memStream);
                                        await cmdArgs.Channel.SendMessageAsync("Done!");
                                    }
                                    catch (Exception ex)
                                    {
                                        await cmdArgs.Channel.SendMessageAsync("Nope.\n" + ex.Message);
                                    }
                                }
                            }
                            break;
                        }
                    }
                }
                else if (cmdArgs.Args.Count > 0)
                {
                    string rawString = $"{cmdArgs.Args[0]}";
                    if (linkParser.Matches(rawString).Count > 0)
                    {
                        string url = linkParser.Matches(rawString)[0].ToString();
                        using (HttpClient htc = new HttpClient())
                        {
                            Stream imageStream = htc.GetStreamAsync(url).Result;

                            if (imageStream != null)
                            {
                                try
                                {
                                    MemoryStream memStream = new MemoryStream();
                                    imageStream.CopyTo(memStream);

                                    await cmdArgs.Client.EditCurrentUserAsync(avatar: memStream);
                                    await cmdArgs.Channel.SendMessageAsync("Done!");
                                }
                                catch (Exception ex)
                                {
                                    await cmdArgs.Channel.SendMessageAsync("Nope.\n" + ex.Message);
                                }
                            }
                        }
                    }
                }
                else
                {
                    await cmdArgs.Channel.SendMessageAsync("Change to what?");
                }
            }, PermissionType.Owner, 1), this);

            /* TODO
             * manager.AddCommand(new CommandStub("prune",
             *  "Prunes the specified amount of messages.",
             *  "If the bot has the role `ManagerMessages`, he will prune other messages in chat.",
             *  PermissionType.Owner, 1,
             * cmdArgs =>
             * {
             *  int messageCount = 0;
             *  if (int.TryParse(cmdArgs.Args[0], out messageCount))
             *  {
             *      var messagesToPrune = manager.Client.GetMessageHistory(cmdArgs.Channel, messageCount);
             *      DiscordMember selfInServer = cmdArgs.Channel.Parent.GetMemberByKey(manager.Client.Me.ID);
             *      bool pruneAll = false;
             *      if (selfInServer != null)
             *      {
             *          foreach (var roll in selfInServer.Roles)
             *          {
             *              if (roll.Permissions.HasPermission(DiscordSpecialPermissions.ManageMessages))
             *              {
             *                  pruneAll = true;
             *                  break;
             *              }
             *          }
             *          foreach (var roll in cmdArgs.Channel.PermissionOverrides)
             *          {
             *              if (roll.id == manager.Client.Me.ID)
             *              {
             *                  if (roll.AllowedPermission(DiscordSpecialPermissions.ManageMessages))
             *                  {
             *                      pruneAll = true;
             *                      break;
             *                  }
             *              }
             *          }
             *      }
             *      foreach (var msg in messagesToPrune)
             *      {
             *          if (!pruneAll)
             *          {
             *              if (msg.Author.ID == manager.Client.Me.ID)
             *              {
             *                  manager.Client.DeleteMessage(msg);
             *                  Thread.Sleep(100);
             *              }
             *          }
             *          else
             *          {
             *              manager.Client.DeleteMessage(msg);
             *              Thread.Sleep(100);
             *          }
             *      }
             *      cmdArgs.Channel.SendMessage($"Attempted pruning of {messageCount} messages.");
             *  }
             * }));
             */
        }
Example #5
0
        public override void Install(CommandsManager manager)
        {
            manager.AddCommand(new CommandStub("selfdestruct", "Shuts the bot down.", "", PermissionType.Owner, cmdArgs =>
            {
                //mainEntry.Exit();
            }), this);
            manager.AddCommand(new CommandStub("stopintegration", "Stops an integrations.", "", PermissionType.Owner, 1, cmdArgs =>
            {
                if (cmdArgs.Args.Count > 0)
                {
                    if (cmdArgs.FromIntegration.ToLower().Trim() == cmdArgs.Args[0].ToLower().Trim())
                    {
                        manager.Integration.SendMessage("You can't stop the integration you're running me from, silly!", cmdArgs.Channel);
                        return;
                    }
                    mainEntry.StopIntegration(cmdArgs.Args[0]);
                }
                else
                {
                    manager.Integration.SendMessage("Stop what?", cmdArgs.Channel);
                }
            }));
            manager.AddCommand(new CommandStub("startintegration", "Starts an integrations.", "", PermissionType.Owner, 1, cmdArgs =>
            {
                if (cmdArgs.Args.Count > 0)
                {
                    if (cmdArgs.FromIntegration.ToLower().Trim() == cmdArgs.Args[0].ToLower().Trim())
                    {
                        manager.Integration.SendMessage("what kind of paradox are you trying to create", cmdArgs.Channel);
                        return;
                    }
                    mainEntry.StartIntegration(cmdArgs.Args[0]);
                }
                else
                {
                    manager.Integration.SendMessage("Start what?", cmdArgs.Channel);
                }
            }));
            manager.AddCommand(new CommandStub("giveperm", "Gives the perm to the specified user (bot scope)", "", PermissionType.Owner, 2, e =>
            {
                //giveperm Admin <@2309208509852>
                if (e.Args.Count > 1)
                {
                    string permString   = e.Args[0];
                    PermissionType type = PermissionType.User;
                    switch (permString.ToLower())
                    {
                    case "admin":
                        type = PermissionType.Admin;
                        break;

                    case "mod":
                        type = PermissionType.Mod;
                        break;

                    case "none":
                        type = PermissionType.None;
                        break;

                    case "user":
                        type = PermissionType.User;
                        break;
                    }
                    string id = e.Args[1].Trim(new char[] { '<', '@', '>' });
                    manager.AddPermission(id, type);
                    manager.Integration.SendMessage($"Given permission {type.ToString().Substring(type.ToString().IndexOf('.') + 1)} to <@{id}>!", e.Channel);
                }
            }), this);

            manager.AddCommand(new CommandStub("disablemodule", "Disables a module by name", "The module name is case insensitive.", PermissionType.Owner, 1, cmdArgs =>
            {
                if (cmdArgs.Args[0].Length > 0)
                {
                    if (!manager.ModuleEnabled(cmdArgs.Args[0]))
                    {
                        manager.Integration.SendMessage("Module already disabled!", cmdArgs.Channel);
                        return;
                    }
                    try
                    {
                        manager.DisableModule(cmdArgs.Args[0]);
                        manager.Integration.SendMessage($"Disabled {cmdArgs.Args[0]}.", cmdArgs.Channel);
                    }
                    catch (Exception ex)
                    { manager.Integration.SendMessage($"Couldn't disable module! {ex.Message}", cmdArgs.Channel); }
                }
                else
                {
                    manager.Integration.SendMessage("What module?", cmdArgs.Channel);
                }
            }), this);

            manager.AddCommand(new CommandStub("enablemodule", "Disables a module by name", "The module name is case insensitive.", PermissionType.Owner, 1, cmdArgs =>
            {
                if (cmdArgs.Args[0].Length > 0)
                {
                    if (manager.ModuleEnabled(cmdArgs.Args[0]))
                    {
                        manager.Integration.SendMessage("Module already enabled!", cmdArgs.Channel);
                        return;
                    }
                    try
                    {
                        manager.EnableModule(cmdArgs.Args[0]);
                        manager.Integration.SendMessage($"Enabled {cmdArgs.Args[0]}.", cmdArgs.Channel);
                    }
                    catch (Exception ex)
                    { manager.Integration.SendMessage($"Couldn't enable module! {ex.Message}", cmdArgs.Channel); }
                }
                else
                {
                    manager.Integration.SendMessage("What module?", cmdArgs.Channel);
                }
            }), this);

            manager.AddCommand(new CommandStub("modules", "Lists all the modules and whether or not they're enabled.", "",
                                               PermissionType.Owner, cmdArgs =>
            {
                string msg = $"**Modules**";
                foreach (var kvp in manager.Modules)
                {
                    msg += $"\n`{kvp.Key.Name}` - {kvp.Value.ToString()}";
                }
                manager.Integration.SendMessage(msg, cmdArgs.Channel);
            }));

            manager.AddCommand(new CommandStub("changeprefix", "Changes the command prefix to a specified character.", "", PermissionType.Owner, 1, cmdArgs =>
            {
                //if (cmdArgs.Args.Count > 0)
                //{
                //    char oldPrefix = mainEntry.config.CommandPrefix;
                //    try
                //    {
                //        char newPrefix = cmdArgs.Args[0][0];
                //        mainEntry.config.CommandPrefix = newPrefix;
                //        manager.Client.SendMessage($"Command prefix changed to **{mainEntry.config.CommandPrefix}** successfully!");
                //    }
                //    catch (Exception)
                //    {
                //        manager.Client.SendMessage($"Unable to change prefix to `{cmdArgs.Args[0][0]}`. Falling back to `{oldPrefix}`.");
                //        mainEntry.config.CommandPrefix = oldPrefix;
                //    }
                //}
                //else
                //    manager.Client.SendMessage("What prefix?");
            }));

            manager.AddCommand(new CommandStub("flush", "Flushes various internal DiscordSharp caches.", "Flushes either `offline` or `messages`. \n  `offline` as parameter will flush offline users from the current server.\n  `messages` will flush the internal message log.", PermissionType.Owner, 1, cmdArgs =>
            {
                if (cmdArgs.FromIntegration.ToLower().Trim() == "discord")
                {
                    manager.Integration.SendMessage($"Coming soon!", cmdArgs.Channel);
                    //if (cmdArgs.Args.Count > 0)
                    //{
                    //    if (cmdArgs.Args[0].ToLower().Trim() == "offline")
                    //    {
                    //        int flushedCount = manager.Client.ClearOfflineUsersFromServer(cmdArgs.Channel.Parent);
                    //        cmdArgs.Channel.SendMessage($"Flushed {flushedCount} offliners from {cmdArgs.Channel.Parent.Name}.");
                    //    }
                    //    else if (cmdArgs.Args[0].ToLower().Trim() == "messages")
                    //    {
                    //        int flushedCount = manager.Client.ClearInternalMessageLog();
                    //        cmdArgs.Channel.SendMessage($"Flushed {flushedCount} messages from the internal message log.");
                    //    }
                    //}
                    //else
                    //{
                    //    cmdArgs.Channel.SendMessage("Flush what? The toilet?");
                    //}
                }
            }), this);

            manager.AddCommand(new CommandStub("about", "Shows bot information", "", cmdArgs =>
            {
                string message = manager.Integration.BoldText("About Luigibot");
                message       += $"\nOwner: Mike Santiago\n";
                message       += $"Libraries: DiscordSharp {typeof(DiscordSharp.DiscordClient).Assembly.GetName().Version.ToString()}\n";
                message       += $"     SlackAPI w/ WebSocketSharp {typeof(SlackAPI.SlackClient).Assembly.GetName().Version.ToString()}\n";
                var uptime     = (DateTime.Now - InitializeTime);
                message       += $"Uptime: {uptime.Days} days, {uptime.Hours} hours, {uptime.Minutes} minutes\n";
                message       += $"Runtime: ";
                if (Type.GetType("Mono.Runtime") != null)
                {
                    message += "Mono\n";
                }
                else
                {
                    message += ".Net\n";
                }

                message += $"OS: {OperatingSystemDetermination.GetUnixName()}\n";
                message += $"Current Integration: {manager.Integration.IntegrationName} ({manager.Integration.IntegrationDescription})\n";

                message += "Commands: " + manager.Commands.Count + "\n";

                manager.Integration.SendMessage(message, cmdArgs.Channel);
            }));
        }
        public override void Install(CommandsManager manager)
        {
            manager.AddCommand(new CommandStub("selfdestruct", "Shuts the bot down.", "", PermissionType.Owner, cmdArgs =>
            {
                mainEntry.Exit();
            }), this);
            manager.AddCommand(new CommandStub("giveperm", "Gives the perm to the specified user (bot scope)", "", PermissionType.Owner, 2, e =>
            {
                //giveperm Admin <@2309208509852>
                if (e.Args.Count > 1)
                {
                    string permString   = e.Args[0];
                    PermissionType type = PermissionType.User;
                    switch (permString.ToLower())
                    {
                    case "admin":
                        type = PermissionType.Admin;
                        break;

                    case "mod":
                        type = PermissionType.Mod;
                        break;

                    case "none":
                        type = PermissionType.None;
                        break;

                    case "user":
                        type = PermissionType.User;
                        break;
                    }
                    string id = e.Args[1].Trim(new char[] { '<', '@', '>' });
                    manager.AddPermission(id, type);
                    e.Channel.SendMessage($"Given permission {type.ToString().Substring(type.ToString().IndexOf('.') + 1)} to <@{id}>!");
                }
            }), this);

            manager.AddCommand(new CommandStub("disablemodule", "Disables a module by name", "The module name is case insensitive.", PermissionType.Owner, 1, cmdArgs =>
            {
                if (cmdArgs.Args[0].Length > 0)
                {
                    if (!manager.ModuleEnabled(cmdArgs.Args[0]))
                    {
                        cmdArgs.Channel.SendMessage("Module already disabled!");
                        return;
                    }
                    try
                    {
                        manager.DisableModule(cmdArgs.Args[0]);
                        cmdArgs.Channel.SendMessage($"Disabled {cmdArgs.Args[0]}.");
                    }
                    catch (Exception ex)
                    { cmdArgs.Channel.SendMessage($"Couldn't disable module! {ex.Message}"); }
                }
                else
                {
                    cmdArgs.Channel.SendMessage("What module?");
                }
            }), this);

            manager.AddCommand(new CommandStub("enablemodule", "Disables a module by name", "The module name is case insensitive.", PermissionType.Owner, 1, cmdArgs =>
            {
                if (cmdArgs.Args[0].Length > 0)
                {
                    if (manager.ModuleEnabled(cmdArgs.Args[0]))
                    {
                        cmdArgs.Channel.SendMessage("Module already enabled!");
                        return;
                    }
                    try
                    {
                        manager.EnableModule(cmdArgs.Args[0]);
                        cmdArgs.Channel.SendMessage($"Enabled {cmdArgs.Args[0]}.");
                    }
                    catch (Exception ex)
                    { cmdArgs.Channel.SendMessage($"Couldn't enable module! {ex.Message}"); }
                }
                else
                {
                    cmdArgs.Channel.SendMessage("What module?");
                }
            }), this);

            manager.AddCommand(new CommandStub("modules", "Lists all the modules and whether or not they're enabled.", "",
                                               PermissionType.Owner, cmdArgs =>
            {
                string msg = $"**Modules**";
                foreach (var kvp in manager.Modules)
                {
                    msg += $"\n`{kvp.Key.Name}` - {kvp.Value.ToString()}";
                }
                cmdArgs.Channel.SendMessage(msg);
            }));

            manager.AddCommand(new CommandStub("changeprefix", "Changes the command prefix to a specified character.", "", PermissionType.Owner, 1, cmdArgs =>
            {
                if (cmdArgs.Args.Count > 0)
                {
                    char oldPrefix = mainEntry.config.CommandPrefix;
                    try
                    {
                        char newPrefix = cmdArgs.Args[0][0];
                        mainEntry.config.CommandPrefix = newPrefix;
                        cmdArgs.Channel.SendMessage($"Command prefix changed to **{mainEntry.config.CommandPrefix}** successfully!");
                    }
                    catch (Exception)
                    {
                        cmdArgs.Channel.SendMessage($"Unable to change prefix to `{cmdArgs.Args[0][0]}`. Falling back to `{oldPrefix}`.");
                        mainEntry.config.CommandPrefix = oldPrefix;
                    }
                }
                else
                {
                    cmdArgs.Channel.SendMessage("What prefix?");
                }
            }));

            manager.AddCommand(new CommandStub("prune",
                                               "Prunes the specified amount of messages.",
                                               "If the bot has the role `ManagerMessages`, he will prune other messages in chat.",
                                               PermissionType.Owner, 1,
                                               cmdArgs =>
            {
                int messageCount = 0;
                if (int.TryParse(cmdArgs.Args[0], out messageCount))
                {
                    var messagesToPrune        = manager.Client.GetMessageHistory(cmdArgs.Channel, messageCount);
                    DiscordMember selfInServer = cmdArgs.Channel.Parent.GetMemberByKey(manager.Client.Me.ID);
                    bool pruneAll = false;
                    if (selfInServer != null)
                    {
                        foreach (var roll in selfInServer.Roles)
                        {
                            if (roll.Permissions.HasPermission(DiscordSpecialPermissions.ManageMessages))
                            {
                                pruneAll = true;
                                break;
                            }
                        }
                        foreach (var roll in cmdArgs.Channel.PermissionOverrides)
                        {
                            if (roll.id == manager.Client.Me.ID)
                            {
                                if (roll.AllowedPermission(DiscordSpecialPermissions.ManageMessages))
                                {
                                    pruneAll = true;
                                    break;
                                }
                            }
                        }
                    }
                    foreach (var msg in messagesToPrune)
                    {
                        if (!pruneAll)
                        {
                            if (msg.Author.ID == manager.Client.Me.ID)
                            {
                                manager.Client.DeleteMessage(msg);
                                Thread.Sleep(100);
                            }
                        }
                        else
                        {
                            manager.Client.DeleteMessage(msg);
                            Thread.Sleep(100);
                        }
                    }
                    cmdArgs.Channel.SendMessage($"Attempted pruning of {messageCount} messages.");
                }
            }));

            manager.AddCommand(new CommandStub("flush", "Flushes various internal DiscordSharp caches.", "Flushes either `offline` or `messages`. \n  `offline` as parameter will flush offline users from the current server.\n  `messages` will flush the internal message log.", PermissionType.Owner, 1, cmdArgs =>
            {
                if (cmdArgs.Args.Count > 0)
                {
                    if (cmdArgs.Args[0].ToLower().Trim() == "offline")
                    {
                        int flushedCount = manager.Client.ClearOfflineUsersFromServer(cmdArgs.Channel.Parent);
                        cmdArgs.Channel.SendMessage($"Flushed {flushedCount} offliners from {cmdArgs.Channel.Parent.Name}.");
                    }
                    else if (cmdArgs.Args[0].ToLower().Trim() == "messages")
                    {
                        int flushedCount = manager.Client.ClearInternalMessageLog();
                        cmdArgs.Channel.SendMessage($"Flushed {flushedCount} messages from the internal message log.");
                    }
                }
                else
                {
                    cmdArgs.Channel.SendMessage("Flush what? The toilet?");
                }
            }), this);
        }
Example #7
0
        private Task SetupEvents(CancellationToken token)
        {
            Console.ForegroundColor = ConsoleColor.White;
            return(Task.Run(() =>
            {
                client.MessageReceived += (sender, e) =>
                {
                    Console.WriteLine($"[-- Message from {e.author.Username} in #{e.Channel.Name} on {e.Channel.parent.name}: {e.message.content}");

                    if (doingInitialRun)
                    {
                        if (e.message.content.StartsWith("?authenticate"))
                        {
                            string[] split = e.message.content.Split(new char[] { ' ' }, 2);
                            if (split.Length > 1)
                            {
                                if (codeToEnter.Trim() == split[1].Trim())
                                {
                                    config.OwnerID = e.author.ID;
                                    doingInitialRun = false;
                                    e.Channel.SendMessage("Authentication successful! **You are now my owner, " + e.author.Username + ".**");
                                    CommandsManager.AddPermission(e.author, PermissionType.Owner);
                                    owner = e.author;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (e.message.content.Length > 0 && (e.message.content[0] == config.CommandPrefix))
                        {
                            string rawCommand = e.message.content.Substring(1);
                            try
                            {
                                CommandsManager.ExecuteCommand(rawCommand, e.Channel, e.author);
                            }
                            catch (UnauthorizedAccessException ex)
                            {
                                e.Channel.SendMessage(ex.Message);
                            }
                            catch (Exception ex)
                            {
                                e.Channel.SendMessage("Exception occurred while running command:\n```" + ex.Message + "\n```");
                            }
                        }
                    }
                };
                client.VoiceClientDebugMessageReceived += (sender, e) =>
                {
                    if (e.message.Level != MessageLevel.Unecessary)
                    {
                        Console.WriteLine($"[{e.message.Level} {e.message.TimeStamp.ToString()}] {e.message.Message}");
                    }
                };
                client.VoiceClientConnected += (sender, e) =>
                {
                    owner.SlideIntoDMs($"Voice connection complete.");
                    //player = new AudioPlayer(client.GetVoiceClient().VoiceConfig);
                    //bufferedWaveProvider = new BufferedWaveProvider(waveFormat);
                    //bufferedWaveProvider.BufferDuration = new TimeSpan(0, 0, 50);
                    //volumeProvider = new VolumeWaveProvider16(bufferedWaveProvider);
                    //volumeProvider.Volume = 1.1f;
                    //outputDevice.Init(volumeProvider);

                    //stutterReducingTimer = new System.Timers.Timer(500);
                    //stutterReducingTimer.Elapsed += StutterReducingTimer_Elapsed;
                    //PlayAudioAsync(cancelToken);
                };
                client.AudioPacketReceived += (sender, e) =>
                {
                    if (bufferedWaveProvider != null)
                    {
                        byte[] potential = new byte[4000];
                        int decodedFrames = client.GetVoiceClient().Decoder.DecodeFrame(e.OpusAudio, 0, e.OpusAudioLength, potential);
                        bufferedWaveProvider.AddSamples(potential, 0, decodedFrames);
                    }
                };
                client.GuildCreated += (sender, e) =>
                {
                    owner.SlideIntoDMs($"Joined server {e.server.name} ({e.server.id})");
                };
                client.SocketClosed += (sender, e) =>
                {
                    if (e.Code != 1000 && !e.WasClean)
                    {
                        WriteError($"Socket Closed! Code: {e.Code}. Reason: {e.Reason}. Clear: {e.WasClean}.");
                        Console.WriteLine("Waiting 6 seconds to reconnect..");
                        Thread.Sleep(6 * 1000);
                        client.Connect();
                    }
                    else
                    {
                        Console.WriteLine($"Shutting down ({e.Code}, {e.Reason}, {e.WasClean})");
                    }
                };
                client.TextClientDebugMessageReceived += (sender, e) =>
                {
                    if (e.message.Level == MessageLevel.Error || e.message.Level == MessageLevel.Critical)
                    {
                        WriteError($"(Logger Error) {e.message.Message}");
                        try
                        {
                            owner.SlideIntoDMs($"Bot error ocurred: ({e.message.Level.ToString()})```\n{e.message.Message}\n```");
                        }
                        catch { }
                    }
                    if (e.message.Level == MessageLevel.Warning)
                    {
                        WriteWarning($"(Logger Warning) {e.message.Message}");
                    }
                };
                client.Connected += (sender, e) =>
                {
                    Console.WriteLine("Connected as " + e.user.Username);
                    loginDate = DateTime.Now;

                    if (!String.IsNullOrEmpty(config.OwnerID))
                    {
                        owner = client.GetServersList().Find(x => x.members.Find(y => y.ID == config.OwnerID) != null).members.Find(x => x.ID == config.OwnerID);
                    }
                    else
                    {
                        doingInitialRun = true;
                        RandomCodeGenerator rcg = new RandomCodeGenerator();
                        codeToEnter = rcg.GenerateRandomCode();

                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.WriteLine("Important: ");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine("\tPlease authenticate yourself as owner by typing the following into any Discord server you and the bot are in: ");
                        Console.WriteLine($"\t{config.CommandPrefix}authenticate " + codeToEnter);
                    }
                    CommandsManager = new CommandsManager(client);
                    if (File.Exists("permissions.json"))
                    {
                        var permissionsDictionary = JsonConvert.DeserializeObject <Dictionary <string, PermissionType> >(File.ReadAllText("permissions.json"));
                        CommandsManager.OverridePermissionsDictionary(permissionsDictionary);
                    }
                    SetupCommands();
                };
                if (client.SendLoginRequest() != null)
                {
                    client.Connect();
                }
            }, token));
        }
Example #8
0
 private void SetUpEvents()
 {
     this._client.Connected += (sender, e) =>
     {
         Console.Title = $"KWRBot - Discord - logged in as {e.User.Username}";
         Console.WriteLine($"Connected! Username: {e.User.Username}");
     };
     this._client.MessageReceived += (sender, e) =>
     {
         if (owner == null)
         {
             owner = this._client.GetServerChannelIsIn(e.Channel).GetMemberByKey(this._config.OwnerID);
         }
         if (e.Author != owner && e.Author.Username != this._client.ClientPrivateInformation.Username)
         {
             Console.WriteLine($"Messag received from {e.Author.Username}: \"{e.MessageText}\"");
         }
         if (e.Message.Content.Length > 0 && e.Message.Content[0] == this._config.CommandPrefix && e.Author.ID != this._config.BotID)
         {
             string rawCommand = e.Message.Content.Substring(1);
             try
             {
                 CommandsManager.ExecuteOnMessageCommand(rawCommand, e.Channel, e.Author);
             }
             catch (UnauthorizedAccessException)
             {
                 this._client.SendMessageToChannel("You don't have permission to execute this command. Contact administrator for additional information", e.Channel);
                 Console.WriteLine($"{e.Author.Username} attempted to execute command with low access level");
             }
         }
     };
     this._client.PrivateMessageReceived += (sender, e) =>
     {
         if (e.Author.ID != this._config.OwnerID)
         {
             Console.WriteLine($"Private message received from {e.Author.Username}: \"{e.Message}\"");
         }
         if (e.Message.Length > 0 && e.Message[0] == this._config.CommandPrefix)
         {
             string rawCommand = e.Message.Substring(1);
             if (e.Author.ID == this._config.OwnerID)
             {
                 this._client.AcceptInvite(rawCommand.Substring(rawCommand.LastIndexOf('/') + 1));
             }
         }
         if (e.Message.StartsWith("?authenticate") && owner == null)
         {
             Console.BackgroundColor = ConsoleColor.Red;
             Console.Write("Kerrang!\nIn order to become an owner type in bot's password: "******"I'm welcoming you, my current owner {e.Author.Username}");
             }
             Console.BackgroundColor = ConsoleColor.Black;
             owner.SlideIntoDMs("Welcome long lost father!");
             File.WriteAllText(Path.GetFullPath("settings.json"), JsonConvert.SerializeObject(this._config));
         }
     };
     this._client.GuildCreated += (sender, e) =>
     {
         Console.WriteLine($"Joined server: {e.Server.Name} ({e.Server.ID})");
     };
 }