Esempio n. 1
0
        private void SetupCommands()
        {
            #region Owner only
            CommandsManager.AddCommand(new CommandStub("selfdestruct", "Shuts the bot down.", "", PermissionType.Owner, cmdArgs =>
            {
                Exit();
            }));
            CommandsManager.AddCommand(new CommandStub("setplaying", "Sets the current game the bot is playing.", "", PermissionType.Owner, 1, cmdArgs =>
            {
                client.UpdateCurrentGame(cmdArgs.Args[0]);
            }));
            CommandsManager.AddCommand(new CommandStub("join", "Joins a specified server", "", PermissionType.Owner, 1, cmdArgs =>
            {
                string substring = cmdArgs.Args[0].Substring(cmdArgs.Args[0].LastIndexOf('/') + 1);
                client.AcceptInvite(substring);
            }));
            CommandsManager.AddCommand(new CommandStub("changeprefix", "Changes the command prefix to a specified character.", "", PermissionType.Owner, 1, cmdArgs =>
            {
                if (cmdArgs.Args.Count > 0)
                {
                    char newPrefix       = cmdArgs.Args[0][0];
                    config.CommandPrefix = newPrefix;
                    cmdArgs.Channel.SendMessage($"Command prefix changed to **{config.CommandPrefix}** successfully!");
                }
                else
                {
                    cmdArgs.Channel.SendMessage("What prefix?");
                }
            }));
            CommandsManager.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[] { '<', '@', '>' });
                    CommandsManager.AddPermission(id, type);
                    e.Channel.SendMessage($"Given permission {type.ToString().Substring(type.ToString().IndexOf('.') + 1)} to <@{id}>!");
                }
            }));
            #endregion
            #region Admin
            CommandsManager.AddCommand(new CommandStub("eval", "Evaluates real-time C# code. Be careful with this",
                                                       "Evaluates C# code that is dynamically compiled.\n\nThe following namespaces are available for use:\n * DiscordSharp\n * System.Threading\n * DiscordSharp.Objects\n\n\nMake sure your function returns a string value.\nYou can reference the DiscordSharp client by using `discordClient`.", PermissionType.Admin, 1, e =>
            {
                string whatToEval = e.Args[0];
                if (whatToEval.StartsWith("`") && whatToEval.EndsWith("`"))
                {
                    whatToEval = whatToEval.Trim('`');
                }
                try
                {
                    var eval   = EvalProvider.CreateEvalMethod <DiscordClient, string>(whatToEval, new string[] { "DiscordSharp", "System.Threading", "DiscordSharp.Objects" }, new string[] { "DiscordSharp.dll" });
                    string res = "";
                    Thread.Sleep(1000);
                    Thread executionThread = null;
                    Task evalTask          = new Task(() =>
                    {
                        executionThread = Thread.CurrentThread;
                        if (eval != null)
                        {
                            res = eval(client);
                        }
                        else
                        {
                            string errors = "Errors While Compiling: \n";
                            if (EvalProvider.errors != null)
                            {
                                if (EvalProvider.errors.Count > 0)
                                {
                                    foreach (var error in EvalProvider.errors)
                                    {
                                        errors += $"{error.ToString()}\n\n";
                                    }
                                }
                                e.Channel.SendMessage($"```\n{errors}\n```");
                            }
                            else
                            {
                                e.Channel.SendMessage("Errors!");
                            }
                        }
                    });
                    evalTask.Start();
                    evalTask.Wait(10 * 1000);
                    if (executionThread != null)
                    {
                        executionThread.Abort();
                    }
                    if (res == null || res == "")
                    {
                        e.Channel.SendMessage("Terminated after 10 second timeout.");
                    }
                    else
                    {
                        e.Channel.SendMessage($"**Result**\n```\n{res}\n```");
                    }
                }
                catch (Exception ex)
                {
                    string errors = "Errors While Compiling: \n";
                    if (EvalProvider.errors != null)
                    {
                        if (EvalProvider.errors.Count > 0)
                        {
                            foreach (var error in EvalProvider.errors)
                            {
                                errors += $"{error.ToString()}\n\n";
                            }
                        }
                        else
                        {
                            errors += ex.Message;
                        }
                        e.Channel.SendMessage($"```\n{errors}\n```");
                    }
                    else
                    {
                        e.Channel.SendMessage("Errors!");
                    }
                }
            }));
            #endregion
            #region Anyone, but limited to server mods
            CommandsManager.AddCommand(new CommandStub("gtfo", "Makes the bot leave the server", "", PermissionType.User, cmdArgs =>
            {
                bool canExecute = false;
                foreach (var roll in cmdArgs.Author.Roles)
                {
                    if (roll.permissions.HasPermission(DiscordSpecialPermissions.ManageServer))
                    {
                        canExecute = true;
                    }
                }
                if (canExecute)
                {
                    client.LeaveServer(cmdArgs.Channel.parent);
                }
                else
                {
                    cmdArgs.Channel.SendMessage("You don't have the proper permissions to do this! You need the ManagerServer permission.");
                }
            }));
            #endregion
            #region Literally anyone
            CommandsManager.AddCommand(new CommandStub("cmdinfo", "Displays help for a command.", "Help", PermissionType.User, 2, e =>
            {
                if (!String.IsNullOrEmpty(e.Args[0]))
                {
                    ICommand stub = CommandsManager.Commands.Find(x => x.CommandName == e.Args[0]);
                    if (stub != null)
                    {
                        string msg = "**Help for " + stub.CommandName + "**";
                        msg       += $"\n{stub.Description}";
                        if (!String.IsNullOrEmpty(stub.HelpTag))
                        {
                            msg += $"\n\n{stub.HelpTag}";
                        }
                        e.Channel.SendMessage(msg);
                    }
                    else
                    {
                        e.Channel.SendMessage("What command?");
                    }
                }
                else
                {
                    e.Channel.SendMessage("What command?");
                }
            }));
            CommandsManager.AddCommand(new CommandStub("about", "Shows bot information", "", cmdArgs =>
            {
                string message = "**About Luigibot**\n";
                message       += "Owner: " + owner.Username + "\n";
                message       += "Library: DiscordSharp\n";
                message       += "Uptime: " + (DateTime.Now - loginDate).ToString() + "\n";
                message       += "Compiled Under: ";
                if (Mono())
                {
                    message += "Mono\n";
                }
                else
                {
                    message += ".Net\n";
                }
                long memUsage = GetMemoryUsage();
                if (memUsage > 0)
                {
                    message += "Memory Usage: " + (memUsage / 1024) / 2 + "mb\n";
                }
                message += "Commands: " + CommandsManager.Commands.Count + "\n";
                message += "Command Prefix: " + config.CommandPrefix + "\n";
                message += "Total Servers: " + client.GetServersList().Count + "\n";
                cmdArgs.Channel.SendMessage(message);
            }));
            #endregion
        }
