public async Task ExitAsync(CommandContext ctx) { if (!Shared.BotManagers.Contains(ctx.Member.Id) && !ctx.Client.CurrentApplication.Owners.Any(x => x.Id == ctx.User.Id)) { await ctx.SafeRespondUnformattedAsync("You do not have permission to use this command!"); return; } await ctx.SafeRespondUnformattedAsync("Are you sure you want to shut down the bot?"); var cts = ctx.Services.GetService <SharedData>().CTS; var interactivity = ctx.Services.GetService <InteractivityExtension>(); var m = await interactivity.WaitForMessageAsync(x => x.ChannelId == ctx.Channel.Id && x.Author.Id == ctx.Member.Id, TimeSpan.FromSeconds(30)); if (m.TimedOut) { await ctx.SafeRespondUnformattedAsync("Timed out."); } else if (InteractivityUtil.Confirm(m.Result)) { await ctx.SafeRespondUnformattedAsync("Shutting down."); cts.Cancel(false); } else { await ctx.SafeRespondUnformattedAsync("Operation cancelled by user."); } }
public async Task ClearAsync(CommandContext ctx) { await ctx.TriggerTypingAsync(); await ctx.SafeRespondUnformattedAsync("Are you sure you want to clear all your active reminders? This action cannot be undone!"); var m = await this.Interactivity.WaitForMessageAsync(x => x.ChannelId == ctx.Channel.Id && x.Author.Id == ctx.Member.Id, TimeSpan.FromSeconds(30)); if (m.TimedOut) { await ctx.SafeRespondUnformattedAsync("Timed out."); } else if (InteractivityUtil.Confirm(m.Result)) { await ctx.SafeRespondUnformattedAsync("Brace for impact!"); await ctx.TriggerTypingAsync(); using (var db = this.Database.CreateContext()) { List <DatabaseTimer> timers = db.Timers.Where(xt => xt.ActionType == TimerActionType.Reminder && xt.UserId == (long)ctx.User.Id).ToList(); var count = timers.Count; await Timers.UnscheduleTimersAsync(timers, ctx.Client, this.Database, this.Shared); await ctx.SafeRespondUnformattedAsync("Alright, cleared " + count + " timers."); } } else { await ctx.SafeRespondUnformattedAsync("Never mind then, maybe next time."); } }