Beispiel #1
0
        public List <Channel> GetChannels(ulong guildId)
        {
            SocketGuild guild = DiscordService.DiscordClient.GetGuild(guildId);

            if (guild == null)
            {
                throw new Exception("Unable to access guild");
            }

            List <Channel> results = new List <Channel>();

            foreach (SocketGuildChannel guildChannel in guild.Channels)
            {
                Channel.Types type = Channel.Types.Unknown;

                if (guildChannel is SocketTextChannel)
                {
                    type = Channel.Types.Text;
                }

                if (guildChannel is SocketVoiceChannel)
                {
                    type = Channel.Types.Voice;
                }

                results.Add(new Channel(guildChannel.Id, guildChannel.Name, type));
            }

            return(results);
        }
Beispiel #2
0
        public static async Task <List <Channel> > GetChannels(Channel.Types type = Channel.Types.Text)
        {
            List <Channel> allChanels = await RPCService.Invoke <List <Channel> >("GuildService.GetChannels");

            List <Channel> channels = new List <Channel>();

            foreach (Channel channel in allChanels)
            {
                if (channel.Type != type)
                {
                    continue;
                }

                channels.Add(channel);
            }

            channels.Sort((Channel a, Channel b) =>
            {
                return(a.Name.CompareTo(b.Name));
            });

            return(channels);
        }
 public InspectorChannelAttribute(Channel.Types type)
 {
     this.ChannelType = type;
 }
 public InspectorChannelAttribute()
 {
     this.ChannelType = Channel.Types.Unknown;
 }