Beispiel #1
0
        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);
        }
Beispiel #2
0
 /// <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)),
Beispiel #3
0
 public static IReadOnlyCollection <IUser> GetUsers(this IGroupChannel channel)
 => GetSocketGroupChannel(channel).Users;
Beispiel #4
0
 public static IUser GetUser(this IGroupChannel channel, ulong id)
 => GetSocketGroupChannel(channel).GetUser(id);
Beispiel #5
0
 public DMChannelViewer(IGroupChannel channel)
 {
     InitializeComponent();
     Channel = channel;
 }
Beispiel #6
0
 public static string GetName(this IGroupChannel channel) => channel.Name ?? string.Join(", ", (channel.GetUsersAsync().Flatten().Result).Select(u => u.Username));