Ejemplo n.º 1
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();
        }