Пример #1
0
        private void BasicClient()
        {
            //Create a new client
            var client = new DiscordRpcClient("560482798364917789");

            //Create some events so we know things are happening
            //Create a timer that will regularly call invoke
            var timer = new System.Timers.Timer(150);

            timer.Elapsed += (sender, evt) => { client.Invoke(); };
            timer.Start();

            //Connect
            client.Initialize();

            //Send a presence. Do this as many times as you want
            client.SetPresence(new RichPresence()
            {
                Details = "Gamemode: Valid Hunt Racing",
                State   = "/vg/station",
                Assets  = new Assets()
                {
                    LargeImageKey  = "vgstation-logo2",
                    LargeImageText = "Meta Station",
                    SmallImageKey  = "logo",
                },
                Timestamps = Timestamps.FromTimeSpan(10)
            });
        }
Пример #2
0
        public static void Initialize()
        {
            Presence = new RichPresence
            {
                Details = "In Main Menu",
                Assets  = new Assets
                {
                    LargeImageText = "Aerovelence",
                    LargeImageKey  = "aerodefault",
                    SmallImageKey  = "helditem"
                },
                State = ""
            };

            if (Main.netMode != NetmodeID.SinglePlayer)
            {
                Presence.Party = new Party
                {
                    Size = Main.ActivePlayersCount,
                    Max  = Main.maxNetPlayers
                }
            }
            ;

            Client = new DiscordRpcClient("828361668646928466");

            Presence.Timestamps = new Timestamps
            {
                Start = DateTime.UtcNow
            };

            Client?.Initialize();
            Client?.SetPresence(Presence);
        }
Пример #3
0
        private static void OnJoinRequested(object sender, JoinRequestMessage args)
        {
            /*
             * This is called when the Discord Client has received a request from another external Discord User to join your game.
             * You should trigger a UI prompt to your user sayings 'X wants to join your game' with a YES or NO button. You can also get
             *  other information about the user such as their avatar (which this library will provide a useful link) and their nickname to
             *  make it more personalised. You can combine this with more API if you wish. Check the Discord API documentation.
             *
             *  Once a user clicks on a response, call the Respond function, passing the message, to respond to the request.
             *  A example is provided below.
             *
             * This feature requires the RegisterURI to be true on the client.
             */

            //We have received a request, dump a bunch of information for the user
            Console.WriteLine("'{0}' has requested to join our game.", args.User.Username);
            Console.WriteLine(" - User's Avatar: {0}", args.User.GetAvatarURL(User.AvatarFormat.GIF, User.AvatarSize.x2048));
            Console.WriteLine(" - User's Descrim: {0}", args.User.Discriminator);
            Console.WriteLine(" - User's Snowflake: {0}", args.User.ID);
            Console.WriteLine();

            //Ask the user if they wish to accept the join request.
            Console.Write("Do you give this user permission to join? [Y / n]: ");
            bool accept = Console.ReadKey().Key == ConsoleKey.Y; Console.WriteLine();

            //Tell the client if we accept or not.
            DiscordRpcClient client = (DiscordRpcClient)sender;

            client.Respond(args, accept);

            //All done.
            Console.WriteLine(" - Sent a {0} invite to the client {1}", accept ? "ACCEPT" : "REJECT", args.User.Username);
        }
Пример #4
0
        public DiscordRP(string ClientID = null)
        {
            if (ClientID == null)
            {
                this.ClientID = "802668887073751041";
            }
            else
            {
                this.ClientID = ClientID;
            }

            discord = new DiscordRpcClient(this.ClientID);

            discord.OnReady += (sender, e) =>
            {
                Console.WriteLine("Received Ready from user {0}", e.User.Username);
            };

            discord.OnPresenceUpdate += (sender, e) =>
            {
                Console.WriteLine("Received Update! {0}", e.Presence);
            };

            discord.Initialize();

            Details = "Iniciando";
            State   = "Esperando música";

            UpdateActivity();
        }
