diff --git a/DisCatSharp/Entities/Invite/DiscordInvite.cs b/DisCatSharp/Entities/Invite/DiscordInvite.cs index 59c24c1a3..55acfac3f 100644 --- a/DisCatSharp/Entities/Invite/DiscordInvite.cs +++ b/DisCatSharp/Entities/Invite/DiscordInvite.cs @@ -1,189 +1,195 @@ // This file is part of the DisCatSharp project. // // Copyright (c) 2021 AITSYS // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. using System; using System.Threading.Tasks; using Newtonsoft.Json; using DisCatSharp.Enums.Discord; namespace DisCatSharp.Entities { /// /// Represents a Discord invite. /// public class DiscordInvite { /// /// Gets the base cloent. /// internal BaseDiscordClient Discord { get; set; } /// /// Gets the invite's code. /// [JsonProperty("code", NullValueHandling = NullValueHandling.Ignore)] public string Code { get; internal set; } /// /// Gets the invite's url. /// [JsonIgnore] public string Url => DiscordDomain.GetDomain(CoreDomain.DiscordShortlink).Url + "/" + this.Code; /// /// Gets the invite's url as Uri. /// [JsonIgnore] public Uri Uri => new(this.Url); /// /// Gets the guild this invite is for. /// [JsonProperty("guild", NullValueHandling = NullValueHandling.Ignore)] public DiscordInviteGuild Guild { get; internal set; } /// /// Gets the channel this invite is for. /// [JsonProperty("channel", NullValueHandling = NullValueHandling.Ignore)] public DiscordInviteChannel Channel { get; internal set; } /// /// Gets the target type for the voice channel this invite is for. /// [JsonProperty("target_type", NullValueHandling = NullValueHandling.Ignore)] public TargetType? TargetType { get; internal set; } /// /// Gets the user that is currently livestreaming. /// [JsonProperty("target_user", NullValueHandling = NullValueHandling.Ignore)] public DiscordUser TargetUser { get; internal set; } /// /// Gets the embedded partial application to open for this voice channel. /// [JsonProperty("target_application", NullValueHandling = NullValueHandling.Ignore)] public DiscordApplication TargetApplication { get; internal set; } /// /// Gets the approximate guild online member count for the invite. /// [JsonProperty("approximate_presence_count", NullValueHandling = NullValueHandling.Ignore)] public int? ApproximatePresenceCount { get; internal set; } /// /// Gets the approximate guild total member count for the invite. /// [JsonProperty("approximate_member_count")] public int? ApproximateMemberCount { get; internal set; } /// /// Gets the user who created the invite. /// [JsonProperty("inviter", NullValueHandling = NullValueHandling.Ignore)] public DiscordUser Inviter { get; internal set; } /// /// Gets the number of times this invite has been used. /// [JsonProperty("uses", NullValueHandling = NullValueHandling.Ignore)] public int Uses { get; internal set; } /// /// Gets the max number of times this invite can be used. /// [JsonProperty("max_uses", NullValueHandling = NullValueHandling.Ignore)] public int MaxUses { get; internal set; } /// /// Gets duration in seconds after which the invite expires. /// [JsonProperty("max_age", NullValueHandling = NullValueHandling.Ignore)] public int MaxAge { get; internal set; } /// /// Gets whether this invite only grants temporary membership. /// [JsonProperty("temporary", NullValueHandling = NullValueHandling.Ignore)] public bool IsTemporary { get; internal set; } /// /// Gets the date and time this invite was created. /// [JsonProperty("created_at", NullValueHandling = NullValueHandling.Ignore)] public DateTimeOffset CreatedAt { get; internal set; } /// /// Gets the date and time when this invite expires. /// [JsonProperty("expires_at", NullValueHandling = NullValueHandling.Ignore)] public DateTimeOffset ExpiresAt { get; internal set; } + /// + /// Gets the date and time when this invite got expired. + /// + [JsonProperty("expired_at", NullValueHandling = NullValueHandling.Ignore)] + public DateTimeOffset ExpiredAt { get; internal set; } + /// /// Gets whether this invite is revoked. /// [JsonProperty("revoked", NullValueHandling = NullValueHandling.Ignore)] public bool IsRevoked { get; internal set; } /// /// Gets the stage instance this invite is for. /// [JsonProperty("stage_instance", NullValueHandling = NullValueHandling.Ignore)] public DiscordInviteStage Stage { get; internal set; } /// /// Initializes a new instance of the class. /// internal DiscordInvite() { } /// /// Deletes the invite. /// /// Reason for audit logs. /// /// Thrown when the client does not have the permission or the permission. /// Thrown when the emoji does not exist. /// Thrown when an invalid parameter was provided. /// Thrown when Discord is unable to process the request. public Task DeleteAsync(string reason = null) => this.Discord.ApiClient.DeleteInviteAsync(this.Code, reason); /* * Disabled due to API restrictions. * * /// * /// Accepts an invite. Not available to bot accounts. Requires "guilds.join" scope or user token. Please note that accepting these via the API will get your account unverified. * /// * /// * [Obsolete("Using this method will get your account unverified.")] * public Task AcceptAsync() * => this.Discord._rest_client.InternalAcceptInvite(Code); */ /// /// Converts this invite into an invite link. /// /// A discord.gg invite link. public override string ToString() => $"{DiscordDomain.GetDomain(CoreDomain.DiscordShortlink).Url}/{this.Code}"; } } diff --git a/DisCatSharp/Entities/Invite/DiscordInviteGuild.cs b/DisCatSharp/Entities/Invite/DiscordInviteGuild.cs index 0fd90b89d..282058d44 100644 --- a/DisCatSharp/Entities/Invite/DiscordInviteGuild.cs +++ b/DisCatSharp/Entities/Invite/DiscordInviteGuild.cs @@ -1,116 +1,128 @@ // This file is part of the DisCatSharp project. // // Copyright (c) 2021 AITSYS // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. using System.Collections.Generic; using System.Globalization; using Newtonsoft.Json; using DisCatSharp.Enums.Discord; using DisCatSharp.Net; namespace DisCatSharp.Entities { /// /// Represents a guild to which the user is invited. /// public class DiscordInviteGuild : SnowflakeObject { /// /// Gets the name of the guild. /// [JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)] public string Name { get; internal set; } /// /// Gets the guild icon's hash. /// [JsonProperty("icon", NullValueHandling = NullValueHandling.Ignore)] public string IconHash { get; internal set; } /// /// Gets the guild icon's url. /// [JsonIgnore] public string IconUrl => !string.IsNullOrWhiteSpace(this.IconHash) ? $"{DiscordDomain.GetDomain(CoreDomain.DiscordCdn).Url}{Endpoints.ICONS}/{this.Id.ToString(CultureInfo.InvariantCulture)}/{this.IconHash}.jpg" : null; /// /// Gets the hash of guild's invite splash. /// [JsonProperty("splash", NullValueHandling = NullValueHandling.Ignore)] internal string SplashHash { get; set; } /// /// Gets the URL of guild's invite splash. /// [JsonIgnore] public string SplashUrl => !string.IsNullOrWhiteSpace(this.SplashHash) ? $"{DiscordDomain.GetDomain(CoreDomain.DiscordCdn).Url}{Endpoints.SPLASHES}/{this.Id.ToString(CultureInfo.InvariantCulture)}/{this.SplashHash}.jpg" : null; /// /// Gets the guild's banner hash, when applicable. /// [JsonProperty("banner", NullValueHandling = NullValueHandling.Ignore)] public string Banner { get; internal set; } /// /// Gets the guild's banner in url form. /// [JsonIgnore] public string BannerUrl => !string.IsNullOrWhiteSpace(this.Banner) ? $"{DiscordDomain.GetDomain(CoreDomain.DiscordCdn).Url}{Endpoints.BANNERS}/{this.Id}/{this.Banner}" : null; /// /// Gets the guild description, when applicable. /// [JsonProperty("description", NullValueHandling = NullValueHandling.Ignore)] public string Description { get; internal set; } /// /// Gets a collection of this guild's features. /// [JsonProperty("features", NullValueHandling = NullValueHandling.Ignore)] public IReadOnlyList Features { get; internal set; } /// /// Gets the guild's verification level. /// [JsonProperty("verification_level", NullValueHandling = NullValueHandling.Ignore)] public VerificationLevel VerificationLevel { get; internal set; } /// /// Gets vanity URL code for this guild, when applicable. /// [JsonProperty("vanity_url_code")] public string VanityUrlCode { get; internal set; } /// /// Gets the guild's welcome screen, when applicable. /// [JsonProperty("welcome_screen", NullValueHandling = NullValueHandling.Ignore)] public DiscordGuildWelcomeScreen WelcomeScreen { get; internal set; } + /// + /// Gets the guild nsfw status. + /// + [JsonProperty("nsfw", NullValueHandling = NullValueHandling.Ignore)] + public bool IsNsfw { get; internal set; } + + /// + /// Gets the guild nsfw level. + /// + [JsonProperty("nsfw_level", NullValueHandling = NullValueHandling.Ignore)] + public NsfwLevel NsfwLevel { get; internal set; } + /// /// Initializes a new instance of the class. /// internal DiscordInviteGuild() { } } }