|
@@ -1,24 +1,31 @@ |
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
|
using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
|
|
namespace Discord |
|
|
namespace Discord |
|
|
{ |
|
|
{ |
|
|
|
|
|
/// <summary> Extensions for <see cref="IDiscordClient"/>. </summary> |
|
|
public static class DiscordClientExtensions |
|
|
public static class DiscordClientExtensions |
|
|
{ |
|
|
{ |
|
|
|
|
|
/// <summary> Gets the private channel with the provided ID. </summary> |
|
|
public static async Task<IPrivateChannel> GetPrivateChannelAsync(this IDiscordClient client, ulong id) |
|
|
public static async Task<IPrivateChannel> GetPrivateChannelAsync(this IDiscordClient client, ulong id) |
|
|
=> await client.GetChannelAsync(id).ConfigureAwait(false) as IPrivateChannel; |
|
|
=> await client.GetChannelAsync(id).ConfigureAwait(false) as IPrivateChannel; |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> Gets the DM channel with the provided ID. </summary> |
|
|
public static async Task<IDMChannel> GetDMChannelAsync(this IDiscordClient client, ulong id) |
|
|
public static async Task<IDMChannel> GetDMChannelAsync(this IDiscordClient client, ulong id) |
|
|
=> await client.GetPrivateChannelAsync(id).ConfigureAwait(false) as IDMChannel; |
|
|
=> await client.GetPrivateChannelAsync(id).ConfigureAwait(false) as IDMChannel; |
|
|
|
|
|
/// <summary> Gets all available DM channels for the client. </summary> |
|
|
public static async Task<IEnumerable<IDMChannel>> GetDMChannelsAsync(this IDiscordClient client) |
|
|
public static async Task<IEnumerable<IDMChannel>> GetDMChannelsAsync(this IDiscordClient client) |
|
|
=> (await client.GetPrivateChannelsAsync().ConfigureAwait(false)).Select(x => x as IDMChannel).Where(x => x != null); |
|
|
=> (await client.GetPrivateChannelsAsync().ConfigureAwait(false)).Select(x => x as IDMChannel).Where(x => x != null); |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> Gets the group channel with the provided ID. </summary> |
|
|
public static async Task<IGroupChannel> GetGroupChannelAsync(this IDiscordClient client, ulong id) |
|
|
public static async Task<IGroupChannel> GetGroupChannelAsync(this IDiscordClient client, ulong id) |
|
|
=> await client.GetPrivateChannelAsync(id).ConfigureAwait(false) as IGroupChannel; |
|
|
=> await client.GetPrivateChannelAsync(id).ConfigureAwait(false) as IGroupChannel; |
|
|
|
|
|
/// <summary> Gets all available group channels for the client. </summary> |
|
|
public static async Task<IEnumerable<IGroupChannel>> GetGroupChannelsAsync(this IDiscordClient client) |
|
|
public static async Task<IEnumerable<IGroupChannel>> GetGroupChannelsAsync(this IDiscordClient client) |
|
|
=> (await client.GetPrivateChannelsAsync().ConfigureAwait(false)).Select(x => x as IGroupChannel).Where(x => x != null); |
|
|
=> (await client.GetPrivateChannelsAsync().ConfigureAwait(false)).Select(x => x as IGroupChannel).Where(x => x != null); |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> Gets the most optimal voice region for the client. </summary> |
|
|
public static async Task<IVoiceRegion> GetOptimalVoiceRegionAsync(this IDiscordClient discord) |
|
|
public static async Task<IVoiceRegion> GetOptimalVoiceRegionAsync(this IDiscordClient discord) |
|
|
{ |
|
|
{ |
|
|
var regions = await discord.GetVoiceRegionsAsync().ConfigureAwait(false); |
|
|
var regions = await discord.GetVoiceRegionsAsync().ConfigureAwait(false); |
|
|