Esempio n. 1
0
 public DiscordPresence UpdateEndTime(DiscordTimestamp timestamp)
 {
     if (_client == null)
     {
         return(null);
     }
     return((DiscordPresence)_client.UpdateEndTime(timestamp.GetDateTime()));
 }
    /// <summary>
    /// Converts this object into a new instance of a rich presence, ready to be sent to the discord client.
    /// </summary>
    /// <returns>A new instance of a rich presence, ready to be sent to the discord client.</returns>
    public DiscordRPC.RichPresence ToRichPresence()
    {
        var presence = new DiscordRPC.RichPresence();

        presence.State   = this.state;
        presence.Details = this.details;

        presence.Party   = !this.party.IsEmpty() ? this.party.ToRichParty() : null;
        presence.Secrets = !this.secrets.IsEmpty() ? this.secrets.ToRichSecrets() : null;

        if ((smallAsset != null && !smallAsset.IsEmpty()) || (largeAsset != null && !largeAsset.IsEmpty()))
        {
            presence.Assets = new DiscordRPC.Assets()
            {
                SmallImageKey  = smallAsset.image,
                SmallImageText = smallAsset.tooltip,

                LargeImageKey  = largeAsset.image,
                LargeImageText = largeAsset.tooltip
            };
        }

        if (startTime.IsValid() || endTime.IsValid())
        {
            presence.Timestamps = new DiscordRPC.Timestamps();
            if (startTime.IsValid())
            {
                presence.Timestamps.Start = startTime.GetDateTime();
            }
            if (endTime.IsValid())
            {
                presence.Timestamps.End = endTime.GetDateTime();
            }
        }

        if (buttons.Length > 0)
        {
            presence.Buttons = new DiscordRPC.Button[buttons.Length];

            for (int i = 0; i < buttons.Length; i++)
            {
                presence.Buttons[i] = new DiscordRPC.Button
                {
                    Label = buttons[i].label,
                    Url   = buttons[i].url
                };
            }
        }

        return(presence);
    }
Esempio n. 3
0
    /// <summary>
    /// Converts this object into a new instance of a rich presence, ready to be sent to the discord client.
    /// </summary>
    /// <returns>A new instance of a rich presence, ready to be sent to the discord client.</returns>
    public DiscordRPC.RichPresence ToRichPresence()
    {
        var presence = new DiscordRPC.RichPresence();

        presence.State   = this.state;
        presence.Details = this.details;

        presence.Party   = !this.party.IsEmpty() ? this.party.ToRichParty() : null;
        presence.Secrets = !this.secrets.IsEmpty() ? this.secrets.ToRichSecrets() : null;

        if ((smallAsset != null && !smallAsset.IsEmpty()) || (largeAsset != null && !largeAsset.IsEmpty()))
        {
            presence.Assets = new DiscordRPC.Assets()
            {
                SmallImageKey  = smallAsset.image,
                SmallImageText = smallAsset.tooltip,

                LargeImageKey  = largeAsset.image,
                LargeImageText = largeAsset.tooltip
            };
        }

        if (startTime.IsValid() || endTime.IsValid())
        {
            presence.Timestamps = new DiscordRPC.Timestamps();
            if (startTime.IsValid())
            {
                presence.Timestamps.Start = startTime.GetDateTime();
            }
            if (endTime.IsValid())
            {
                presence.Timestamps.End = endTime.GetDateTime();
            }
        }

        if ((firstButton != null && !firstButton.IsEmpty()) || (secondButton != null && !secondButton.IsEmpty()))
        {
            presence.Buttons = new DiscordRPC.Button[]
            {
                new DiscordRPC.Button {
                    Label = firstButton.label, Url = firstButton.url
                },
                new DiscordRPC.Button {
                    Label = secondButton.label, Url = secondButton.url
                }
            };
        }

        return(presence);
    }
Esempio n. 4
0
    /// <summary>
    /// Converts this object into a new instance of a rich presence, ready to be sent to the discord client.
    /// </summary>
    /// <returns>A new instance of a rich presence, ready to be sent to the discord client.</returns>
    public DiscordRPC.RichPresence ToRichPresence()
    {
        var presence = new DiscordRPC.RichPresence();

        presence.State   = this.state;
        presence.Details = this.details;

        presence.Party   = !this.party.IsEmpty() ? this.party.ToRichParty() : null;
        presence.Secrets = !this.secrets.IsEmpty() ? this.secrets.ToRichSecrets() : null;

        if (!smallAsset.IsEmpty() || !largeAsset.IsEmpty())
        {
            presence.Assets = new DiscordRPC.Assets()
            {
                SmallImageKey  = smallAsset.image,
                SmallImageText = smallAsset.tooltip,

                LargeImageKey  = largeAsset.image,
                LargeImageText = largeAsset.tooltip
            };
        }

        if (startTime.IsValid() || endTime.IsValid())
        {
            presence.Timestamps = new DiscordRPC.Timestamps();
            if (startTime.IsValid())
            {
                presence.Timestamps.Start = startTime.GetDateTime();
            }
            if (endTime.IsValid())
            {
                presence.Timestamps.End = endTime.GetDateTime();
            }
        }

        return(presence);
    }