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