.novel done, waifutransfer almost done
This commit is contained in:
		@@ -9,13 +9,15 @@ namespace NadekoBot.Modules.Gambling.Services
 | 
			
		||||
    public class WaifuService : INService
 | 
			
		||||
    {
 | 
			
		||||
        private readonly DbService _db;
 | 
			
		||||
        private readonly CurrencyService _cs;
 | 
			
		||||
 | 
			
		||||
        public ConcurrentDictionary<ulong, DateTime> DivorceCooldowns { get; } = new ConcurrentDictionary<ulong, DateTime>();
 | 
			
		||||
        public ConcurrentDictionary<ulong, DateTime> AffinityCooldowns { get; } = new ConcurrentDictionary<ulong, DateTime>();
 | 
			
		||||
 | 
			
		||||
        public WaifuService(DbService db)
 | 
			
		||||
        public WaifuService(DbService db, CurrencyService cs)
 | 
			
		||||
        {
 | 
			
		||||
            _db = db;
 | 
			
		||||
            _cs = cs;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public async Task<bool> WaifuTransfer(IUser owner, ulong waifuId, IUser newOwner)
 | 
			
		||||
@@ -29,12 +31,22 @@ namespace NadekoBot.Modules.Gambling.Services
 | 
			
		||||
                if (waifu.ClaimerId != ownerUser.Id)
 | 
			
		||||
                    return false;
 | 
			
		||||
 | 
			
		||||
                if (!await _cs.RemoveAsync(owner.Id,
 | 
			
		||||
                    "Waifu Transfer",
 | 
			
		||||
                    waifu.Price / 10,
 | 
			
		||||
                    uow).ConfigureAwait(false))
 | 
			
		||||
                {
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                //new claimerId is the id of the new owner
 | 
			
		||||
                var newOwnerUser = uow.DiscordUsers.GetOrCreate(newOwner);
 | 
			
		||||
                waifu.ClaimerId = newOwnerUser.Id;
 | 
			
		||||
 | 
			
		||||
                await uow.CompleteAsync().ConfigureAwait(false);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -190,9 +190,9 @@ namespace NadekoBot.Modules.Gambling
 | 
			
		||||
 | 
			
		||||
            [NadekoCommand, Usage, Description, Aliases]
 | 
			
		||||
            [RequireContext(ContextType.Guild)]
 | 
			
		||||
            public async Task WaifuTransfer(IGuildUser waifu, IGuildUser newOwner)
 | 
			
		||||
            public async Task WaifuTransfer(IUser waifu, IUser newOwner)
 | 
			
		||||
            {
 | 
			
		||||
                if(!await _service.WaifuTransfer(waifu.Id, newOwner.Id)
 | 
			
		||||
                if(!await _service.WaifuTransfer(Context.User, waifu.Id, newOwner)
 | 
			
		||||
                    .ConfigureAwait(false))
 | 
			
		||||
                {
 | 
			
		||||
                    await ReplyErrorLocalized("waifu_transfer_fail").ConfigureAwait(false);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user