Esempio n. 2
0
        public override void Install(CommandsManager manager)
        {
            manager.AddCommand(new CommandStub("eval", "Evaluates real-time C# code. Be careful with this",
                                               "Evaluates C# code that is dynamically compiled.\n\nThe following namespaces are available for use:\n * DiscordSharp\n * System.Threading\n * DiscordSharp.Objects\n\n\nMake sure your function returns a string value.\nYou can reference the DiscordSharp client by using `discordClient`.", PermissionType.User, 1, e =>
            {
                bool canExec = false;
                if (manager.HasPermission(e.Author, PermissionType.Admin))
                {
                    canExec = true;
                }
                if (!canExec)
                {
                    e.Channel.SendMessage("kek");
                    return;
                }

                string whatToEval = e.Args[0];
                if (whatToEval.StartsWith("`") && whatToEval.EndsWith("`"))
                {
                    whatToEval = whatToEval.Trim('`');
                }
                try
                {
                    var eval   = EvalProvider.CreateEvalMethod <DiscordClient, string>(whatToEval, EvalNamespaces, new string[] { "DiscordSharp.dll", "System.Data.Linq.dll" });
                    string res = "";
                    Thread.Sleep(1000);
                    Thread executionThread = null;
                    Task evalTask          = new Task(() =>
                    {
                        executionThread = Thread.CurrentThread;
                        if (eval != null)
                        {
                            try
                            {
                                res = eval(manager.Client);
                            }
                            catch (Exception ex) { res = "Exception occurred while running: " + ex.Message; }
                        }
                        else
                        {
                            string errors = "Errors While Compiling: \n";
                            if (EvalProvider.errors != null)
                            {
                                if (EvalProvider.errors.Count > 0)
                                {
                                    foreach (var error in EvalProvider.errors)
                                    {
                                        errors += $"{error.ToString()}\n\n";
                                    }
                                }
                                e.Channel.SendMessage($"```\n{errors}\n```");
                            }
                            else
                            {
                                e.Channel.SendMessage("Errors!");
                            }
                        }
                    });
                    evalTask.Start();
                    evalTask.Wait(10 * 1000);
                    if (!runningOnMono)     //causes exceptions apparently >.>
                    {
                        if (executionThread != null)
                        {
                            executionThread.Abort();
                        }
                    }
                    if (res == null || res == "")
                    {
                        e.Channel.SendMessage("Terminated after 10 second timeout.");
                    }
                    else
                    {
                        e.Channel.SendMessage($"**Result**\n```\n{res}\n```");
                    }
                }
                catch (Exception ex)
                {
                    string errors = "Errors While Compiling: \n";
                    if (EvalProvider.errors != null)
                    {
                        if (EvalProvider.errors.Count > 0)
                        {
                            foreach (var error in EvalProvider.errors)
                            {
                                errors += $"{error.ToString()}\n\n";
                            }
                        }
                        else
                        {
                            errors += ex.Message;
                        }
                        e.Channel.SendMessage($"```\n{errors}\n```");
                    }
                    else
                    {
                        e.Channel.SendMessage($"Errors! {ex.Message}");
                    }
                }
            }), this);

            manager.AddCommand(new CommandStub("lua", "Evals Lua code.", "WIP.", PermissionType.Admin, 1, cmdArgs =>
            {
                string whatToEval = cmdArgs.Args[0];
                if (whatToEval.StartsWith("`") && whatToEval.EndsWith("`"))
                {
                    whatToEval = whatToEval.Trim('`');
                    if (whatToEval.StartsWith("\n"))
                    {
                        whatToEval = whatToEval.Trim('\n');
                    }
                }

                Lua state = new Lua();

                bool isAdmin = false;
                if (manager.HasPermission(cmdArgs.Author, PermissionType.Admin))
                {
                    state["discordClient"] = manager.Client;
                    state.LoadCLRPackage();
                    string importStatements = "";
                    foreach (var use in EvalNamespaces)
                    {
                        importStatements += $"import('{use}')\n";
                    }
                    state.DoString(importStatements);
                    isAdmin = true;
                }
                else
                {
                    //state.DoString("import = function () end");
                }
                state.DoString(CustomLuaFunctions);

                string prefix        = isAdmin ? $"{whatToEval}" : $"return run({whatToEval});";
                var res              = state.DoString(prefix);
                string resultMessage = $"**Result: {res.Length}**\n```";
                foreach (var obj in res)
                {
                    resultMessage += $"\n{obj.ToString()}";
                }
                resultMessage += "\n```";

                if (res != null)
                {
                    cmdArgs.Channel.SendMessage($"{resultMessage}");
                }
                else
                {
                    cmdArgs.Channel.SendMessage($"No result given.");
                }
            }), this);
        }
