Beispiel #1
0
 //Searching for Players
 private void searchbtn_Click(object sender, EventArgs e)
 {
     client.UpdateState("Searching...");
     client.UpdateDetails("");
     client.UpdateClearTime();
     client.UpdateLargeAsset("cover");
     client.UpdateSmallAsset(null, null);
     client.Invoke();
 }
Beispiel #2
0
 public DiscordPresence UpdateClearTime(DiscordTimestamp timestamp)
 {
     if (_client == null)
     {
         return(null);
     }
     return((DiscordPresence)_client.UpdateClearTime());
 }
Beispiel #3
0
        static void Main(string[] args)
        {
            var timer = new System.Timers.Timer(150);

            timer.Elapsed += (sender, sargs) => { if (Settings.Default.rpTimer && client != null && running)
                                                  {
                                                      client.UpdateClearTime();
                                                  }
            };
            timer.Start();

            Print("===== Discord RPC =====");
            if (Settings.Default.autostart && Settings.Default.clientID != "none")
            {
                Print("Auto Start configuration found, connecting...");
                client = new DiscordRpcClient(Settings.Default.clientID);
                Events(client);
                client.Initialize();
                client.SetPresence(FromSettings());
            }
            Print("Type \"help\" for a list of commands");

            while (true)
            {
                string inp = Input("Command: ");
                if (inp == "")
                {
                    continue;
                }

                List <string> cmdargs = new List <string>();
                foreach (var arg in inp.Split(' '))
                {
                    if (arg == "")
                    {
                        continue;
                    }
                    cmdargs.Add(arg);
                }

                string cmd = cmdargs[0];
                cmdargs.RemoveAt(0);
                string cmdInput = cmdargs.Count == 0 ? "" : inp.Substring(cmd.Length, inp.Length - cmd.Length).Trim();

                // Print("CMD:", cmd, ", CmdInput:", cmdInput);

                if (cmd == "id")
                {
                    if (cmdInput == "")
                    {
                        Print("Invalid Usage. Please input a valid Client ID too!");
                        continue;
                    }

                    Settings.Default.clientID = cmdInput;
                    Settings.Default.Save();
                    Print("Configured Client ID to", cmdInput + "!");
                }
                else if (cmd == "state" || cmd == "st")
                {
                    if (cmdInput == "")
                    {
                        Print("Invalid Usage. Please input a valid State Text too!");
                        continue;
                    }

                    Settings.Default.rpState = cmdInput;
                    Settings.Default.Save();
                    Print("Configured State Text to", cmdInput + "!");
                }
                else if (cmd == "detail" || cmd == "details" || cmd == "dt")
                {
                    if (cmdInput == "")
                    {
                        Print("Invalid Usage. Please input a valid Details Text too!");
                        continue;
                    }

                    Settings.Default.rpDetails = cmdInput;
                    Settings.Default.Save();
                    Print("Configured Details Text to", cmdInput + "!");
                }
                else if (cmd == "largetext" || cmd == "largetxt" || cmd == "ltxt")
                {
                    if (cmdInput == "")
                    {
                        Print("Invalid Usage. Please input a valid Large Image Text too!");
                        continue;
                    }

                    Settings.Default.rpLargeText = cmdInput;
                    Settings.Default.Save();
                    Print("Configured Large Image Text to", cmdInput + "!");
                }
                else if (cmd == "smalltext" || cmd == "smalltxt" || cmd == "stxt")
                {
                    if (cmdInput == "")
                    {
                        Print("Invalid Usage. Please input a valid Small Image Text too!");
                        continue;
                    }

                    Settings.Default.rpSmallText = cmdInput;
                    Settings.Default.Save();
                    Print("Configured Small Image Text to", cmdInput + "!");
                }
                else if (cmd == "largekey" || cmd == "largeimg" || cmd == "limg" || cmd == "lkey" || cmd == "largeimage")
                {
                    if (cmdInput == "")
                    {
                        Print("Invalid Usage. Please input a valid Large Image Key too!");
                        continue;
                    }

                    Settings.Default.rpLargeKey = cmdInput;
                    Settings.Default.Save();
                    Print("Configured Large Image Key to", cmdInput + "!");
                }
                else if (cmd == "smallkey" || cmd == "smallimg" || cmd == "simg" || cmd == "skey" || cmd == "smallimage")
                {
                    if (cmdInput == "")
                    {
                        Print("Invalid Usage. Please input a valid Small Image Key too!");
                        continue;
                    }

                    Settings.Default.rpSmallKey = cmdInput;
                    Settings.Default.Save();
                    Print("Configured Small Image Key to", cmdInput + "!");
                }
                else if (cmd == "run" || cmd == "start")
                {
                    if (running || client != null)
                    {
                        Print("RPC Connection already established!");
                        continue;
                    }

                    if (Settings.Default.clientID == "" || Settings.Default.clientID == "none")
                    {
                        Print("Add a valid Client ID first using \"id <insert id here>\" command!");
                        continue;
                    }

                    client = new DiscordRpcClient(Settings.Default.clientID);
                    Events(client);
                    client.Initialize();
                    client.SetPresence(FromSettings());
                    Settings.Default.Save();
                }
                else if (cmd == "info" || cmd == "current")
                {
                    Print("========================================");
                    Print("Running:    " + (running ? "Yes" : "No"));
                    Print("Client ID:  " + Nullify(Settings.Default.clientID) ?? "None");
                    Print("State:      " + Nullify(Settings.Default.rpState) ?? "None");
                    Print("Details:    " + Nullify(Settings.Default.rpDetails) ?? "None");
                    Print("Large Text: " + Nullify(Settings.Default.rpLargeText) ?? "None");
                    Print("Large Img:  " + Nullify(Settings.Default.rpLargeKey) ?? "None");
                    Print("Small Text: " + Nullify(Settings.Default.rpSmallText) ?? "None");
                    Print("Small Img:  " + Nullify(Settings.Default.rpSmallKey) ?? "None");
                    Print("Timer?:     " + (Settings.Default.rpTimer ? "Enabled" : "Disabled"));
                    Print("========================================");
                }
                else if (cmd == "timer" || cmd == "t")
                {
                    Settings.Default.rpTimer = !Settings.Default.rpTimer;
                    Settings.Default.Save();
                    Print("RPC Timer:", Settings.Default.rpTimer ? "Enabled" : "Disabled");
                }
                else if (cmd == "update" || cmd == "u" || cmd == "up")
                {
                    if (!running || client == null)
                    {
                        Print("RPC not connected");
                        continue;
                    }

                    client.SetPresence(FromSettings());
                }
                else if (cmd == "autostart" || cmd == "as" || cmd == "auto")
                {
                    Settings.Default.autostart = !Settings.Default.autostart;
                    Settings.Default.Save();
                    Print("RPC AutoStart:", Settings.Default.autostart ? "Enabled" : "Disabled");
                }
                else if (cmd == "dc" || cmd == "end" || cmd == "disconnect" || cmd == "stop")
                {
                    if (!running || client == null)
                    {
                        Print("RPC is not even running!");
                        continue;
                    }

                    client.Dispose();
                    client  = null;
                    running = false;
                }
                else if (cmd == "x" || cmd == "exit" || cmd == "q" || cmd == "quit")
                {
                    Settings.Default.Save();
                    if (client != null)
                    {
                        client.Dispose();
                    }
                    Environment.Exit(0);
                }
                else if (cmd == "help" || cmd == "cmds" || cmd == "commands" || cmd == "h" || cmd == "hlp" || cmd == "halp")
                {
                    Print("============== Commands ================");
                    Print("info:       See current configuration   ");
                    Print("id:         Set Client ID               ");
                    Print("state:      Set State Text              ");
                    Print("details:    Set Details                 ");
                    Print("largetext:  Set Large Image Text        ");
                    Print("largeimg:   Set Large Image Key         ");
                    Print("smalltext:  Set Small Image Text        ");
                    Print("smallimg:   Set Small Image Key         ");
                    Print("timer:      Toggle Timer                ");
                    Print("autostart:  Toggle AutoStart on Startup ");
                    Print("clear:      Clear Discord RP            ");
                    Print("stop:       Stop/DC from Discord RP     ");
                    Print("exit:       Exit the application        ");
                    Print("========================================");
                    Print("/============================================\\");
                    Print("| Note: All the commands which set something |");
                    Print("| or toggle, store the data on your PC. So   |");
                    Print("| you don't have to enter each time.         |");
                    Print("\\============================================/");
                }
                else if (cmd == "clear" || cmd == "cls" || cmd == "cl")
                {
                    if (!running || client == null)
                    {
                        Print("RPC Not connected!");
                        continue;
                    }

                    client.ClearPresence();
                    Print("Presence Cleared.");
                }
                else
                {
                    Print("Invalid Command!");
                }
            }
        }