Changed Guild#DefaultChannel to resolve the first accessible channel (#777)
* Changed Guild#DefaultChannel to resolve the first accessible channel Resolves #776 This change is inline with hammerandchisel/discord-api-docs#329 RestGuild#DefaultChannelId is now obsolete and will throw a NotSupportedException. * RestGuild#DefaultChannelId will fall back to the guild ID Adding an exception here would be a breaking change, so this was agreed to fall back to the previous behavior, which would just return the guild ID.
This commit is contained in:
@@ -33,6 +33,8 @@ namespace Discord.Rest
|
||||
internal bool Available { get; private set; }
|
||||
|
||||
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
|
||||
|
||||
[Obsolete("DefaultChannelId is deprecated, use GetDefaultChannelAsync")]
|
||||
public ulong DefaultChannelId => Id;
|
||||
public string IconUrl => CDN.GetGuildIconUrl(Id, IconId);
|
||||
public string SplashUrl => CDN.GetGuildSplashUrl(Id, SplashId);
|
||||
@@ -185,8 +187,12 @@ namespace Discord.Rest
|
||||
}
|
||||
public async Task<RestTextChannel> GetDefaultChannelAsync(RequestOptions options = null)
|
||||
{
|
||||
var channel = await GuildHelper.GetChannelAsync(this, Discord, DefaultChannelId, options).ConfigureAwait(false);
|
||||
return channel as RestTextChannel;
|
||||
var channels = await GetTextChannelsAsync(options).ConfigureAwait(false);
|
||||
var user = await GetCurrentUserAsync(options).ConfigureAwait(false);
|
||||
return channels
|
||||
.Where(c => user.GetPermissions(c).ReadMessages)
|
||||
.OrderBy(c => c.Position)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
public async Task<RestGuildChannel> GetEmbedChannelAsync(RequestOptions options = null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user