public async Task StopQuiz() { ulong id = GetId(); var quiz = await _db.Quiz.Where(q => q.ServerId == id && q.IsActive).FirstOrDefaultAsync(); if (quiz != null) { var gUser = Context.User as IGuildUser; if (gUser != null && Context.User.Id != quiz.StartedById && !gUser.GuildPermissions.KickMembers) { await ReplyAsync($"Sorry, {Context.User.Mention}, a test can only be stopped by the person who started it, or by someone with at least **KickMembers** permissions in {Context.Guild.Name}!"); return; } else if (quiz != null && gUser != null && gUser.GuildPermissions.KickMembers) { QuizUtil trivia = null; if (_hamTestService.RunningTests.TryRemove(id, out trivia)) { await trivia.StopQuiz().ConfigureAwait(false); } else { await ReplyAsync("No quiz to end!"); } return; } if (Context.User.Id == quiz.StartedById) { QuizUtil trivia = null; if (_hamTestService.RunningTests.TryRemove(id, out trivia)) { await trivia.StopQuiz().ConfigureAwait(false); } else { await ReplyAsync("No quiz to end!"); } } else { await ReplyAsync($"Sorry, {Context.User.Mention}, a test can only be stopped by the person who started it! (or by a moderator)"); } } else { await ReplyAsync("No quiz to end!"); } }