diff --git a/src/Discord.Net.Net45/Discord.Net.csproj b/src/Discord.Net.Net45/Discord.Net.csproj
index d8023d6bd..b26180c07 100644
--- a/src/Discord.Net.Net45/Discord.Net.csproj
+++ b/src/Discord.Net.Net45/Discord.Net.csproj
@@ -256,6 +256,9 @@
API\Client\Rest\DeleteChannel.cs
+
+ API\Client\Rest\DeleteGuild.cs
+
API\Client\Rest\DeleteInvite.cs
diff --git a/src/Discord.Net/API/Client/Rest/DeleteGuild.cs b/src/Discord.Net/API/Client/Rest/DeleteGuild.cs
new file mode 100644
index 000000000..d55c6d989
--- /dev/null
+++ b/src/Discord.Net/API/Client/Rest/DeleteGuild.cs
@@ -0,0 +1,20 @@
+using Newtonsoft.Json;
+
+namespace Discord.API.Client.Rest
+{
+ [JsonObject(MemberSerialization.OptIn)]
+ public class DeleteGuildRequest : IRestRequest
+ {
+ string IRestRequest.Method => "DELETE";
+ string IRestRequest.Endpoint => $"guilds/{GuildId}";
+ object IRestRequest.Payload => null;
+ bool IRestRequest.IsPrivate => false;
+
+ public ulong GuildId { get; set; }
+
+ public DeleteGuildRequest(ulong guildId)
+ {
+ GuildId = guildId;
+ }
+ }
+}
diff --git a/src/Discord.Net/Models/Server.cs b/src/Discord.Net/Models/Server.cs
index 2c0e9f288..7db898804 100644
--- a/src/Discord.Net/Models/Server.cs
+++ b/src/Discord.Net/Models/Server.cs
@@ -208,17 +208,13 @@ namespace Discord
/// Leaves this server. This function will fail if you're the owner - use Delete instead.
public async Task Leave()
{
- if (_ownerId == CurrentUser.Id)
- throw new InvalidOperationException("Unable to leave a server you own, use Server.Delete instead");
try { await Client.ClientAPI.Send(new LeaveGuildRequest(Id)).ConfigureAwait(false); }
catch (HttpException ex) when (ex.StatusCode == HttpStatusCode.NotFound) { }
}
/// Deletes this server. This function will fail if you're not the owner - use Leave instead.
public async Task Delete()
{
- if (_ownerId != CurrentUser.Id)
- throw new InvalidOperationException("Unable to delete a server you don't own, use Server.Leave instead");
- try { await Client.ClientAPI.Send(new LeaveGuildRequest(Id)).ConfigureAwait(false); }
+ try { await Client.ClientAPI.Send(new DeleteGuildRequest(Id)).ConfigureAwait(false); }
catch (HttpException ex) when (ex.StatusCode == HttpStatusCode.NotFound) { }
}