internal static SocketGroupChannel GetSocketGroupChannel(IGroupChannel channel) { Preconditions.NotNull(channel, nameof(channel)); var socketChannel = channel as SocketGroupChannel; if (socketChannel == null) { throw new InvalidOperationException("This extension method is only valid on WebSocket Entities"); } return(socketChannel); }
/// <summary> /// Converts an existing <see cref="IGroupChannel"/> to an abstracted <see cref="IGroupChannel"/> value. /// </summary> /// <param name="groupChannel">The existing <see cref="IGroupChannel"/> to be abstracted.</param> /// <exception cref="ArgumentNullException">Throws for <paramref name="groupChannel"/>.</exception> /// <returns>An <see cref="IGroupChannel"/> that abstracts <paramref name="groupChannel"/>.</returns> public static IGroupChannel Abstract(this IGroupChannel groupChannel) => groupChannel switch { null => throw new ArgumentNullException(nameof(groupChannel)),
public static IReadOnlyCollection <IUser> GetUsers(this IGroupChannel channel) => GetSocketGroupChannel(channel).Users;
public static IUser GetUser(this IGroupChannel channel, ulong id) => GetSocketGroupChannel(channel).GetUser(id);
public DMChannelViewer(IGroupChannel channel) { InitializeComponent(); Channel = channel; }
public static string GetName(this IGroupChannel channel) => channel.Name ?? string.Join(", ", (channel.GetUsersAsync().Flatten().Result).Select(u => u.Username));