public async Task WaifuGift(WaifuItem.ItemName item, [Remainder] IUser waifu) { if (waifu.Id == Context.User.Id) { return; } var itemObj = WaifuItem.GetItem(item, _bc.BotConfig.WaifuGiftMultiplier); using (var uow = _db.UnitOfWork) { var w = uow.Waifus.ByWaifuUserId(waifu.Id); //try to buy the item first if (!await _cs.RemoveAsync(Context.User.Id, "Bought waifu item", itemObj.Price, gamble: true)) { await ReplyErrorLocalized("not_enough", _bc.BotConfig.CurrencySign).ConfigureAwait(false); return; } if (w == null) { uow.Waifus.Add(w = new WaifuInfo() { Affinity = null, Claimer = null, Price = 1, Waifu = uow.DiscordUsers.GetOrCreate(waifu), }); w.Waifu.Username = waifu.Username; w.Waifu.Discriminator = waifu.Discriminator; } w.Items.Add(itemObj); if (w.Claimer?.UserId == Context.User.Id) { w.Price += itemObj.Price; } else { w.Price += itemObj.Price / 2; } await uow.CompleteAsync().ConfigureAwait(false); } await ReplyConfirmLocalized("waifu_gift", Format.Bold(item.ToString() + " " + itemObj.ItemEmoji), Format.Bold(waifu.ToString())).ConfigureAwait(false); }
public async Task WaifuGift(WaifuItem.ItemName item, [Remainder] IUser waifu) { if (waifu.Id == Context.User.Id) { return; } var itemObj = WaifuItem.GetItemObject(item, Bc.BotConfig.WaifuGiftMultiplier); int sucess = await _service.GiftWaifuAsync(Context.User.Id, waifu, itemObj); if (sucess != 0) { await ReplyConfirmLocalized("waifu_gift", Format.Bold(GetText(item.ToString()) + " " + itemObj.ItemEmoji), waifu.Mention, Format.Bold(String.Format("{0:#,0}", sucess) + Bc.BotConfig.CurrencySign)); } else { await ReplyErrorLocalized("not_enough", Bc.BotConfig.CurrencySign); } }
public async Task WaifuGift(WaifuItem.ItemName item, [Leftover] IUser waifu) { if (waifu.Id == ctx.User.Id) { return; } var itemObj = WaifuItem.GetItemObject(item, Bc.BotConfig.WaifuGiftMultiplier); bool sucess = await _service.GiftWaifuAsync(ctx.User.Id, waifu, itemObj); if (sucess) { await ReplyConfirmLocalizedAsync("waifu_gift", Format.Bold(item.ToString() + " " + itemObj.ItemEmoji), Format.Bold(waifu.ToString())); } else { await ReplyErrorLocalizedAsync("not_enough", Bc.BotConfig.CurrencySign); } }