Esempio n. 3
0
        public override void Install(CommandsManager manager)
        {
            manager.AddCommand(new CommandStub("yt", "Streams a YouTube Video. Lewd.", "", PermissionType.Owner, 1, cmdArgs =>
            {
                if (cmdArgs.Args[0].Length > 0)
                {
                    string url  = cmdArgs.Args[0];
                    var youtube = YouTube.Default;
                    var video   = youtube.GetVideo(url);
                    if (video.AudioFormat == AudioFormat.Mp3 || video.AudioFormat == AudioFormat.Vorbis)
                    {
                        SendVoice("", manager.Client, video);
                    }
                    else
                    {
                        cmdArgs.Channel.SendMessage($"Tell Axiom not to get lazy and support other audio codecs besides MP3! (This was in {video.AudioFormat})");
                    }
                }
                else
                {
                    cmdArgs.Channel.SendMessage($"wrong");
                }
            }), this);
            manager.AddCommand(new CommandStub("disconnect", "Disconnects from voice", "", PermissionType.Owner, 1, cmdArgs =>
            {
                manager.Client.DisconnectFromVoice();
            }), this);
            manager.AddCommand(new CommandStub("testvoice", "Broadcasts specified file over voice.", "", PermissionType.Owner, 1, cmdArgs =>
            {
                if (File.Exists(cmdArgs.Args[0]))
                {
                    if (manager.Client.ConnectedToVoice())
                    {
                        SendVoice(cmdArgs.Args[0], manager.Client);
                    }
                    else
                    {
                        cmdArgs.Channel.SendMessage("Not connected to voice!");
                    }
                }
                else
                {
                    cmdArgs.Channel.SendMessage("Couldn't broadcast specified file! It doesn't exist!");
                }
            }), this);
            manager.AddCommand(new CommandStub("joinvoice", "Joins a specified voice channel", "Arg is case insensitive voice channel name to join.", PermissionType.Owner, 1, cmdArgs =>
            {
                DiscordChannel channelToJoin = cmdArgs.Channel.Parent.Channels.Find(x => x.Name.ToLower() == cmdArgs.Args[0].ToLower() && x.Type == ChannelType.Voice);
                if (channelToJoin != null)
                {
                    DiscordVoiceConfig config = new DiscordVoiceConfig
                    {
                        FrameLengthMs = 60,
                        Channels      = 1,
                        OpusMode      = DiscordSharp.Voice.OpusApplication.MusicOrMixed,
                        SendOnly      = true
                    };

                    //waveFormat = new WaveFormat(48000, 16, config.Channels);

                    //if (!config.SendOnly)
                    //{
                    //    waveCallbackInfo = WaveCallbackInfo.FunctionCallback();
                    //    outputDevice = new WaveOut();
                    //}

                    manager.Client.ConnectToVoiceChannel(channelToJoin, config);
                }
                else
                {
                    cmdArgs.Channel.SendMessage("Couldn't find the specified channel as a voice channel!");
                }
            }), this);
            manager.AddCommand(new CommandStub("stop", "Stops current voice without disconnecting.", "", PermissionType.Owner, cmdArgs =>
            {
                if (manager.Client.GetVoiceClient() != null)
                {
                    manager.Client.GetVoiceClient().ClearVoiceQueue();
                }
            }), this);
        }
Esempio n. 4
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);
            }));
        }
Esempio n. 5
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.");
             *  }
             * }));
             */
        }
Esempio n. 6
0
        private void SetupCommands()
        {
            #region Old Commands
            CommandsManager.AddCommand(new CommandStub("invite", "Makes an invite to specified server given its ID", "Pass ID douchebag.", PermissionType.Owner, 1, cmdArgs =>
            {
                if (cmdArgs.Args.Count > 0)
                {
                    if (cmdArgs.Args[0].Length > 0)
                    {
                        DiscordServer server   = client.GetServersList().Find(x => x.ID == cmdArgs.Args[0]);
                        DiscordChannel channel = server.Channels.Find(x => x.Name == "general");
                        cmdArgs.Channel.SendMessage(client.CreateInvite(channel));
                    }
                    else
                    {
                        cmdArgs.Channel.SendMessage("kek");
                    }
                }
                else
                {
                    cmdArgs.Channel.SendMessage("kek");
                }
            }));

            CommandsManager.AddCommand(new CommandStub("statusof", "`Status` test", "", PermissionType.Owner, 1, cmdArgs =>
            {
                string id = cmdArgs.Args[0].Trim(new char[] { '<', '@', '>' });
                if (!string.IsNullOrEmpty(id))
                {
                    DiscordMember member = cmdArgs.Channel.Parent.GetMemberByKey(id);
                    if (member != null)
                    {
                        string msg = $"Status of `{member.Username}`\n{member.Status}";
                        if (!string.IsNullOrEmpty(member.CurrentGame))
                        {
                            msg += $"\nPlaying: *{member.CurrentGame}*";
                        }
                        cmdArgs.Channel.SendMessage(msg);
                    }
                }
            }));
            CommandsManager.AddCommand(new CommandStub("changepic", "Changes the bot's guild pic test.", "Test", PermissionType.Owner, 1, cmdArgs =>
            {
                Regex linkParser = new Regex(@"\b(?:https?://|www\.)\S+\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
                string rawString = $"{cmdArgs.Args[0]}";
                if (linkParser.Matches(rawString).Count > 0)
                {
                    string url = linkParser.Matches(rawString)[0].ToString();
                    using (WebClient wc = new WebClient())
                    {
                        byte[] data = wc.DownloadData(url);
                        using (MemoryStream mem = new MemoryStream(data))
                        {
                            using (var image = System.Drawing.Image.FromStream(mem))
                            {
                                client.ChangeClientAvatar(new Bitmap(image));
                            }
                        }
                    }
                }
            }));
            CommandsManager.AddCommand(new CommandStub("serverstats", "Server stats", "help me", PermissionType.Owner, cmdArgs =>
            {
                if (cmdArgs.Channel != null && cmdArgs.Channel.Parent != null)
                {
                    DiscordServer guild = cmdArgs.Channel.Parent;
                    string msg          = $"Stats for **{guild.Name}**\n```\n";
                    msg += $"{guild.Members.Count} members\n";
                    msg += $"{guild.Roles.Count} roles\n";
                    msg += $"Owned by {guild.Owner.Username}#{guild.Owner.Discriminator}\n";
                    msg += $"{guild.Region}\n```";
                    cmdArgs.Channel.SendMessage(msg);
                }
            }));
            CommandsManager.AddCommand(new CommandStub("listroles", "Lists rolls", "help me", PermissionType.Owner, cmdArgs =>
            {
                if (cmdArgs.Channel != null && cmdArgs.Channel.Parent != null)
                {
                    DiscordServer guild = cmdArgs.Channel.Parent;
                    string msg          = $"Roles for **{guild.Name}**, per your request.\n```\n";
                    foreach (var role in guild.Roles)
                    {
                        msg += $"{role.Position} - {role.Name} - {role.ID} - {role.Permissions.GetRawPermissions()}\n";
                    }
                    msg += "\n```";
                    try
                    {
                        owner.SlideIntoDMs(msg);
                    }
                    catch { }
                    cmdArgs.Channel.SendMessage($"DMed to you ;)");
                }
            }));
            CommandsManager.AddCommand(new CommandStub("sendchanneltest", "`Client.SendMessageToChannel` Test", "", PermissionType.Owner, cmdArgs =>
            {
                client.SendMessageToChannel("Works!", cmdArgs.Channel);
            }));
            CommandsManager.AddCommand(new CommandStub("setplaying", "Sets the current game the bot is playing.", "", PermissionType.Owner, 1, cmdArgs =>
            {
                client.UpdateCurrentGame(cmdArgs.Args[0]);
            }));
            CommandsManager.AddCommand(new CommandStub("join", "Joins a specified server", "", PermissionType.Owner, 1, cmdArgs =>
            {
                string substring = cmdArgs.Args[0].Substring(cmdArgs.Args[0].LastIndexOf('/') + 1);
                client.AcceptInvite(substring);
            }));
            CommandsManager.AddCommand(new CommandStub("cmdinfo", "Displays help for a command.", "Help", PermissionType.User, 2, e =>
            {
                if (!String.IsNullOrEmpty(e.Args[0]))
                {
                    ICommand stub = CommandsManager.Commands.Find(x => x.CommandName == e.Args[0]);
                    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.SendMessage(msg);
                    }
                    else
                    {
                        e.Channel.SendMessage("What command?");
                    }
                }
                else
                {
                    e.Channel.SendMessage("What command?");
                }
            }));
            CommandsManager.AddCommand(new CommandStub("about", "Shows bot information", "", cmdArgs =>
            {
                string message = "**About Luigibot**\n";
                message       += $"Owner: {owner.Username}#{owner.Discriminator}\n";
                message       += $"Library: DiscordSharp {typeof(DiscordClient).Assembly.GetName().Version.ToString()}\n";
                message       += $"Gateway Version: {client.DiscordGatewayVersion}\n";
                var uptime     = (DateTime.Now - loginDate);
                message       += $"Uptime: {uptime.Days} days, {uptime.Hours} hours, {uptime.Minutes} minutes.\n";
                message       += "Runtime: ";

                if (runningOnMono)
                {
                    message += "Mono\n";
                }
                else
                {
                    message += ".Net\n";
                }

                message      += $"OS: {osString}\n";
                long memUsage = GetMemoryUsage();
                if (memUsage > 0)
                {
                    message += "Memory Usage: " + (memUsage / 1024) + "mb\n";
                }
                message += "Commands: " + CommandsManager.Commands.Count + "\n";
                message += "Command Prefix: " + config.CommandPrefix + "\n";
                message += "Total Servers: " + client.GetServersList().Count + "\n";
                cmdArgs.Channel.SendMessage(message);
            }));
            CommandsManager.AddCommand(new CommandStub("moduleinfo", "Shows information about a specific module.", "", PermissionType.User, 1, cmdArgs =>
            {
                if (cmdArgs.Args.Count > 0 && cmdArgs.Args[0].Length > 0)
                {
                    foreach (var module in CommandsManager.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.ForEach(x => msg += $"{x.CommandName}, ");

                            cmdArgs.Channel.SendMessage(msg);
                            break;
                        }
                    }
                }
            }));
            #endregion

            var OwnerModules = new BaseOwnerModules(this);
            OwnerModules.Install(CommandsManager);

            var funModule = new NoFunAllowedModule();
            funModule.Install(CommandsManager);

            var serverAdminModules = new ServerAdminModules(this);
            serverAdminModules.Install(CommandsManager);

            var evalModules = new EvalModules();
            evalModules.Install(CommandsManager);

            var yugiohModules = new YugiohModules();
            yugiohModules.Install(CommandsManager);

            var serverLogs = new TestServerLog(client);
            serverLogs.Install(CommandsManager);

            var voice = new Voice(this);
            voice.Install(CommandsManager);

            var holupholup = new Holup();
            holupholup.Install(CommandsManager);

            var testingModule = new TestingModule();
            testingModule.Install(CommandsManager);
        }
        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);
        }
