public async Task ShopAdd(Role _, int price, [Leftover] IRole role)
            {
                var entry = new ShopEntry()
                {
                    Name     = "-",
                    Price    = price,
                    Type     = ShopEntryType.Role,
                    AuthorId = ctx.User.Id,
                    RoleId   = role.Id,
                    RoleName = role.Name
                };

                using (var uow = _db.GetDbContext())
                {
                    var entries = new IndexedCollection <ShopEntry>(uow.GuildConfigs.ForId(ctx.Guild.Id,
                                                                                           set => set.Include(x => x.ShopEntries)
                                                                                           .ThenInclude(x => x.Items)).ShopEntries)
                    {
                        entry
                    };
                    uow.GuildConfigs.ForId(ctx.Guild.Id, set => set).ShopEntries = entries;
                    uow.SaveChanges();
                    List <ulong> roleForSales = JsonConvert.DeserializeObject <List <ulong> >(_bc.BotConfig.RoleForSale);
                    if (!roleForSales.Contains(role.Id))
                    {
                        roleForSales.Add(role.Id);
                        _bc.Edit(BotConfigEditType.RoleForSale, JsonConvert.SerializeObject(roleForSales));
                    }
                }
                await ctx.Channel.EmbedAsync(EntryToEmbed(entry)
                                             .WithTitle(GetText("shop_item_add"))).ConfigureAwait(false);
            }
Beispiel #2
0
            public async Task BotConfigEdit(BotConfigEditType type, [Remainder] string newValue = null)
            {
                if (string.IsNullOrWhiteSpace(newValue))
                {
                    newValue = null;
                }

                var success = _service.Edit(type, newValue);

                if (!success)
                {
                    await ReplyErrorLocalized("bot_config_edit_fail", Format.Bold(type.ToString()), Format.Bold(newValue ?? "NULL")).ConfigureAwait(false);
                }
                else
                {
                    await ReplyConfirmLocalized("bot_config_edit_success", Format.Bold(type.ToString()), Format.Bold(newValue ?? "NULL")).ConfigureAwait(false);
                }
            }