Пример #5
0
        private void load(IAPIProvider provider, OsuConfigManager config)
        {
            client = new DiscordRpcClient(client_id)
            {
                SkipIdenticalPresence = false // handles better on discord IPC loss, see updateStatus call in onReady.
            };

            client.OnReady += onReady;

            // safety measure for now, until we performance test / improve backoff for failed connections.
            client.OnConnectionFailed += (_, __) => client.Deinitialize();

            client.OnError += (_, e) => Logger.Log($"An error occurred with Discord RPC Client: {e.Code} {e.Message}", LoggingTarget.Network);

            config.BindWith(OsuSetting.DiscordRichPresence, privacyMode);

            (user = provider.LocalUser.GetBoundCopy()).BindValueChanged(u =>
            {
                status.UnbindBindings();
                status.BindTo(u.NewValue.Status);

                activity.UnbindBindings();
                activity.BindTo(u.NewValue.Activity);
            }, true);

            ruleset.BindValueChanged(_ => updateStatus());
            status.BindValueChanged(_ => updateStatus());
            activity.BindValueChanged(_ => updateStatus());
            privacyMode.BindValueChanged(_ => updateStatus());

            client.Initialize();
        }
 public RidersRichPresence(GetRaceModeHook getRaceModeHook)
 {
     _getRaceModeHook = getRaceModeHook;
     _discordRpc      = new DiscordRpcClient("713075835653062666"); // Not like you could get this from decompiling anyway. Obfuscation? That sucks.
     _discordRpc.Initialize();
     _timer = new System.Threading.Timer(OnTick, null, 0, 5000);
 }
Пример #7
0
        private void InitializeDiscord()
        {
            client = new DiscordRpcClient("535459312915578910")
            {
                Logger = new ConsoleLogger()
                {
#if DEBUG
                    Level = LogLevel.Warning
#else
                    Level = LogLevel.None
#endif
                }
            };

#if DEBUG
            client.OnReady += (sender, e) =>
            {
                Debug.WriteLine("Received Ready from user {0}", e.User.Username);
            };

            client.OnPresenceUpdate += (sender, e) =>
            {
                Debug.WriteLine("Received Update! {0}", e.Presence);
            };
#endif

            client.Initialize();
        }
Пример #8
0
        private void load(IAPIProvider provider)
        {
            client = new DiscordRpcClient(client_id)
            {
                SkipIdenticalPresence = false // handles better on discord IPC loss, see updateStatus call in onReady.
            };

            client.OnReady += onReady;
            client.OnError += (_, e) => Logger.Log($"An error occurred with Discord RPC Client: {e.Code} {e.Message}", LoggingTarget.Network);

            (user = provider.LocalUser.GetBoundCopy()).BindValueChanged(u =>
            {
                status.UnbindBindings();
                status.BindTo(u.NewValue.Status);

                activity.UnbindBindings();
                activity.BindTo(u.NewValue.Activity);
            }, true);

            ruleset.BindValueChanged(_ => updateStatus());
            status.BindValueChanged(_ => updateStatus());
            activity.BindValueChanged(_ => updateStatus());

            client.Initialize();
        }
Пример #9
0
        private void InitDiscord()
        {
            DateTime now = DateTime.Now;

            client = new DiscordRpcClient("681252858058113030");

            client.OnReady += (sender, e) =>
            {
                Console.WriteLine("Received Ready from user {0}", e.User.Username);
            };

            client.OnPresenceUpdate += (sender, e) =>
            {
                Console.WriteLine("Received Update! {0}", e.Presence);
            };

            client.Initialize();

            client.SetPresence(new RichPresence()
            {
                Details = "Playing AssaultCube",
                State   = "Cheating...",
                Assets  = new Assets()
                {
                    LargeImageKey  = "logo",
                    LargeImageText = "Using AssaultCube Cheat",
                }
            });
        }