Esempio n. 8
0
        private void SetupCommands()
        {
            #region Owner only
            CommandsManager.AddCommand(new CommandStub("selfdestruct", "Shuts the bot down.", "", PermissionType.Owner, cmdArgs =>
            {
                Exit();
            }));
            CommandsManager.AddCommand(new CommandStub("joinvoice", "Joins a specified voice channel", "Arg is case insensitive voice channel name to join.", PermissionType.Owner, 1, cmdArgs =>
            {
                DiscordChannel channelToJoin = cmdArgs.Channel.parent.channels.Find(x => x.Name.ToLower() == cmdArgs.Args[0].ToLower() && x.Type == ChannelType.Voice);
                if (channelToJoin != null)
                {
                    DiscordVoiceConfig config = new DiscordVoiceConfig
                    {
                        FrameLengthMs = 20,
                        Channels      = 1,
                        OpusMode      = Discord.Audio.Opus.OpusApplication.LowLatency,
                        SendOnly      = true
                    };

                    waveFormat = new WaveFormat(48000, 16, config.Channels);

                    if (!config.SendOnly)
                    {
                        waveCallbackInfo = WaveCallbackInfo.FunctionCallback();
                        outputDevice     = new WaveOut();
                    }

                    client.ConnectToVoiceChannel(channelToJoin, config);
                }
                else
                {
                    cmdArgs.Channel.SendMessage("Couldn't find the specified channel as a voice channel!");
                }
            }));
            CommandsManager.AddCommand(new CommandStub("disconnect", "Disconnects from voice", "", PermissionType.Owner, 1, cmdArgs =>
            {
                client.DisconnectFromVoice();
            }));
            CommandsManager.AddCommand(new CommandStub("testvoice", "Broadcasts specified file over voice.", "", PermissionType.Owner, 1, cmdArgs =>
            {
                if (File.Exists(cmdArgs.Args[0]))
                {
                    if (client.ConnectedToVoice())
                    {
                        SendVoice(cmdArgs.Args[0]);
                    }
                    else
                    {
                        cmdArgs.Channel.SendMessage("Not connected to voice!");
                    }
                }
                else
                {
                    cmdArgs.Channel.SendMessage("Couldn't broadcast specified file! It doesn't exist!");
                }
            }));
            CommandsManager.AddCommand(new CommandStub("statusof", "`Status` test", "", PermissionType.Owner, 1, cmdArgs =>
            {
                string id = cmdArgs.Args[0].Trim(new char[] { '<', '@', '>' });
                if (!string.IsNullOrEmpty(id))
                {
                    DiscordMember member = cmdArgs.Channel.parent.members.Find(x => x.ID == id);
                    if (member != null)
                    {
                        string msg = $"Status of `{member.Username}`\n{member.Status}";
                        if (!string.IsNullOrEmpty(member.CurrentGame))
                        {
                            msg += $"\nPlaying: *{member.CurrentGame}*";
                        }
                        cmdArgs.Channel.SendMessage(msg);
                    }
                }
            }));
            CommandsManager.AddCommand(new CommandStub("changepic", "Changes the bot's guild pic test.", "Test", PermissionType.Owner, 1, cmdArgs =>
            {
                Regex linkParser = new Regex(@"\b(?:https?://|www\.)\S+\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
                string rawString = $"{cmdArgs.Args[0]}";
                if (linkParser.Matches(rawString).Count > 0)
                {
                    string url = linkParser.Matches(rawString)[0].ToString();
                    using (WebClient wc = new WebClient())
                    {
                        byte[] data = wc.DownloadData(url);
                        using (MemoryStream mem = new MemoryStream(data))
                        {
                            using (var image = System.Drawing.Image.FromStream(mem))
                            {
                                client.ChangeClientAvatar(new Bitmap(image));
                            }
                        }
                    }
                }
            }));
            CommandsManager.AddCommand(new CommandStub("sendchanneltest", "`Client.SendMessageToChannel` Test", "", PermissionType.Owner, cmdArgs =>
            {
                client.SendMessageToChannel("Works!", cmdArgs.Channel);
            }));
            CommandsManager.AddCommand(new CommandStub("setplaying", "Sets the current game the bot is playing.", "", PermissionType.Owner, 1, cmdArgs =>
            {
                client.UpdateCurrentGame(cmdArgs.Args[0]);
            }));
            CommandsManager.AddCommand(new CommandStub("join", "Joins a specified server", "", PermissionType.Owner, 1, cmdArgs =>
            {
                string substring = cmdArgs.Args[0].Substring(cmdArgs.Args[0].LastIndexOf('/') + 1);
                client.AcceptInvite(substring);
            }));
            CommandsManager.AddCommand(new CommandStub("changeprefix", "Changes the command prefix to a specified character.", "", PermissionType.Owner, 1, cmdArgs =>
            {
                if (cmdArgs.Args.Count > 0)
                {
                    char newPrefix       = cmdArgs.Args[0][0];
                    config.CommandPrefix = newPrefix;
                    cmdArgs.Channel.SendMessage($"Command prefix changed to **{config.CommandPrefix}** successfully!");
                }
                else
                {
                    cmdArgs.Channel.SendMessage("What prefix?");
                }
            }));
            CommandsManager.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[] { '<', '@', '>' });
                    CommandsManager.AddPermission(id, type);
                    e.Channel.SendMessage($"Given permission {type.ToString().Substring(type.ToString().IndexOf('.') + 1)} to <@{id}>!");
                }
            }));
            CommandsManager.AddCommand(new CommandStub("prune", "Prune test", "", PermissionType.Owner, 1, cmdArgs =>
            {
                int messageCount = 0;
                if (int.TryParse(cmdArgs.Args[0], out messageCount))
                {
                    var messagesToPrune = client.GetMessageHistory(cmdArgs.Channel, messageCount);
                    foreach (var msg in messagesToPrune)
                    {
                        client.DeleteMessage(msg);
                        Thread.Sleep(100);
                    }
                    cmdArgs.Channel.SendMessage($"Attempted pruning of {messageCount} messages.");
                }
            }));
            #endregion
            #region Admin
            CommandsManager.AddCommand(new CommandStub("eval", "Evaluates real-time C# code. Be careful with this",
                                                       "Evaluates C# code that is dynamically compiled.\n\nThe following namespaces are available for use:\n * DiscordSharp\n * System.Threading\n * DiscordSharp.Objects\n\n\nMake sure your function returns a string value.\nYou can reference the DiscordSharp client by using `discordClient`.", PermissionType.Admin, 1, e =>
            {
                string whatToEval = e.Args[0];
                if (whatToEval.StartsWith("`") && whatToEval.EndsWith("`"))
                {
                    whatToEval = whatToEval.Trim('`');
                }
                try
                {
                    var eval   = EvalProvider.CreateEvalMethod <DiscordClient, string>(whatToEval, new string[] { "DiscordSharp", "System.Threading", "DiscordSharp.Objects" }, new string[] { "DiscordSharp.dll" });
                    string res = "";
                    Thread.Sleep(1000);
                    Thread executionThread = null;
                    Task evalTask          = new Task(() =>
                    {
                        executionThread = Thread.CurrentThread;
                        if (eval != null)
                        {
                            res = eval(client);
                        }
                        else
                        {
                            string errors = "Errors While Compiling: \n";
                            if (EvalProvider.errors != null)
                            {
                                if (EvalProvider.errors.Count > 0)
                                {
                                    foreach (var error in EvalProvider.errors)
                                    {
                                        errors += $"{error.ToString()}\n\n";
                                    }
                                }
                                e.Channel.SendMessage($"```\n{errors}\n```");
                            }
                            else
                            {
                                e.Channel.SendMessage("Errors!");
                            }
                        }
                    });
                    evalTask.Start();
                    evalTask.Wait(10 * 1000);
                    if (executionThread != null)
                    {
                        executionThread.Abort();
                    }
                    if (res == null || res == "")
                    {
                        e.Channel.SendMessage("Terminated after 10 second timeout.");
                    }
                    else
                    {
                        e.Channel.SendMessage($"**Result**\n```\n{res}\n```");
                    }
                }
                catch (Exception ex)
                {
                    string errors = "Errors While Compiling: \n";
                    if (EvalProvider.errors != null)
                    {
                        if (EvalProvider.errors.Count > 0)
                        {
                            foreach (var error in EvalProvider.errors)
                            {
                                errors += $"{error.ToString()}\n\n";
                            }
                        }
                        else
                        {
                            errors += ex.Message;
                        }
                        e.Channel.SendMessage($"```\n{errors}\n```");
                    }
                    else
                    {
                        e.Channel.SendMessage("Errors!");
                    }
                }
            }));
            #endregion
            #region Anyone, but limited to server mods
            CommandsManager.AddCommand(new CommandStub("gtfo", "Makes the bot leave the server", "", PermissionType.User, cmdArgs =>
            {
                bool canExecute = false;
                foreach (var roll in cmdArgs.Author.Roles)
                {
                    if (roll.permissions.HasPermission(DiscordSpecialPermissions.ManageServer))
                    {
                        canExecute = true;
                    }
                }
                if (canExecute)
                {
                    client.LeaveServer(cmdArgs.Channel.parent);
                }
                else
                {
                    cmdArgs.Channel.SendMessage("You don't have the proper permissions to do this! You need the ManagerServer permission.");
                }
            }));
            #endregion
            #region Literally anyone
            CommandsManager.AddCommand(new CommandStub("cmdinfo", "Displays help for a command.", "Help", PermissionType.User, 2, e =>
            {
                if (!String.IsNullOrEmpty(e.Args[0]))
                {
                    ICommand stub = CommandsManager.Commands.Find(x => x.CommandName == e.Args[0]);
                    if (stub != null)
                    {
                        string msg = "**Help for " + stub.CommandName + "**";
                        msg       += $"\n{stub.Description}";
                        if (!String.IsNullOrEmpty(stub.HelpTag))
                        {
                            msg += $"\n\n{stub.HelpTag}";
                        }
                        e.Channel.SendMessage(msg);
                    }
                    else
                    {
                        e.Channel.SendMessage("What command?");
                    }
                }
                else
                {
                    e.Channel.SendMessage("What command?");
                }
            }));
            CommandsManager.AddCommand(new CommandStub("about", "Shows bot information", "", cmdArgs =>
            {
                string message = "**About Luigibot**\n";
                message       += "Owner: " + owner.Username + "\n";
                message       += $"Library: DiscordSharp {typeof(DiscordClient).Assembly.GetName().Version.ToString()}\n";
                var uptime     = (DateTime.Now - loginDate);
                message       += $"Uptime: {uptime.Days} days, {uptime.Hours} hours, {uptime.Minutes} minutes.\n";
                message       += "Runtime: ";

                if (runningOnMono)
                {
                    message += "Mono\n";
                }
                else
                {
                    message += ".Net\n";
                }

                message      += $"OS: {osString}\n";
                long memUsage = GetMemoryUsage();
                if (memUsage > 0)
                {
                    message += "Memory Usage: " + (memUsage / 1024) / 2 + "mb\n";
                }
                message += "Commands: " + CommandsManager.Commands.Count + "\n";
                message += "Command Prefix: " + config.CommandPrefix + "\n";
                message += "Total Servers: " + client.GetServersList().Count + "\n";
                cmdArgs.Channel.SendMessage(message);
            }));
            CommandsManager.AddCommand(new CommandStub("ygo", "Retrieves information for a Yu-Gi-Oh card from the YugiohPrices database.",
                                                       "Card names are (unfortunately) case sensitive.\n\n**Valid:** Dark Magician\n**Invalid: **dark magician", PermissionType.User, 1, cmdArgs =>
            {
                if (cmdArgs.Args.Count > 0)
                {
                    YugiohPricesSearcher searcher = new YugiohPricesSearcher();
                    try
                    {
                        var card = searcher.GetCardByName(cmdArgs.Args[0]).Result;
                        if (card.Name != "<NULL CARD>")
                        {
                            card.CardImage.Save("ygotemp.png");
                            string message = $"**{card.Name}**";
                            if (card.Type == CardType.Monster)
                            {
                                message += $" Level: {card.Level} Attribute: {card.Attribute}\n";
                            }
                            else
                            {
                                message += "\n";
                            }
                            message += $"**Description:** {card.Description}";
                            if (card.Type == CardType.Monster)
                            {
                                message += $"\n**Type:** {card.MonsterType}\n**ATK/DEF:** {card.Attack}/{card.Defense}";
                            }

                            client.AttachFile(cmdArgs.Channel, message, "ygotemp.png");
                        }
                        else
                        {
                            cmdArgs.Channel.SendMessage("Couldn't find that specified card!");
                        }
                    }
                    catch (HttpRequestException ex)
                    {
                        cmdArgs.Channel.SendMessage("Couldn't find that specified card! (" + ex.Message + ")");
                    }
                }
            }));
            CommandsManager.AddCommand(new CommandStub("khaled", "Anotha one.", "", cmdArgs =>
            {
                if (rng == null)
                {
                    Console.WriteLine("RNG null?!");
                    rng = new Random((int)DateTime.Now.Ticks);
                }
                cmdArgs.Channel.SendMessage($"***{KhaledQuotes[rng.Next(0, KhaledQuotes.Length - 1)]}***");
            }));
            #endregion
        }
