Beispiel #1
0
        private void ReactionLocksEdit_Click(object sender, RoutedEventArgs e)
        {
            if (reactionListBox.SelectedIndex == -1)
            {
                return;
            }
            ReactionLockEditor rl = new ReactionLockEditor();

            rl.Owner  = this;
            rl._lock  = _server.ReactionLockList[reactionListBox.SelectedIndex];
            rl.Title  = $"Edit lock {rl._lock.MessageId}";
            IsEnabled = false;
            rl.ShowDialog();
            IsEnabled = true;
            if (rl.DialogResult.HasValue && rl.DialogResult.Value)
            {
                rl._lock.ChannelId = ulong.Parse(rl.channelBox.Text);
                rl._lock.MessageId = ulong.Parse(rl.messageBox.Text);
                rl._lock.Emote     = rl.emoteBox.Text;
                rl._lock.GiveRole  = ulong.Parse(rl.giveRoleBox.Text);
                rl._lock.TakeRole  = ulong.Parse(rl.takeRoleBox.Text);
                UpdateView("reactionlock");
                BotFrame.SaveFile("servers");
            }
        }
Beispiel #2
0
        //ReactionLocks
        private void ReactionLocksAdd_Click(object sender, RoutedEventArgs e)
        {
            ReactionLockEditor rl = new ReactionLockEditor();

            rl.Owner  = this;
            rl.Title  = "New Reaction Lock";
            IsEnabled = false;
            rl.ShowDialog();
            IsEnabled = true;
            if (rl.DialogResult.HasValue && rl.DialogResult.Value)
            {
                if (_server.ReactionLockList.FirstOrDefault(x => x.ChannelId == ulong.Parse(rl.channelBox.Text) && x.MessageId == ulong.Parse(rl.messageBox.Text)) != null)
                {
                    MessageBox.Show("You are trying to add a reaction lock that already has an entry, please select the reaction lock entry and edit it instead!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                ReactionLock newLock = new ReactionLock()
                {
                    ChannelId = ulong.Parse(rl.channelBox.Text),
                    MessageId = ulong.Parse(rl.messageBox.Text),
                    Emote     = rl.emoteBox.Text,
                    GiveRole  = ulong.Parse(rl.giveRoleBox.Text),
                    TakeRole  = ulong.Parse(rl.takeRoleBox.Text)
                };
                if (_server.ReactionLockList == null)
                {
                    _server.ReactionLockList = new List <ReactionLock>();
                }
                _server.ReactionLockList.Add(newLock);
                UpdateView("reactionlock");
                BotFrame.SaveFile("servers");
            }
        }