Beispiel #1
0
        private void SaveItem()
        {
            var newItem = new BusinessObject {
                Name        = SelectedItemName,
                FirstName   = SelectedItemFirstName,
                Address     = SelectedItemAddress,
                PhoneNumber = SelectedItemPhoneNumber
            };

            DbService.AddItem(newItem.ConvertToItem());
            newItem.ItemId = DbService.GetLastItemId();

            Items.Add(newItem);
            AddButtonVisibility  = Constants.Visible;
            SaveButtonVisibility = Constants.Collapsed;
            LabelVisibility      = Constants.Collapsed;
            VisibilityTextBox    = Constants.Collapsed;
        }
Beispiel #2
0
        public async Task SetAsync([Summary("The new prefix."), Remainder] string prefix = null)
        {
            if (string.IsNullOrWhiteSpace(prefix))
            {
                var interaction = await _inter.SendSelectionAsync(new ButtonSelectionBuilder <string>()
                                                                  .AddUser(Context.User)
                                                                  .WithSelectionPage(new PageBuilder()
                                                                                     .WithTitle("⚠️ Warning ⚠️")
                                                                                     .WithDescription($"My current prefix is {_db.GetPrefix(Context.Guild.Id).Prefix}`. Did you intend to reset it?")
                                                                                     .WithCurrentTimestamp()
                                                                                     .WithColor(_rand.RandomColor()
                                                                                                ))
                                                                  .WithInputType(InputType.Buttons)
                                                                  .WithOptions(new[] { new ButtonOption <string>("Confirm", ButtonStyle.Primary), new ButtonOption <string>("Cancel", ButtonStyle.Danger) })
                                                                  .Build(), Context.Channel, timeout : TimeSpan.FromSeconds(10));

                if (interaction.IsSuccess && interaction.Value.Option == "Confirm")
                {
                    _db.RemovePrefix(Context.Guild.Id);
                    await ReplyAsync("The prefix has been reset to default; mention me if you are unsure of what that is.");
                }

                await interaction.Message.DeleteAsync();

                return;
            }

            var gp = new GuildPrefix {
                GuildId = Context.Guild.Id, Prefix = prefix
            };

            _db.RemovePrefix(Context.Guild.Id);
            var suc = _db.AddItem <GuildPrefix>("prefixes", gp);

            if (suc)
            {
                await ReplyAsync($"Changed the prefix to `{prefix}`.");
            }
            else
            {
                await ReplyAsync("Failed to change the prefix.");
            }
        }