Esempio n. 9
0
        /// <summary>
        /// Setting up some commands
        /// </summary>
        private void SetUpCommands()
        {
            CommandsManager.AddCommand(new CommandStub("about", "Tells about bot.", "", PermissionType.User, 1, cmdArgs =>
            {
                this._client.SendMessageToChannel("Currently being in development this bot will assists moderators and administrators in managing server and channels.\nAuthor: Reverendo\nCourtesy: Big thanks to Luigifan", cmdArgs.Channel);
            }));
            CommandsManager.AddCommand(new CommandStub("help", "Provide discriptions to all avaliable commands", "", PermissionType.User, cmdArgs =>
            {
                string help = String.Format("inComplete set of commands:\n");
                foreach (var command in CommandsManager.Commands)
                {
                    help += String.Format("{0,-15} {1,-100}\n", this._config.CommandPrefix + command.CommandName, "-" + command.Description + " Level: " + command.MinimumPermission);
                }
                cmdArgs.Channel.SendMessage(help);
            }));
            CommandsManager.AddCommand(new CommandStub("join", "Join a specified server. Ownder only.", "", PermissionType.Owner, 1, cmdArgs =>
            {
                string substring = cmdArgs.Args[0].Substring(cmdArgs.Args[0].LastIndexOf('/') + 1);
                this._client.AcceptInvite(substring);
                Console.WriteLine($"Joined new server.");
                cmdArgs.Author.SlideIntoDMs("Joined server you requested!");
            }));
            CommandsManager.AddCommand(new CommandStub("wakeup", $"Mentions user multiple times. Example: {this._config.CommandPrefix}wakeup Username n-times", "specify victim", PermissionType.User, 2, cmdArgs =>
            {
                string substring = cmdArgs.Args[0].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[0];
                var victim       = this._client.GetMemberFromChannel(cmdArgs.Channel, cmdArgs.Args[0], false);
                int times        = 0;
                if (!int.TryParse(cmdArgs.Args[1], out times))
                {
                    cmdArgs.Channel.SendMessage("Numbers, not random letters, dummy!");
                }
                for (int i = 0; i < times; i++)
                {
                    cmdArgs.Channel.SendMessage($"@{victim.Username}, wake up!");
                }
            }));
            CommandsManager.AddCommand(new CommandStub("deletemsg", $"Delete last n messages. Example: {this._config.CommandPrefix}deletemsg n", "specify amount of messages", PermissionType.Mod, 1, cmdArgs =>
            {
                int amount = 0;
                int.TryParse(cmdArgs.Args[0], out amount);
                this._client.DeleteMultipleMessagesInChannel(cmdArgs.Channel, amount + 1);
            }));
            CommandsManager.AddCommand(new CommandStub("ban", $"Bans user for specified amount of days. Example: {this._config.CommandPrefix}ban user days", "", PermissionType.Mod, 2, cmdArgs =>
            {
                int days = 1;
                int.TryParse(cmdArgs.Args[1], out days);
                _client.BanMember(_client.GetMemberFromChannel(cmdArgs.Channel, cmdArgs.Args[0]));
            }));
            CommandsManager.AddCommand(new CommandStub("kick", $"Kicks user. Example: {this._config.CommandPrefix}kick user", "", PermissionType.Mod, 1, cmdArgs =>
            {
                this._client.KickMember(this._client.GetMemberFromChannel(cmdArgs.Channel, cmdArgs.Args[0]));
            }));
            CommandsManager.AddCommand(new CommandStub("permission", $"Grants user specified permission: Admin, Mod or User. Example: {this._config.CommandPrefix}permission user level", "", PermissionType.Owner, 2, cmdArgs =>
            {
                var member          = this._client.GetMemberFromChannel(cmdArgs.Channel, cmdArgs.Args[0], false);
                PermissionType type = PermissionType.User;
                switch (cmdArgs.Args[1].ToLower())
                {
                case "admin":
                    type = PermissionType.Admin;
                    break;

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

                case "user":
                    type = PermissionType.User;
                    break;

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

                default:
                    break;
                }
                cmdArgs.Channel.SendMessage($"User {member.Username} become {type.ToString()}");
                Console.WriteLine($"New {type.ToString()} - {member.Username}({member.ID})");
                CommandsManager.AddPermission(member, type);
            }));
            CommandsManager.AddCommand(new CommandStub("q", $"Posts random quote. Example: {this._config.CommandPrefix}q", "", PermissionType.None, 1, cmdArgs =>
            {
                cmdArgs.Channel.SendMessage("\"" + ConfuQuote[CommandsManager.rng.Next(0, ConfuQuote.Length)] + "\"" + " - Конфуций");
            }));
            CommandsManager.AddCommand(new CommandStub("ball", $"If you seek for advice, just ask. Example: {this._config.CommandPrefix}ball", "", PermissionType.None, cmdArgs =>
            {
                cmdArgs.Channel.SendMessage(Ball8[CommandsManager.rng.Next(0, Ball8.Length)]);
            }));
            CommandsManager.AddCommand(new CommandStub("joinvoice", "Join voice channel", "", PermissionType.Owner, 1, cmdArgs =>
            {
                DiscordChannel channelToJoin = cmdArgs.Channel.Parent.Channels.Find(x => x.Name.ToLower() == cmdArgs.Args[0].ToLower() && x.Type == ChannelType.Voice);
                if (channelToJoin != null)
                {
                    DiscordVoiceConfig config = new DiscordVoiceConfig
                    {
                        FrameLengthMs = 60,
                        Channels      = 1,
                        OpusMode      = DiscordSharp.Voice.OpusApplication.MusicOrMixed,
                        SendOnly      = true
                    };
                    this.CommandsManager.Client.ConnectToVoiceChannel(channelToJoin, config);
                    this.ap = new AudioPlayer(this.CommandsManager.Client, config, channelToJoin);
                }
            }));
            CommandsManager.AddCommand(new CommandStub("disconnect", "Disconnects from voice channel.", "", PermissionType.Owner, 0, cmdArgs =>
            {
                this._client.DisconnectFromVoice();
            }));
            CommandsManager.AddCommand(new CommandStub("player", "Granting access to audio player. Currently avaliable commands: play", "", PermissionType.User, 1, cmdArgs =>
            {
                switch (cmdArgs.Args[0])
                {
                case "play":
                    this.ap.Play();
                    break;

                case "stop":
                    if (this._client.GetVoiceClient() != null)
                    {
                        this._client.GetVoiceClient().ClearVoiceQueue();
                    }
                    break;

                default:
                    break;
                }
            }));
            CommandsManager.AddCommand(new CommandStub("roles", "Shows permission levels for users.", "", PermissionType.Owner, 0, cmdArgs =>
            {
                string msg = $"Roles for \"{cmdArgs.Channel.Parent.Name}\"\n";
                foreach (var role in cmdArgs.Channel.Parent.Roles)
                {
                    msg += $"{role.Position} - {role.ID} - {role.Permissions.GetRawPermissions()}\n";
                }
                owner.SlideIntoDMs(msg);
            }));
            CommandsManager.AddCommand(new CommandStub("shutdown", "Shutdown bot. Owner only.", "", PermissionType.Owner, 0, cmdArgs =>
            {
                Exit();
            }));
        }
