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 ShowStats(IGuildUser target) { var nickOrUsername = target.Nickname ?? target.Username; if (target.Id == Context.User.Id) { await ShowStats(); return; } if (target.IsBot) { await ReplyAsync("Bots don't have stats. Even if they had, they would beat you up."); return; } if (!_userProvider.GlobalDataExists(target.Id)) { await ReplyAsync($"{nickOrUsername} did not give data collection consent."); return; } var globalUser = _userProvider.GetGlobalUserData(target.Id); await ReplyAsync($@"Stats of {nickOrUsername} {globalUser.RpgAccount.GetStringReport()}"); }
public async Task GiveConsent() { var userId = Context.User.Id; if (_gudp.GlobalDataExists(userId)) { return; } var consent = new DataConsent { Date = DateTime.UtcNow, MessageId = Context.Message.Id }; _gudp.AddNewGlobalData(userId, consent); await ReplyAsync(_lang.Resolve("[PRIVACY_MESSAGE_HEADER]\n\n[PRIVACY_AGREE_RESPONSE]\n\n[PRIVACY_CMD_HINT]")); }
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}"); }