Exemple #1
0
        private void StreamersEdit_Click(object sender, RoutedEventArgs e)
        {
            if (streamerListBox.SelectedIndex == -1)
            {
                return;
            }
            StreamerEditor se = new StreamerEditor();

            se.Owner     = this;
            se._streamer = _server.StreamerList[streamerListBox.SelectedIndex];
            se.Title     = $"Edit Streamer {se._streamer.DiscordName}";
            IsEnabled    = false;
            se.ShowDialog();
            IsEnabled = true;
            if (se.DialogResult.HasValue && se.DialogResult.Value)
            {
                se._streamer.DiscordId   = ulong.Parse(se.discordIdBox.Text);
                se._streamer.DiscordName = _client.Guilds.FirstOrDefault(x => x.Id == _server.ServerId).Users.FirstOrDefault(y => y.Id == ulong.Parse(se.discordIdBox.Text)).ToString();
                se._streamer.TwitchName  = se.twitchNameBox.Text;
                se._streamer.Mention     = (MentionLevel)se.mentionLevelComboBox.SelectedItem;
                se._streamer.GiveRole    = se.giveRoleCheckBox.IsChecked.Value;
                se._streamer.AutoPost    = se.autoPostCheckBox.IsChecked.Value;
                UpdateView("streamers");
                BotFrame.SaveFile("servers");
            }
        }
Exemple #2
0
        //Streamers
        private void StreamersAdd_Click(object sender, RoutedEventArgs e)
        {
            StreamerEditor se = new StreamerEditor();

            se.Owner = this;
            se.Title = "New Streamer";
            se.mentionLevelComboBox.SelectedItem = MentionLevel.None;
            IsEnabled = false;
            se.ShowDialog();
            IsEnabled = true;
            if (se.DialogResult.HasValue && se.DialogResult.Value)
            {
                if (_server.StreamerList.FirstOrDefault(x => x.DiscordId == ulong.Parse(se.discordIdBox.Text) || x.TwitchName == se.twitchNameBox.Text) != null)
                {
                    MessageBox.Show("You are trying to add a user that already has an entry, please select the user entry and edit it instead!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                Streamer newStreamer = new Streamer()
                {
                    Streaming   = false,
                    DiscordId   = ulong.Parse(se.discordIdBox.Text),
                    DiscordName = _client.Guilds.FirstOrDefault(x => x.Id == _server.ServerId).Users.FirstOrDefault(y => y.Id == ulong.Parse(se.discordIdBox.Text)).ToString(),
                    Mention     = (MentionLevel)se.mentionLevelComboBox.SelectedItem,
                    GiveRole    = se.giveRoleCheckBox.IsChecked.Value,
                    AutoPost    = se.autoPostCheckBox.IsChecked.Value,
                    TwitchName  = se.twitchNameBox.Text
                };
                if (_server.StreamerList == null)
                {
                    _server.StreamerList = new List <Streamer>();
                }
                _server.StreamerList.Add(newStreamer);
                UpdateView("streamer");
                BotFrame.SaveFile("servers");
            }
        }