diff --git a/src/Discord.Net/Common/Entities/Guilds/IGuild.cs b/src/Discord.Net/Common/Entities/Guilds/IGuild.cs
index 2c3d8a3c8..16db2c0e3 100644
--- a/src/Discord.Net/Common/Entities/Guilds/IGuild.cs
+++ b/src/Discord.Net/Common/Entities/Guilds/IGuild.cs
@@ -11,6 +11,8 @@ namespace Discord
int AFKTimeout { get; }
/// Returns true if this guild is embeddable (e.g. widget)
bool IsEmbeddable { get; }
+ /// Returns true if the current user owns this guild.
+ bool IsOwner { get; }
/// Gets the name of this guild.
string Name { get; }
int VerificationLevel { get; }
diff --git a/src/Discord.Net/Rest/Entities/Guilds/Guild.cs b/src/Discord.Net/Rest/Entities/Guilds/Guild.cs
index 481a8d884..60170d0fa 100644
--- a/src/Discord.Net/Rest/Entities/Guilds/Guild.cs
+++ b/src/Discord.Net/Rest/Entities/Guilds/Guild.cs
@@ -46,6 +46,8 @@ namespace Discord.Rest
///
public DateTime CreatedAt => DateTimeHelper.FromSnowflake(Id);
///
+ public bool IsOwner => OwnerId == Discord.CurrentUser.Id;
+ ///
public string IconUrl => API.CDN.GetGuildIconUrl(Id, _iconId);
///
public string SplashUrl => API.CDN.GetGuildSplashUrl(Id, _splashId);
@@ -155,11 +157,15 @@ namespace Discord.Rest
///
public async Task Leave()
{
+ if (IsOwner)
+ throw new InvalidOperationException("Unable to leave a guild the current user owns.");
await Discord.BaseClient.LeaveGuild(Id).ConfigureAwait(false);
}
///
public async Task Delete()
{
+ if (!IsOwner)
+ throw new InvalidOperationException("Unable to delete a guild the current user does not own.");
await Discord.BaseClient.DeleteGuild(Id).ConfigureAwait(false);
}
diff --git a/src/Discord.Net/Rest/Entities/Guilds/UserGuild.cs b/src/Discord.Net/Rest/Entities/Guilds/UserGuild.cs
index d278b6341..cae71f5ae 100644
--- a/src/Discord.Net/Rest/Entities/Guilds/UserGuild.cs
+++ b/src/Discord.Net/Rest/Entities/Guilds/UserGuild.cs
@@ -41,14 +41,14 @@ namespace Discord.Rest
public async Task Leave()
{
if (IsOwner)
- throw new InvalidOperationException("Unable to leave a guild the current user owns, use Delete() instead.");
+ throw new InvalidOperationException("Unable to leave a guild the current user owns.");
await Discord.BaseClient.LeaveGuild(Id).ConfigureAwait(false);
}
///
public async Task Delete()
{
if (!IsOwner)
- throw new InvalidOperationException("Unable to leave a guild the current user owns, use Delete() instead.");
+ throw new InvalidOperationException("Unable to delete a guild the current user does not own.");
await Discord.BaseClient.DeleteGuild(Id).ConfigureAwait(false);
}