Пример #10
0
        /* Connection */

        public void StartRPC()
        {
            if (isOffline)
            {
                return;
            }

            // Check if connection exists to avoid creating multiple connections
            Instance = new RichPresence();
            Debugger.Discord(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_DISCORD_CONNECTED']"));
            Client = new DiscordRpcClient(APP_ID, autoEvents: true);

            Client.RegisterUriScheme("582010");

            // Events
            Client.OnReady         += Client_OnReady;
            Client.OnJoinRequested += Client_OnJoinRequested;
            Client.OnJoin          += Client_OnJoin;

            Client.SetSubscription(EventType.JoinRequest | EventType.Join);

            Client.Initialize();
            if (!UserSettings.PlayerConfig.RichPresence.Enabled && isVisible)
            {
                Client?.ClearPresence();
                isVisible = false;
            }
        }
Пример #11
0
        public void Execute()
        {
            // todo do things
            Console.CancelKeyPress += new ConsoleCancelEventHandler(CtrlC);
            running         = true;
            client          = new DiscordRpcClient("410474255810035712", null, true, -1); // bind to 1st available pipe
            client.OnReady += RPCReady;

            Assets assets = new Assets()
            {
                LargeImageKey  = "cone",
                LargeImageText = "VLC media player"
            };

            presence = new RichPresence()
            {
                State   = "In C#",
                Details = "Test",
                Assets  = assets
            };

            client.SetPresence(presence);
            client.Initialize();

            while (running && client != null)
            {
                client.Invoke();
                Thread.Sleep(15000); // sleep for 15s
            }
        }
Пример #12
0
        /// <summary>
        /// Initializes the Discord RPC API
        /// </summary>
        private void InitializeDiscord()
        {
            string clientID = "535310204859056139";

            _discordRpcClient = new DiscordRpcClient(clientID);
            _discordRpcClient.Initialize();
        }
        public JeremieLauncher()
        {
            InitializeComponent();
            instance      = this;
            Text         += " " + launcherVersion.ToString();
            client        = new DiscordRpcClient("718605351263535106");
            client.Logger = new ConsoleLogger()
            {
                Level = LogLevel.Warning
            };
            client.Initialize();

            startTime = (ulong)DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();

            RichPresence = new RichPresence()
            {
                Details = "Jeremie Launcher " + launcherVersion.ToString(),
                Assets  = new Assets()
                {
                    LargeImageKey = "image"
                },
                Timestamps = new Timestamps()
                {
                    StartUnixMilliseconds = startTime
                }
            };

            client.SetPresence(RichPresence);
        }
 private void optionsChanged(object sender, OptionsChangedEventArgs e)
 {
     if (e.GetOption <int>("checkUpdateTime") != 0)
     {
         checkUpdate_timer.Interval = Options.TimeSelections[e.GetOption <int>("checkUpdateTime")] * 60000;
         checkUpdate_timer.Start();
     }
     else
     {
         checkUpdate_timer.Stop();
     }
     if (e.GetOption <bool>("discordRichPresence"))
     {
         if (!client.IsInitialized)
         {
             client        = new DiscordRpcClient("718605351263535106");
             client.Logger = new ConsoleLogger()
             {
                 Level = LogLevel.Warning
             };
             client.Initialize();
             client.SetPresence(RichPresence);
         }
     }
     else
     {
         if (client.IsInitialized)
         {
             client.Deinitialize();
         }
     }
 }
Пример #15
0
        public static void InitializeRPC()
        {
            client = new DiscordRpcClient("697579712653819985");
            client.Initialize();
            Button[] buttons = { new Button()
                                 {
                                     Label = "Discord", Url = API.api.apidata.discordurl
                                 }, new Button()
                                 {
                                     Label = "YouTube", Url = "https://youtube.com/proswapperofficial"
                                 } };

            client.SetPresence(new RichPresence()
            {
                Details    = "Pro Swapper | " + global.version,
                State      = "Idle",
                Timestamps = Timestamps.Now,
                Buttons    = buttons,

                Assets = new Assets()
                {
                    LargeImageKey  = "logotransparent",
                    LargeImageText = "Pro Swapper",
                    SmallImageKey  = "proswapperman",
                    SmallImageText = "Made by Kye#5000"
                }
            });
            SetState("Idle");
        }
Пример #16
0
        private void Update()
        {
            if (m_Client != null)
            {
                m_Lock.EnterReadLock();
                try
                {
                    m_Client.SetPresence(m_Presence);
                }
                finally
                {
                    m_Lock.ExitReadLock();
                }
                m_Client.Invoke();
            }

            if (m_Active == true)
            {
                if (m_Client == null)
                {
                    m_Client = new DiscordRpcClient("845540839878164490");
                    if (m_Client.Initialize() == false)
                    {
                        m_Client.Dispose();
                        m_Client = null;
                    }
                }
            }
            else if (m_Client != null)
            {
                m_Client.Dispose();
                m_Client = null;
            }
        }
Пример #17
0
        public MainWindow()
        {
            InitializeComponent();
            updater.Tick    += Update;
            updater.Interval = TimeSpan.FromMilliseconds(1000);


            client = new DiscordRpcClient("801172982231859291");

            //Set the logger
            client.Logger = new ConsoleLogger()
            {
                Level = LogLevel.Warning
            };

            //Subscribe to events
            client.OnReady += (sender, e) =>
            {
                Console.WriteLine("Received Ready from user {0}", e.User.Username);
            };

            client.OnPresenceUpdate += (sender, e) =>
            {
                Console.WriteLine("Received Update! {0}", e.Presence);
            };
        }
Пример #18
0
        public static void Initialize()
        {
            client          = new DiscordRpcClient("456867456040960001");
            client.OnReady += (sender, msg) =>
            {
#if TESTING
                Console.WriteLine($"Connected Discord Rich Presence with user {msg.User.Username}");
#endif
                RPCConnected   = true;
                RPCConnectedTo = msg.User.Username;
            };

            client.OnPresenceUpdate += (sender, msg) =>
            {
#if TESTING
                Console.WriteLine("Presence has been updated! ");
#endif
            };
            client.Initialize();
            client.SetPresence(new RichPresence()
            {
                Details = "Playing AQW",
                State   = "By : CptShad#7140",
                Assets  = new Assets()
                {
                    LargeImageKey  = "icon",
                    LargeImageText = "AQW Connect"
                },
                Timestamps = Timestamps.Now
            });
        }
Пример #19
0
        public DiscordService(MiniYaml yaml)
        {
            FieldLoader.Load(this, yaml);

            // HACK: Prevent service from starting when launching the utility or server.
            if (Game.Renderer == null)
            {
                return;
            }

            client = new DiscordRpcClient(ApplicationId, autoEvents: true)
            {
                SkipIdenticalPresence = false
            };

            client.OnJoin          += OnJoin;
            client.OnJoinRequested += OnJoinRequested;

            // HACK: We need to set HasRegisteredUriScheme to bypass the check that is done when calling SetPresence with a joinSecret.
            // DiscordRpc lib expect us to register uri handlers with RegisterUriScheme(), we are doing it ourselves in our installers/launchers.
            client.GetType().GetProperty("HasRegisteredUriScheme").SetValue(client, true);

            client.SetSubscription(EventType.Join | EventType.JoinRequest);
            client.Initialize();
        }
Пример #20
0
        public void initClient()
        {
            if (DetailsTB.Text != "" && StateLbl.Text != "" && clientIDTB.Text != "")
            {
                client = new DiscordRpcClient(clientIDTB.Text);
                if (client.Initialize())
                {
                    if (!isEndCB.Checked)
                    {
                        presence = new RichPresence()
                        {
                            Details    = DetailsTB.Text,
                            State      = StateTB.Text,
                            Timestamps = new Timestamps()
                            {
                                Start = DateTime.UtcNow
                            },
                            Assets = new Assets()
                            {
                                LargeImageKey  = largeImageKeyTB.Text,
                                SmallImageKey  = smallImageKeyTB.Text,
                                LargeImageText = largeImageTextTB.Text,
                                SmallImageText = smallImageTextTB.Text
                            }
                        };
                    }
                    else
                    {
                        presence = new RichPresence()
                        {
                            Details    = DetailsTB.Text,
                            State      = StateTB.Text,
                            Timestamps = new Timestamps()
                            {
                                Start = DateTime.UtcNow,
                                End   = DateTime.UtcNow + TimeSpan.FromSeconds(Convert.ToDouble(endTimeTB.Text))
                            },
                            Assets = new Assets()
                            {
                                LargeImageKey  = largeImageKeyTB.Text,
                                SmallImageKey  = smallImageKeyTB.Text,
                                LargeImageText = largeImageTextTB.Text,
                                SmallImageText = smallImageTextTB.Text
                            }
                        };
                    }

                    client.SetPresence(presence);
                }
                else
                {
                    MessageBox.Show("Could not init discrod rpc");
                }
            }
            else
            {
                MessageBox.Show("Please Field Text Boxes:\n[Details] [State] [ClientID]", "Warning", MessageBoxButtons.OK);
                Application.Restart();
            }
        }
Пример #21
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            discordRpcClient = new DiscordRpcClient(DiscordTokens.AppID);

            discordRpcClient.OnReady += (x, y) => {
                DiscordTokens.ID            = y.User.ID.ToString();
                DiscordTokens.Username      = y.User.Username.ToString();
                DiscordTokens.Discriminator = y.User.Username.ToString();
                DiscordTokens.Avatar        = y.User.Avatar.ToString();
            };

            discordRpcClient.OnError += (x, y) => {
                MessageBox.Show($"Discord Error\n{y.Message}", y.Code.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
            };

            _presence.State   = "MainWindow";
            _presence.Details = "In-Launcher: " + Application.ProductVersion;
            _presence.Assets  = new Assets {
                LargeImageText = "SBRW",
                LargeImageKey  = "nfsw"
            };

            discordRpcClient.SetPresence(_presence);

            discordRpcClient.Initialize();
        }
Пример #22
0
        /// <summary>
        /// Sets up the timer
        /// </summary>
        public void Initialize(int pipe = -1)
        {
            if (_callbackTimer != null || _rpcClient != null || _presence != null)
            {
                throw new Exception("Already running! Dispose first");
            }

            // Create the RPC client
            _rpcClient          = new DiscordRpcClient(Settings.DiscordAppId, pipe);
            _rpcClient.OnReady += OnReady;
            _rpcClient.OnClose += OnClose;
            _rpcClient.OnError += OnError;
            _rpcClient.OnConnectionEstablished += OnConnectionEstablished;
            _rpcClient.OnConnectionFailed      += OnConnectionFailed;

            // Define an initial presence
            _presence = new RichPresence {
                Assets = new Assets {
                    LargeImageKey  = "misc_logo",
                    LargeImageText = $"{Settings.ProgramName} {Settings.Version}"
                }
            };

            // Start the client
            _rpcClient.SetPresence(_presence);
            _rpcClient.Initialize();
            _callbackTimer = new Timer(TimerCallback, null, TimeSpan.Zero, Settings.PresencePollInterval);
        }
Пример #23
0
 public static void Initialize()
 {
     client          = new DiscordRpcClient("699266677698723941");
     client.OnError += (sender, e) => logger.Error(e.Message);
     _ = client.Initialize();
     SetPresence("In main menu");
 }
Пример #24
0
        /// <summary>
        /// Turn the rich presence on.
        /// </summary>
        /// <param name="automatic">Whether to have EliteAPI send events to the presence.</param>
        public RichPresenceClient TurnOn(bool automatic = true)
        {
            //Create RPC client.
            rpc = new DiscordRpcClient(clientID, true);
            api.Logger.Log("Starting rich presence.");

            //Subscribe to events.
            rpc.OnConnectionEstablished += (sender, e) => api.Logger.Log(Severity.Debug, $"Attempting to connect to Discord ... ");
            rpc.OnConnectionFailed      += (sender, e) => { api.Logger.Log(Severity.Error, $"There was an error while trying to connect to Discord. Make sure Discord is running.", new ExternalException("Discord is unresponsive, or might not be running on this machine.")); TurnOff(); };
            rpc.OnError              += (sender, e) => api.Logger.Log(Severity.Error, $"Discord Rich Presence stumbled upon an error.", new ExternalException(e.Message, (int)e.Code));
            rpc.OnReady              += (sender, e) => { api.Logger.Log(Severity.Success, $"Discord Rich Presence has connected and is running."); IsReady = true; };
            rpc.OnClose              += (sender, e) => { api.Logger.Log($"Discord Rich Presence closed.", new ExternalException(e.Reason, e.Code)); TurnOff(); };
            rpc.OnJoin               += (sender, e) => api.Logger.Log(Severity.Debug, $"Discord Rich Presence joined with secret '{e.Secret}'.");
            rpc.OnJoinRequested      += (sender, e) => api.Logger.Log(Severity.Debug, $"Discord Rich Presence joining with '{e.User.Username}' (ID {e.User.ID})");
            api.Events.DockedEvent   += (sender, e) => { justDocked = true; };
            api.Events.UndockedEvent += (sender, e) => { justDocked = false; };

            //Start the RPC.
            //Mark as running.
            IsRunning = true;
            rpc.SetSubscription(EventType.Join | EventType.JoinRequest | EventType.Spectate);
            rpc.Initialize();
            Task.Run(() => { while (!IsReady)
                             {
                                 Thread.Sleep(1000); rpc.Invoke();
                             }
                     });
            if (automatic)
            {
                DoAutomaticEvents();
            }
            return(this);
        }
        public void initialize()
        {
            client = new DiscordRpcClient("");

            client.Logger = new ConsoleLogger()
            {
                Level = LogLevel.Trace
            };

            client.OnReady += (sender, e) =>
            {
                Console.WriteLine("Received Ready from user {0}", e.User.Username);
            };

            client.OnPresenceUpdate += (sender, e) =>
            {
                Console.WriteLine("Received Update! {0}", e.Presence);
            };

            client.Initialize();

            client.SetPresence(new RichPresence()
            {
                Details = "Example Project",
                State   = "csharp example",
                Assets  = new Assets()
                {
                    LargeImageKey  = "image_large",
                    LargeImageText = "Lachee's Discord IPC Library",
                    SmallImageKey  = "image_small"
                }
            });
        }
Пример #26
0
        /// <summary>
        /// Initializes connection to the Discord API.
        /// </summary>
        /// <returns><see langword="False"/> if ID isn't set, otherwise <see langword="true"/>.</returns>
        private bool Init()
        {
            if (settings.id == "")
            {
                MessageBox.Show(Strings.errorNoID, Strings.error, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                return(false);
            }

            if (client != null && !client.IsDisposed)
            {
                client.Dispose();                                           // This stuff needs proper disposal
            }
            client = new DiscordRpcClient(settings.id, (int)settings.pipe); // Assigning the ID
            client.OnPresenceUpdate   += ClientOnPresenceUpdate;
            client.OnError            += ClientOnError;
            client.OnConnectionFailed += ClientOnConnFailed;

            client.Logger = new TimestampFileLogger(Application.StartupPath + "\\rpc.log");

            client.Initialize();

            SetPresence();

            return(true);
        }
        public static void Initialize()
        {
            //this code was lazily CTRL+C'd and CTRL+V'd from the https://github.com/Lachee/discord-rpc-csharp README.md file because i'm lazy lmao

            /*
             * Create a discord client
             * NOTE:    If you are using Unity3D, you must use the full constructor and define
             *       the pipe connection.
             */
            client = new DiscordRpcClient("693125956960911391");

            //Set the logger
            client.Logger = new ConsoleLogger()
            {
                Level = LogLevel.Warning
            };

            //Subscribe to events
            client.OnReady += (sender, e) => {
                initialized = true;
                //Console.WriteLine("RPC Log: Received Ready from user {0}", e.User.Username);
            };

            client.OnPresenceUpdate += (sender, e) => {
                //Console.WriteLine("RPC Log: Received Update - {0}", e.Presence);
            };

            client.OnClose += (sender, e) => {
                //Console.WriteLine("RPC Log: Connection to Discord lost/terminated.");
            };

            //Connect to the RPC
            client.Initialize();
        }
Пример #28
0
        private async void Form1_Load(object sender, EventArgs e)
        {
            HttpClient http = new HttpClient();

            if (!HttpListener.IsSupported)
            {
                MessageBox.Show("Windows XP SP2 or Server 2003 is required to use the HttpListener class.");
                return;
            }

            client = new DiscordRpcClient("494943194165805082", true, 0);
            client.Initialize();

            var hi = await http.GetAsync("https://raw.githubusercontent.com/Lilwiggy/counter-strike-rpc/master/version.json");

            string s = await hi.Content.ReadAsStringAsync();

            dynamic JSON = JObject.Parse(s);

            if (JSON.v != v)
            {
                MessageBox.Show("You have an outdated version! I'll open up your favorite browser with a link to the latest version for you to download :)");
                Process.Start($"https://github.com/Lilwiggy/counter-strike-rpc/releases/tag/V{JSON.v}");
            }
            RunListener();
        }
Пример #29
0
 public void discord_rpc_init()
 {
     if (!discordRpcClient.IsInitialized)
     {
         discordRpcClient = new DiscordRpcClient("842763717179342858");
         discordRpcClient.Initialize();
         if (beat_length == 0)
         {
             discordRpcClient.SetPresence(new RichPresence()
             {
                 Details = "No song selected",
                 State   = "¯\\_(ツ)_/¯",
                 Assets  = new Assets()
                 {
                     LargeImageKey  = "hues_csharp_main3",
                     LargeImageText = "That's Kybey, The Cutest Waifu",
                 }
             });
         }
         else
         {
             discordRpcClient.SetPresence(new RichPresence()
             {
                 Details = "Playing song",
                 State   = RPM.allSongs[current_song].title,
                 Assets  = new Assets()
                 {
                     LargeImageKey  = "hues_csharp_main3",
                     LargeImageText = "That's Kybey, The Cutest Waifu",
                 }
             });
         }
     }
 }
Пример #30
0
        private void Form1_Load(object sender, EventArgs e)
        {
            FormBorderStyle = FormBorderStyle.None;
            SetBorderCurve(10);
            DoubleBuffered = true;

            mainLauncher1.SendToBack();

            if (!Directory.Exists("mars_client"))
            {
                DirectoryInfo di = Directory.CreateDirectory("mars_client");
                di.Attributes = FileAttributes.Hidden;
            }

            DiscordRpcClient cli;

            cli = new DiscordRpcClient("620414963902709760");
            //cli.RegisterUriScheme(null, null);
            //cli.OnJoinRequested += Cli_OnJoinRequested;
            cli.Initialize();
            Data.rpccli = cli;

            Data.hook = new KeyboardHooking();

            if (!File.Exists("mars_client\\bindings.ser"))
            {
                Data.keybinds = new KeybindManager();
            }
            else
            {
                Data.keybinds = KeybindManager.Deserialize(
                    File.ReadAllText("mars_client\\bindings.ser"));
            }
        }