public async Task RegisterJob(DiggingJob job) { // Do not continue if consent was lost. if (!_gudp.GlobalDataExists(job.UserId)) { return; } #if DEBUG // In DEBUG, we need to wait for SECONDS instead of HOURS // to be able to test the feature without actually waiting. var finishDateTime = job.StartDateTime.AddSeconds(job.DiggingLengthInHours); //var finishDateTime = job.StartDateTime.AddSeconds(20); #else var finishDateTime = job.StartDateTime.AddHours(job.DiggingLengthInHours); #endif // Finish if past due-date. if (finishDateTime < DateTime.Now) { await FinishDigging(job); return; } var user = _gudp.GetGlobalUserData(job.UserId); JustineCore.SchedulerUtilities.ExecuteAt(async() => { await FinishDigging(job); }, finishDateTime); Logger.Log($"[RegisterAllDiggingJobs] Scheduled a stored job."); }
public async Task GetDataCopy(string arg = "") { var userId = Context.User.Id; if (!_gudp.GlobalDataExists(userId)) { return; } var data = _gudp.GetGlobalUserData(userId); var json = JsonConvert.SerializeObject(data, Formatting.Indented); var template = _lang.Resolve($"{Context.User.Mention}\n[PRIVACY_DATA_REPORT_TEMPLATE(@DATA)]"); var dataReport = string.Format(template, json); if (arg == "public") { await ReplyAsync(dataReport); return; } try { await Context.User.SendMessageAsync(_lang.Resolve($"{dataReport}\n[DM_DELETABLE]")); await ReplyAsync(_lang.Resolve($"{Context.User.Mention}, [PRIVACY_DATA_REPORT_SUCCESS]")); } catch (Exception) { await ReplyAsync(_lang.GetResource("PRIVACY_DATA_REPORT_FAIL")); } }
public async Task DebugCmd(IGuildUser target) { var tName = target.Nickname ?? target.Username; if (!_gudp.GlobalDataExists(target.Id)) { await ReplyAsync($"{tName} - No consent"); return; } var onAdventure = _gudp.GetGlobalUserData(target.Id).RpgAccount.OnAdventure; await ReplyAsync($"{tName} - OnAdventure: {onAdventure}"); }
public async Task UseHealthPotion() { var acc = _userProvider.GetGlobalUserData(Context.User.Id); var item = _rpgItemRepository.GetItemByName("Health Potion"); if (!acc.RpgAccount.HasItem(item.Id)) { await ReplyAsync("You don't have any more health potions. _(RIP)_"); return; } acc.RpgAccount.RemoveItemCount(item.Id, 1); acc = item.UseDelegate(acc); _userProvider.SaveGlobalUserData(acc); await ReplyAsync(":heart_exclamation: You drank a health potion and you feel better."); }