Browse Source

Added GetAFK/Default/Embed/Owner extension methods to IGuild

pull/97/head
RogueException 9 years ago
parent
commit
c072666db5
1 changed files with 19 additions and 0 deletions
  1. +19
    -0
      src/Discord.Net/Extensions/GuildExtensions.cs

+ 19
- 0
src/Discord.Net/Extensions/GuildExtensions.cs View File

@@ -8,5 +8,24 @@ namespace Discord.Extensions
=> await guild.GetChannelAsync(id).ConfigureAwait(false) as ITextChannel; => await guild.GetChannelAsync(id).ConfigureAwait(false) as ITextChannel;
public static async Task<IVoiceChannel> GetVoiceChannelAsync(this IGuild guild, ulong id) public static async Task<IVoiceChannel> GetVoiceChannelAsync(this IGuild guild, ulong id)
=> await guild.GetChannelAsync(id).ConfigureAwait(false) as IVoiceChannel; => await guild.GetChannelAsync(id).ConfigureAwait(false) as IVoiceChannel;

public static async Task<IVoiceChannel> GetAFKChannelAsync(this IGuild guild)
{
var afkId = guild.AFKChannelId;
if (afkId.HasValue)
return await guild.GetChannelAsync(afkId.Value).ConfigureAwait(false) as IVoiceChannel;
return null;
}
public static async Task<ITextChannel> GetDefaultChannelAsync(this IGuild guild)
=> await guild.GetChannelAsync(guild.DefaultChannelId).ConfigureAwait(false) as ITextChannel;
public static async Task<IVoiceChannel> GetEmbedChannelAsync(this IGuild guild)
{
var embedId = guild.EmbedChannelId;
if (embedId.HasValue)
return await guild.GetChannelAsync(embedId.Value).ConfigureAwait(false) as IVoiceChannel;
return null;
}
public static async Task<IGuildUser> GetOwnerAsync(this IGuild guild)
=> await guild.GetUserAsync(guild.OwnerId).ConfigureAwait(false);
} }
} }

Loading…
Cancel
Save