Esempio n. 10
0
        public override void Install(CommandsManager manager)
        {
            LoadSystemsDictionary();

            // Setup the one time listener for adding systems.
            manager.Client.MessageCreated += async(
                e) =>
            {
                if (WaitingOnInput)
                {
                    if (WaitingOnInputFrom.Id == e.Author.Id && WaitingChannel.Id == e.Channel.Id)
                    {
                        if (!e.Message.Content.Contains("addsystem")) //skip because this has already been handled.
                        {
                            Console.WriteLine($"[SystemsModule] Got input from correct person in correct channel {WaitingOnInputFrom.Id} == {e.Author.Id}");
                            try
                            {
                                if (SystemsDatabase.ContainsKey(e.Author.Id)) //we already have a systems collection for this user.
                                {
                                    Console.WriteLine("[SystemsModule] Already had one, added");
                                    SystemsDatabase[e.Author.Id].Add("System " + (SystemsDatabase[e.Author.Id].Count + 1), e.Message.Content);
                                }
                                else
                                {
                                    Console.WriteLine("[SystemsModule] Created one");
                                    SystemsCollection <string, string> collection = new SystemsCollection <string, string>();
                                    collection.UserSnowflake = e.Author.Id;

                                    string systemName = "System 1";
                                    if (!String.IsNullOrEmpty(PotentialSystemName))
                                    {
                                        systemName          = PotentialSystemName.Trim();
                                        PotentialSystemName = null;
                                    }
                                    collection.Add(systemName, e.Message.Content);
                                    SystemsDatabase.Add(e.Author.Id, collection);
                                }
                                //SystemsDatabase[e.Author.Id] = collection;
                                WaitingOnInput     = false;
                                WaitingOnInputFrom = null;
                                Console.WriteLine("[SystemsModule] Flushing");
                                //Might as well save after write, I don't pay for the SSD on the VPS...
                                FlushSystemsModule();

                                await e.Channel.SendMessageAsync("👌");
                            }
                            catch (Exception ex)
                            {
                                await e.Channel.SendMessageAsync("bro something is royally f****d: " + ex.Message);

                                Console.WriteLine("[SystemsModule] Exception details\n\n" + ex.Message + "\n\n" + ex.StackTrace + "\n\n");
                                WaitingOnInput     = false;
                                WaitingOnInputFrom = null;
                            }
                        }
                    }
                }
            };

            manager.AddCommand(new CommandStub("addsystem", "Adds your system to the database, simply follow the prompts. ", "addsystem", cmdArgs =>
            {
                if (cmdArgs.Args.Count > 1)
                {
                    PotentialSystemName = cmdArgs.Args[1];
                }
                else
                {
                    PotentialSystemName = null;
                }

                var m = cmdArgs.Channel.SendMessageAsync($"Please enter system specs");
                Console.WriteLine($"[SystemsModule] Waiting on input from {cmdArgs.Message.Author.Username}");
                WaitingOnInput     = true;
                WaitingOnInputFrom = cmdArgs.Message.Author;
                WaitingChannel     = cmdArgs.Message.Channel;
            }, argCount: 1), this);

            manager.AddCommand(new CommandStub("system", "get someone's specs (mention is optional)", "system <user>", cmdArgs =>
            {
                if (cmdArgs.Args.Count == 1)
                {
                    // Check if it's a mention and handle nicely
                    if (cmdArgs.Args[0].StartsWith("<@") && (cmdArgs.Args[0].EndsWith(">")))
                    {
                        ulong ID = ulong.Parse(cmdArgs.Args[0].Trim(new char[] { '<', '>', '@', '!' }));
                        List <DiscordMember> membersListAsList = new List <DiscordMember>(cmdArgs.Channel.Guild.Members);
                        DiscordMember member = membersListAsList.Find(x => x.Id == ID);

                        if (SystemsDatabase.ContainsKey(ID))
                        {
                            SystemsCollection <string, string> collection = SystemsDatabase[ID];
                            var first     = collection.First();
                            string system = first.Value;
                            // TODO come back in a sec
                            DiscordEmbedBuilder b = new DiscordEmbedBuilder();
                            b.WithAuthor(member.DisplayName, icon_url: member.AvatarUrl);
                            b.WithColor(DiscordColor.Purple);
                            b.AddField("System", system);

                            cmdArgs.Channel.SendMessageAsync(embed: b.Build());
                        }
                        else
                        {
                            cmdArgs.Channel.SendMessageAsync("Sorry! You're not in the database :c");
                        }
                    }
                    else
                    {
                        IReadOnlyList <DiscordMember> membersList = cmdArgs.Channel.Guild.Members;
                        if (membersList != null)
                        {
                            List <DiscordMember> membersListAsList = new List <DiscordMember>(membersList);
                            DiscordMember member = membersListAsList.Find(x => x.Username.Trim('@') == cmdArgs.Args[0].Trim());

                            if (member != null)
                            {
                                if (SystemsDatabase.ContainsKey(member.Id))
                                {
                                    SystemsCollection <string, string> collection = SystemsDatabase[member.Id];
                                    var first     = collection.First();
                                    string system = first.Value;
                                    //cmdArgs.Channel.SendMessageAsync($"**System for {member.DisplayName}**:\n\n{system}");

                                    DiscordEmbedBuilder b = new DiscordEmbedBuilder();
                                    b.WithAuthor(member.DisplayName, icon_url: member.AvatarUrl);
                                    b.WithColor(DiscordColor.Purple);
                                    b.AddField(first.Key, system);

                                    cmdArgs.Channel.SendMessageAsync(embed: b.Build());
                                }
                                else
                                {
                                    cmdArgs.Channel.SendMessageAsync("Sorry! Not in the database :c");
                                }
                            }
                        }
                    }
                }
                else //do it for self
                {
                    ulong ID = cmdArgs.Author.Id;
                    List <DiscordMember> membersListAsList = new List <DiscordMember>(cmdArgs.Channel.Guild.Members);
                    DiscordMember member = membersListAsList.Find(x => x.Id == ID);

                    if (SystemsDatabase.ContainsKey(ID))
                    {
                        SystemsCollection <string, string> collection = SystemsDatabase[ID];
                        var first     = collection.First();
                        string system = first.Value;
                        // TODO come back in a sec
                        DiscordEmbedBuilder b = new DiscordEmbedBuilder();
                        b.WithAuthor(member.DisplayName, icon_url: member.AvatarUrl);
                        b.WithColor(DiscordColor.Purple);
                        b.AddField(first.Key, system);

                        cmdArgs.Channel.SendMessageAsync(embed: b.Build());
                    }
                    else
                    {
                        cmdArgs.Channel.SendMessageAsync("Sorry! You're not in the database :c");
                    }
                }
            }, PermissionType.User, 1), this);

            manager.AddCommand(new CommandStub("removesystem", "remove your system", "removesystem", cmdArgs =>
            {
                ulong userID = cmdArgs.Message.Author.Id;

                try
                {
                    SystemsDatabase.Remove(userID);
                    cmdArgs.Channel.SendMessageAsync("👌");
                }
                catch (Exception ex)
                {
                    cmdArgs.Channel.SendMessageAsync("Unable to remove your system. Please tell an admin immediately, something is royally borked.\n\n```\n" +
                                                     ex.Message + "\n```");
                }
            }, PermissionType.User, 0), this);
        }