diff --git a/src/Discord.Net/Common/Entities/Channels/IGuildChannel.cs b/src/Discord.Net/Common/Entities/Channels/IGuildChannel.cs
index 456f6931e..0a6cf2f1b 100644
--- a/src/Discord.Net/Common/Entities/Channels/IGuildChannel.cs
+++ b/src/Discord.Net/Common/Entities/Channels/IGuildChannel.cs
@@ -20,9 +20,9 @@ namespace Discord
/// The max amount of times this invite may be used. Set to null to have unlimited uses.
/// If true, a user accepting this invite will be kicked from the guild after closing their client.
/// If true, creates a human-readable link. Not supported if maxAge is set to null.
- Task CreateInvite(int? maxAge = 1800, int? maxUses = default(int?), bool isTemporary = false, bool withXkcd = false);
+ Task CreateInvite(int? maxAge = 1800, int? maxUses = default(int?), bool isTemporary = false, bool withXkcd = false);
/// Returns a collection of all invites to this channel.
- Task> GetInvites();
+ Task> GetInvites();
/// Gets a collection of permission overwrites for this channel.
IReadOnlyDictionary PermissionOverwrites { get; }
diff --git a/src/Discord.Net/Common/Entities/Guilds/IGuild.cs b/src/Discord.Net/Common/Entities/Guilds/IGuild.cs
index 9d6518612..2fc618196 100644
--- a/src/Discord.Net/Common/Entities/Guilds/IGuild.cs
+++ b/src/Discord.Net/Common/Entities/Guilds/IGuild.cs
@@ -70,13 +70,13 @@ namespace Discord
Task CreateVoiceChannel(string name);
/// Gets a collection of all invites to this guild.
- Task> GetInvites();
+ Task> GetInvites();
/// Creates a new invite to this guild.
/// The time (in seconds) until the invite expires. Set to null to never expire.
/// The max amount of times this invite may be used. Set to null to have unlimited uses.
/// If true, a user accepting this invite will be kicked from the guild after closing their client.
/// If true, creates a human-readable link. Not supported if maxAge is set to null.
- Task CreateInvite(int? maxAge = 1800, int? maxUses = default(int?), bool isTemporary = false, bool withXkcd = false);
+ Task CreateInvite(int? maxAge = 1800, int? maxUses = default(int?), bool isTemporary = false, bool withXkcd = false);
/// Gets a collection of all roles in this guild.
Task> GetRoles();
diff --git a/src/Discord.Net/Common/Entities/Invites/IGuildInvite.cs b/src/Discord.Net/Common/Entities/Invites/IInviteMetadata.cs
similarity index 81%
rename from src/Discord.Net/Common/Entities/Invites/IGuildInvite.cs
rename to src/Discord.Net/Common/Entities/Invites/IInviteMetadata.cs
index 25e6d0e80..9e68b8a82 100644
--- a/src/Discord.Net/Common/Entities/Invites/IGuildInvite.cs
+++ b/src/Discord.Net/Common/Entities/Invites/IInviteMetadata.cs
@@ -1,6 +1,6 @@
namespace Discord
{
- public interface IGuildInvite : IDeletable, IInvite
+ public interface IInviteMetadata : IDeletable, IInvite
{
/// Returns true if this invite was revoked.
bool IsRevoked { get; }
@@ -12,8 +12,5 @@
int? MaxUses { get; }
/// Gets the amount of times this invite has been used.
int Uses { get; }
-
- /// Gets the guild this invite is linked to.
- IGuild Guild { get; }
}
}
\ No newline at end of file
diff --git a/src/Discord.Net/Common/Entities/Invites/IPublicInvite.cs b/src/Discord.Net/Common/Entities/Invites/IPublicInvite.cs
deleted file mode 100644
index 1d518bd0a..000000000
--- a/src/Discord.Net/Common/Entities/Invites/IPublicInvite.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Discord
-{
- public interface IPublicInvite : IInvite
- {
- /// Gets the name of the the channel this invite is linked to.
- string ChannelName { get; }
- /// Gets the name of the guild this invite is linked to.
- string GuildName { get; }
- }
-}
\ No newline at end of file
diff --git a/src/Discord.Net/Common/Entities/Invites/Invite.cs b/src/Discord.Net/Common/Entities/Invites/Invite.cs
index 9ea98fd18..feae2119e 100644
--- a/src/Discord.Net/Common/Entities/Invites/Invite.cs
+++ b/src/Discord.Net/Common/Entities/Invites/Invite.cs
@@ -3,33 +3,43 @@ using Model = Discord.API.Invite;
namespace Discord
{
- public abstract class Invite : IInvite
+ public class Invite : IInvite
{
- protected ulong _guildId, _channelId;
-
///
public string Code { get; }
+ internal IDiscordClient Discord { get; }
+
+ ///
+ public ulong GuildId { get; private set; }
+ ///
+ public ulong ChannelId { get; private set; }
+ ///
+ public string XkcdCode { get; private set; }
+ ///
+ public string GuildName { get; private set; }
///
- public string XkcdCode { get; }
+ public string ChannelName { get; private set; }
///
public string Url => $"{DiscordConfig.InviteUrl}/{XkcdCode ?? Code}";
///
public string XkcdUrl => XkcdCode != null ? $"{DiscordConfig.InviteUrl}/{XkcdCode}" : null;
- internal abstract IDiscordClient Discord { get; }
- internal Invite(Model model)
+ internal Invite(IDiscordClient discord, Model model)
{
+ Discord = discord;
Code = model.Code;
- XkcdCode = model.XkcdPass;
Update(model);
}
protected virtual void Update(Model model)
{
- _guildId = model.Guild.Id;
- _channelId = model.Channel.Id;
+ XkcdCode = model.XkcdPass;
+ GuildId = model.Guild.Id;
+ ChannelId = model.Channel.Id;
+ GuildName = model.Guild.Name;
+ ChannelName = model.Channel.Name;
}
///
@@ -38,11 +48,15 @@ namespace Discord
await Discord.BaseClient.AcceptInvite(Code).ConfigureAwait(false);
}
+ ///
+ public async Task Delete()
+ {
+ await Discord.BaseClient.DeleteInvite(Code).ConfigureAwait(false);
+ }
+
///
public override string ToString() => XkcdUrl ?? Url;
string IEntity.Id => Code;
- ulong IInvite.GuildId => _guildId;
- ulong IInvite.ChannelId => _channelId;
}
}
diff --git a/src/Discord.Net/Common/Entities/Invites/InviteMetadata.cs b/src/Discord.Net/Common/Entities/Invites/InviteMetadata.cs
new file mode 100644
index 000000000..61f353ebd
--- /dev/null
+++ b/src/Discord.Net/Common/Entities/Invites/InviteMetadata.cs
@@ -0,0 +1,32 @@
+using Model = Discord.API.InviteMetadata;
+
+namespace Discord
+{
+ public class InviteMetadata : Invite, IInviteMetadata
+ {
+ ///
+ public bool IsRevoked { get; private set; }
+ ///
+ public bool IsTemporary { get; private set; }
+ ///
+ public int? MaxAge { get; private set; }
+ ///
+ public int? MaxUses { get; private set; }
+ ///
+ public int Uses { get; private set; }
+
+ internal InviteMetadata(IDiscordClient client, Model model)
+ : base(client, model)
+ {
+ Update(model);
+ }
+ private void Update(Model model)
+ {
+ IsRevoked = model.Revoked;
+ IsTemporary = model.Temporary;
+ MaxAge = model.MaxAge != 0 ? model.MaxAge : (int?)null;
+ MaxUses = model.MaxUses;
+ Uses = model.Uses;
+ }
+ }
+}
diff --git a/src/Discord.Net/Common/Entities/Invites/PublicInvite.cs b/src/Discord.Net/Common/Entities/Invites/PublicInvite.cs
deleted file mode 100644
index 3a2f42394..000000000
--- a/src/Discord.Net/Common/Entities/Invites/PublicInvite.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System.Threading.Tasks;
-using Model = Discord.API.Invite;
-
-namespace Discord.Rest
-{
- public class PublicInvite : Invite, IPublicInvite
- {
- ///
- public string GuildName { get; private set; }
- ///
- public string ChannelName { get; private set; }
-
- ///
- public ulong GuildId => _guildId;
- ///
- public ulong ChannelId => _channelId;
-
- internal override IDiscordClient Discord { get; }
-
- internal PublicInvite(IDiscordClient discord, Model model)
- : base(model)
- {
- Discord = discord;
- }
- protected override void Update(Model model)
- {
- base.Update(model);
- GuildName = model.Guild.Name;
- ChannelName = model.Channel.Name;
- }
-
- ///
- public async Task Update()
- {
- var model = await Discord.BaseClient.GetInvite(Code).ConfigureAwait(false);
- Update(model);
- }
- }
-}
diff --git a/src/Discord.Net/Discord.Net.csproj b/src/Discord.Net/Discord.Net.csproj
index 0c5742f1c..af5ce3e12 100644
--- a/src/Discord.Net/Discord.Net.csproj
+++ b/src/Discord.Net/Discord.Net.csproj
@@ -118,7 +118,6 @@
-
@@ -139,7 +138,7 @@
-
+
@@ -168,9 +167,7 @@
-
-
@@ -217,7 +214,7 @@
-
+
diff --git a/src/Discord.Net/IDiscordClient.cs b/src/Discord.Net/IDiscordClient.cs
index 4d12632cd..068f56bff 100644
--- a/src/Discord.Net/IDiscordClient.cs
+++ b/src/Discord.Net/IDiscordClient.cs
@@ -27,7 +27,7 @@ namespace Discord
Task> GetGuilds();
Task CreateGuild(string name, IVoiceRegion region, Stream jpegIcon = null);
- Task GetInvite(string inviteIdOrXkcd);
+ Task GetInvite(string inviteIdOrXkcd);
Task GetUser(ulong id);
Task GetUser(string username, ushort discriminator);
diff --git a/src/Discord.Net/Rest/DiscordClient.cs b/src/Discord.Net/Rest/DiscordClient.cs
index 504ff86f9..f57f9694c 100644
--- a/src/Discord.Net/Rest/DiscordClient.cs
+++ b/src/Discord.Net/Rest/DiscordClient.cs
@@ -168,11 +168,11 @@ namespace Discord.Rest
return models.Select(x => new DMChannel(this, x));
}
- public async Task GetInvite(string inviteIdOrXkcd)
+ public async Task GetInvite(string inviteIdOrXkcd)
{
var model = await BaseClient.GetInvite(inviteIdOrXkcd).ConfigureAwait(false);
if (model != null)
- return new PublicInvite(this, model);
+ return new Invite(this, model);
return null;
}
@@ -269,7 +269,7 @@ namespace Discord.Rest
=> await GetDMChannels().ConfigureAwait(false);
async Task> IDiscordClient.GetConnections()
=> await GetConnections().ConfigureAwait(false);
- async Task IDiscordClient.GetInvite(string inviteIdOrXkcd)
+ async Task IDiscordClient.GetInvite(string inviteIdOrXkcd)
=> await GetInvite(inviteIdOrXkcd).ConfigureAwait(false);
async Task IDiscordClient.GetGuild(ulong id)
=> await GetGuild(id).ConfigureAwait(false);
diff --git a/src/Discord.Net/Rest/Entities/Channels/GuildChannel.cs b/src/Discord.Net/Rest/Entities/Channels/GuildChannel.cs
index c06cb8e70..635709948 100644
--- a/src/Discord.Net/Rest/Entities/Channels/GuildChannel.cs
+++ b/src/Discord.Net/Rest/Entities/Channels/GuildChannel.cs
@@ -81,10 +81,10 @@ namespace Discord.Rest
return null;
}
/// Downloads a collection of all invites to this channel.
- public async Task> GetInvites()
+ public async Task> GetInvites()
{
var models = await Discord.BaseClient.GetChannelInvites(Id).ConfigureAwait(false);
- return models.Select(x => new GuildInvite(Guild, x));
+ return models.Select(x => new InviteMetadata(Discord, x));
}
///
@@ -123,7 +123,7 @@ namespace Discord.Rest
/// The max amount of times this invite may be used. Set to null to have unlimited uses.
/// If true, a user accepting this invite will be kicked from the guild after closing their client.
/// If true, creates a human-readable link. Not supported if maxAge is set to null.
- public async Task CreateInvite(int? maxAge = 1800, int? maxUses = null, bool isTemporary = false, bool withXkcd = false)
+ public async Task CreateInvite(int? maxAge = 1800, int? maxUses = null, bool isTemporary = false, bool withXkcd = false)
{
var args = new CreateChannelInviteParams
{
@@ -133,7 +133,7 @@ namespace Discord.Rest
XkcdPass = withXkcd
};
var model = await Discord.BaseClient.CreateChannelInvite(Id, args).ConfigureAwait(false);
- return new GuildInvite(Guild, model);
+ return new InviteMetadata(Discord, model);
}
///
@@ -149,9 +149,9 @@ namespace Discord.Rest
}
IGuild IGuildChannel.Guild => Guild;
- async Task IGuildChannel.CreateInvite(int? maxAge, int? maxUses, bool isTemporary, bool withXkcd)
+ async Task IGuildChannel.CreateInvite(int? maxAge, int? maxUses, bool isTemporary, bool withXkcd)
=> await CreateInvite(maxAge, maxUses, isTemporary, withXkcd).ConfigureAwait(false);
- async Task> IGuildChannel.GetInvites()
+ async Task> IGuildChannel.GetInvites()
=> await GetInvites().ConfigureAwait(false);
async Task> IGuildChannel.GetUsers()
=> await GetUsers().ConfigureAwait(false);
diff --git a/src/Discord.Net/Rest/Entities/Guilds/Guild.cs b/src/Discord.Net/Rest/Entities/Guilds/Guild.cs
index 055c91bd4..c1ee23236 100644
--- a/src/Discord.Net/Rest/Entities/Guilds/Guild.cs
+++ b/src/Discord.Net/Rest/Entities/Guilds/Guild.cs
@@ -231,13 +231,13 @@ namespace Discord.Rest
}
/// Gets a collection of all invites to this guild.
- public async Task> GetInvites()
+ public async Task> GetInvites()
{
var models = await Discord.BaseClient.GetGuildInvites(Id).ConfigureAwait(false);
- return models.Select(x => new GuildInvite(this, x));
+ return models.Select(x => new InviteMetadata(Discord, x));
}
/// Creates a new invite to this guild.
- public async Task CreateInvite(int? maxAge = 1800, int? maxUses = null, bool isTemporary = false, bool withXkcd = false)
+ public async Task CreateInvite(int? maxAge = 1800, int? maxUses = null, bool isTemporary = false, bool withXkcd = false)
{
if (maxAge <= 0) throw new ArgumentOutOfRangeException(nameof(maxAge));
if (maxUses <= 0) throw new ArgumentOutOfRangeException(nameof(maxUses));
@@ -250,7 +250,7 @@ namespace Discord.Rest
XkcdPass = withXkcd
};
var model = await Discord.BaseClient.CreateChannelInvite(DefaultChannelId, args).ConfigureAwait(false);
- return new GuildInvite(this, model);
+ return new InviteMetadata(Discord, model);
}
/// Gets the role in this guild with the provided id, or null if not found.
@@ -344,7 +344,7 @@ namespace Discord.Rest
=> await GetChannel(id).ConfigureAwait(false);
async Task> IGuild.GetChannels()
=> await GetChannels().ConfigureAwait(false);
- async Task IGuild.CreateInvite(int? maxAge, int? maxUses, bool isTemporary, bool withXkcd)
+ async Task IGuild.CreateInvite(int? maxAge, int? maxUses, bool isTemporary, bool withXkcd)
=> await CreateInvite(maxAge, maxUses, isTemporary, withXkcd).ConfigureAwait(false);
async Task IGuild.CreateRole(string name, GuildPermissions? permissions, Color? color, bool isHoisted)
=> await CreateRole(name, permissions, color, isHoisted).ConfigureAwait(false);
@@ -352,7 +352,7 @@ namespace Discord.Rest
=> await CreateTextChannel(name).ConfigureAwait(false);
async Task IGuild.CreateVoiceChannel(string name)
=> await CreateVoiceChannel(name).ConfigureAwait(false);
- async Task> IGuild.GetInvites()
+ async Task> IGuild.GetInvites()
=> await GetInvites().ConfigureAwait(false);
Task IGuild.GetRole(ulong id)
=> Task.FromResult(GetRole(id));
diff --git a/src/Discord.Net/Rest/Entities/Invites/GuildInvite.cs b/src/Discord.Net/Rest/Entities/Invites/GuildInvite.cs
deleted file mode 100644
index 71b0541e2..000000000
--- a/src/Discord.Net/Rest/Entities/Invites/GuildInvite.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System.Threading.Tasks;
-using Model = Discord.API.InviteMetadata;
-
-namespace Discord.Rest
-{
- public class GuildInvite : Invite, IGuildInvite
- {
- /// Gets the guild this invite is linked to.
- public Guild Guild { get; private set; }
- ///
- public ulong ChannelId { get; private set; }
-
- ///
- public bool IsRevoked { get; private set; }
- ///
- public bool IsTemporary { get; private set; }
- ///
- public int? MaxAge { get; private set; }
- ///
- public int? MaxUses { get; private set; }
- ///
- public int Uses { get; private set; }
-
- internal override IDiscordClient Discord => Guild.Discord;
-
- internal GuildInvite(Guild guild, Model model)
- : base(model)
- {
- Guild = guild;
-
- Update(model); //Causes base.Update(Model) to be run twice, but that's fine.
- }
- private void Update(Model model)
- {
- base.Update(model);
- IsRevoked = model.Revoked;
- IsTemporary = model.Temporary;
- MaxAge = model.MaxAge != 0 ? model.MaxAge : (int?)null;
- MaxUses = model.MaxUses;
- Uses = model.Uses;
- }
-
- ///
- public async Task Delete()
- {
- await Discord.BaseClient.DeleteInvite(Code).ConfigureAwait(false);
- }
-
- IGuild IGuildInvite.Guild => Guild;
- ulong IInvite.GuildId => Guild.Id;
- }
-}
diff --git a/src/Discord.Net/WebSocket/DiscordClient.cs b/src/Discord.Net/WebSocket/DiscordClient.cs
index 4032a5539..0af5cceb9 100644
--- a/src/Discord.Net/WebSocket/DiscordClient.cs
+++ b/src/Discord.Net/WebSocket/DiscordClient.cs
@@ -86,7 +86,7 @@ namespace Discord.WebSocket
throw new NotImplementedException();
}
- public Task GetInvite(string inviteIdOrXkcd)
+ public Task GetInvite(string inviteIdOrXkcd)
{
throw new NotImplementedException();
}
diff --git a/src/Discord.Net/WebSocket/Entities/Channels/GuildChannel.cs b/src/Discord.Net/WebSocket/Entities/Channels/GuildChannel.cs
index c3a895b28..7f33e1eae 100644
--- a/src/Discord.Net/WebSocket/Entities/Channels/GuildChannel.cs
+++ b/src/Discord.Net/WebSocket/Entities/Channels/GuildChannel.cs
@@ -80,10 +80,10 @@ namespace Discord.WebSocket
return null;
}
/// Downloads a collection of all invites to this channel.
- public async Task> GetInvites()
+ public async Task> GetInvites()
{
var models = await Discord.BaseClient.GetChannelInvites(Id).ConfigureAwait(false);
- return models.Select(x => new GuildInvite(Guild, x));
+ return models.Select(x => new InviteMetadata(Discord, x));
}
///
@@ -114,7 +114,7 @@ namespace Discord.WebSocket
/// The max amount of times this invite may be used. Set to null to have unlimited uses.
/// If true, a user accepting this invite will be kicked from the guild after closing their client.
/// If true, creates a human-readable link. Not supported if maxAge is set to null.
- public async Task CreateInvite(int? maxAge = 1800, int? maxUses = null, bool isTemporary = false, bool withXkcd = false)
+ public async Task CreateInvite(int? maxAge = 1800, int? maxUses = null, bool isTemporary = false, bool withXkcd = false)
{
var args = new CreateChannelInviteParams
{
@@ -124,7 +124,7 @@ namespace Discord.WebSocket
XkcdPass = withXkcd
};
var model = await Discord.BaseClient.CreateChannelInvite(Id, args).ConfigureAwait(false);
- return new GuildInvite(Guild, model);
+ return new InviteMetadata(Discord, model);
}
///
@@ -134,9 +134,9 @@ namespace Discord.WebSocket
}
IGuild IGuildChannel.Guild => Guild;
- async Task IGuildChannel.CreateInvite(int? maxAge, int? maxUses, bool isTemporary, bool withXkcd)
+ async Task IGuildChannel.CreateInvite(int? maxAge, int? maxUses, bool isTemporary, bool withXkcd)
=> await CreateInvite(maxAge, maxUses, isTemporary, withXkcd).ConfigureAwait(false);
- async Task> IGuildChannel.GetInvites()
+ async Task> IGuildChannel.GetInvites()
=> await GetInvites().ConfigureAwait(false);
Task> IGuildChannel.GetUsers()
=> Task.FromResult>(Users);
diff --git a/src/Discord.Net/WebSocket/Entities/Guilds/Guild.cs b/src/Discord.Net/WebSocket/Entities/Guilds/Guild.cs
index 3f68395d6..fa5bba1c0 100644
--- a/src/Discord.Net/WebSocket/Entities/Guilds/Guild.cs
+++ b/src/Discord.Net/WebSocket/Entities/Guilds/Guild.cs
@@ -224,13 +224,13 @@ namespace Discord.WebSocket
}
/// Gets a collection of all invites to this guild.
- public async Task> GetInvites()
+ public async Task> GetInvites()
{
var models = await Discord.BaseClient.GetGuildInvites(Id).ConfigureAwait(false);
- return models.Select(x => new GuildInvite(this, x));
+ return models.Select(x => new InviteMetadata(Discord, x));
}
/// Creates a new invite to this guild.
- public async Task CreateInvite(int? maxAge = 1800, int? maxUses = null, bool isTemporary = false, bool withXkcd = false)
+ public async Task CreateInvite(int? maxAge = 1800, int? maxUses = null, bool isTemporary = false, bool withXkcd = false)
{
if (maxAge <= 0) throw new ArgumentOutOfRangeException(nameof(maxAge));
if (maxUses <= 0) throw new ArgumentOutOfRangeException(nameof(maxUses));
@@ -243,7 +243,7 @@ namespace Discord.WebSocket
XkcdPass = withXkcd
};
var model = await Discord.BaseClient.CreateChannelInvite(DefaultChannelId, args).ConfigureAwait(false);
- return new GuildInvite(this, model);
+ return new InviteMetadata(Discord, model);
}
/// Gets the role in this guild with the provided id, or null if not found.
@@ -337,7 +337,7 @@ namespace Discord.WebSocket
=> await GetChannel(id).ConfigureAwait(false);
async Task> IGuild.GetChannels()
=> await GetChannels().ConfigureAwait(false);
- async Task IGuild.CreateInvite(int? maxAge, int? maxUses, bool isTemporary, bool withXkcd)
+ async Task IGuild.CreateInvite(int? maxAge, int? maxUses, bool isTemporary, bool withXkcd)
=> await CreateInvite(maxAge, maxUses, isTemporary, withXkcd).ConfigureAwait(false);
async Task IGuild.CreateRole(string name, GuildPermissions? permissions, Color? color, bool isHoisted)
=> await CreateRole(name, permissions, color, isHoisted).ConfigureAwait(false);
@@ -345,7 +345,7 @@ namespace Discord.WebSocket
=> await CreateTextChannel(name).ConfigureAwait(false);
async Task IGuild.CreateVoiceChannel(string name)
=> await CreateVoiceChannel(name).ConfigureAwait(false);
- async Task> IGuild.GetInvites()
+ async Task> IGuild.GetInvites()
=> await GetInvites().ConfigureAwait(false);
Task IGuild.GetRole(ulong id)
=> Task.FromResult(GetRole(id));
diff --git a/src/Discord.Net/WebSocket/Entities/Invites/GuildInvite.cs b/src/Discord.Net/WebSocket/Entities/Invites/GuildInvite.cs
deleted file mode 100644
index c78c7a9e9..000000000
--- a/src/Discord.Net/WebSocket/Entities/Invites/GuildInvite.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System.Threading.Tasks;
-using Model = Discord.API.InviteMetadata;
-
-namespace Discord.WebSocket
-{
- public class GuildInvite : Invite, IGuildInvite
- {
- /// Gets the guild this invite is linked to.
- public Guild Guild { get; private set; }
- ///
- public ulong ChannelId { get; private set; }
-
- ///
- public bool IsRevoked { get; private set; }
- ///
- public bool IsTemporary { get; private set; }
- ///
- public int? MaxAge { get; private set; }
- ///
- public int? MaxUses { get; private set; }
- ///
- public int Uses { get; private set; }
-
- internal override IDiscordClient Discord => Guild.Discord;
-
- internal GuildInvite(Guild guild, Model model)
- : base(model)
- {
- Guild = guild;
-
- Update(model); //Causes base.Update(Model) to be run twice, but that's fine.
- }
- private void Update(Model model)
- {
- base.Update(model);
- IsRevoked = model.Revoked;
- IsTemporary = model.Temporary;
- MaxAge = model.MaxAge != 0 ? model.MaxAge : (int?)null;
- MaxUses = model.MaxUses;
- Uses = model.Uses;
- }
-
- ///
- public async Task Delete()
- {
- await Discord.BaseClient.DeleteInvite(Code).ConfigureAwait(false);
- }
-
- IGuild IGuildInvite.Guild => Guild;
- ulong IInvite.GuildId => Guild.Id;
- }
-}