예제 #1
0
        private async Task Client_ChannelCreated(IChannel arg)
        {
            if (arg is IGuildChannel && (arg as IGuildChannel).Guild.Id == Guild.Id)
            {
                await Dispatcher.InvokeAsync(() =>
                {
                    channelsList.Items.Clear();
                });

                IEnumerable <ITextChannel> channels = (await(arg as IGuildChannel).Guild.GetTextChannelsAsync());

                foreach (ITextChannel channel in channels.Where(c => (c.GetUsersAsync().Flatten().Result).Any(u => u.Id == App.DiscordWindow.Client.CurrentUser.Id)).OrderBy(c => c.Position))
                {
                    await Dispatcher.InvokeAsync(() =>
                    {
                        ChannelViewer viewer = new ChannelViewer(channel);
                        channelsList.Items.Add(viewer);
                    });
                }

                await Dispatcher.InvokeAsync(() =>
                {
                    channelsList.Items.Add(new Separator());
                });

                foreach (IVoiceChannel channel in await(arg as IGuildChannel).Guild.GetVoiceChannelsAsync())
                {
                    await Dispatcher.InvokeAsync(() =>
                    {
                        ChannelViewer viewer = new ChannelViewer(voiceChan: channel);
                        channelsList.Items.Add(viewer);
                    });
                }
            }
        }
예제 #2
0
        private async void ListViewItem_Loaded(object sender, RoutedEventArgs e)
        {
            if (await Guild.GetDefaultChannelAsync() != null)
            {
                guildDescription.Text = "#" + (await Guild.GetDefaultChannelAsync()).Name;
            }

            foreach (ITextChannel channel in (await Guild.GetTextChannelsAsync()).Where(c => c.GetUsersAsync().Flatten().Result.Any(u => u.Id == App.DiscordWindow.Client.CurrentUser.Id)).OrderBy(c => c.Position))
            {
                ChannelViewer viewer = new ChannelViewer(channel);
                channelsList.Items.Add(viewer);
            }

            if ((await Guild.GetVoiceChannelsAsync()).Any())
            {
                channelsList.Items.Add(new Separator());

                foreach (IVoiceChannel channel in await Guild.GetVoiceChannelsAsync())
                {
                    ChannelViewer viewer = new ChannelViewer(voiceChan: channel);
                    channelsList.Items.Add(viewer);
                }
            }
        }