Added IGuild.IsOwner, cleaned a few exceptions
This commit is contained in:
@@ -11,6 +11,8 @@ namespace Discord
|
||||
int AFKTimeout { get; }
|
||||
/// <summary> Returns true if this guild is embeddable (e.g. widget) </summary>
|
||||
bool IsEmbeddable { get; }
|
||||
/// <summary> Returns true if the current user owns this guild. </summary>
|
||||
bool IsOwner { get; }
|
||||
/// <summary> Gets the name of this guild. </summary>
|
||||
string Name { get; }
|
||||
int VerificationLevel { get; }
|
||||
|
||||
@@ -46,6 +46,8 @@ namespace Discord.Rest
|
||||
/// <inheritdoc />
|
||||
public DateTime CreatedAt => DateTimeHelper.FromSnowflake(Id);
|
||||
/// <inheritdoc />
|
||||
public bool IsOwner => OwnerId == Discord.CurrentUser.Id;
|
||||
/// <inheritdoc />
|
||||
public string IconUrl => API.CDN.GetGuildIconUrl(Id, _iconId);
|
||||
/// <inheritdoc />
|
||||
public string SplashUrl => API.CDN.GetGuildSplashUrl(Id, _splashId);
|
||||
@@ -155,11 +157,15 @@ namespace Discord.Rest
|
||||
/// <inheritdoc />
|
||||
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);
|
||||
}
|
||||
/// <inheritdoc />
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
/// <inheritdoc />
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user