Some questions fixed, some trivia bugs fixed, games prettified

This commit is contained in:
Kwoth 2016-12-11 01:42:58 +01:00
parent b65c2e1bdf
commit 3dbdcda6da
9 changed files with 117 additions and 102 deletions

View File

@ -1,6 +1,7 @@
using Discord; using Discord;
using Discord.Commands; using Discord.Commands;
using NadekoBot.Attributes; using NadekoBot.Attributes;
using NadekoBot.Extensions;
using NadekoBot.Services; using NadekoBot.Services;
using NLog; using NLog;
using Services.CleverBotApi; using Services.CleverBotApi;
@ -72,12 +73,11 @@ namespace NadekoBot.Modules.Games
var response = await cleverbot.Think(message).ConfigureAwait(false); var response = await cleverbot.Think(message).ConfigureAwait(false);
try try
{ {
await msg.Channel.SendMessageAsync(response).ConfigureAwait(false); await msg.Channel.SendConfirmAsync(response.SanitizeMentions()).ConfigureAwait(false);
} }
catch (Exception ex) catch
{ {
_log.Warn(ex, "Eror sending response"); await msg.Channel.SendConfirmAsync(response.SanitizeMentions()).ConfigureAwait(false); // try twice :\
await msg.Channel.SendMessageAsync(msg.Author.Mention+" "+response).ConfigureAwait(false); // try twice :\
} }
return true; return true;
} }
@ -97,7 +97,7 @@ namespace NadekoBot.Modules.Games
uow.GuildConfigs.SetCleverbotEnabled(channel.Guild.Id, false); uow.GuildConfigs.SetCleverbotEnabled(channel.Guild.Id, false);
await uow.CompleteAsync().ConfigureAwait(false); await uow.CompleteAsync().ConfigureAwait(false);
} }
await channel.SendMessageAsync($"{imsg.Author.Mention} `Disabled cleverbot on this server.`").ConfigureAwait(false); await channel.SendConfirmAsync($"{imsg.Author.Mention} Disabled cleverbot on this server.").ConfigureAwait(false);
return; return;
} }
@ -112,7 +112,7 @@ namespace NadekoBot.Modules.Games
await uow.CompleteAsync().ConfigureAwait(false); await uow.CompleteAsync().ConfigureAwait(false);
} }
await channel.SendMessageAsync($"{imsg.Author.Mention} `Enabled cleverbot on this server.`").ConfigureAwait(false); await channel.SendConfirmAsync($"{imsg.Author.Mention} Enabled cleverbot on this server.").ConfigureAwait(false);
} }
} }
} }

View File

@ -21,7 +21,7 @@ namespace NadekoBot.Modules.Games
text = text.Trim(); text = text.Trim();
if (string.IsNullOrWhiteSpace(text)) if (string.IsNullOrWhiteSpace(text))
return; return;
await channel.SendMessageAsync(ToLeet(text, level)).ConfigureAwait(false); await channel.SendConfirmAsync("L33t", ToLeet(text, level).SanitizeMentions()).ConfigureAwait(false);
} }

View File

@ -105,7 +105,7 @@ namespace NadekoBot.Modules.Games
if (!channel.Guild.GetCurrentUser().GetPermissions(channel).ManageMessages) if (!channel.Guild.GetCurrentUser().GetPermissions(channel).ManageMessages)
{ {
await channel.SendMessageAsync("`I need manage channel permissions in order to process this command.`").ConfigureAwait(false); await channel.SendErrorAsync("I need manage channel permissions in order to process this command.").ConfigureAwait(false);
return; return;
} }
@ -118,7 +118,7 @@ namespace NadekoBot.Modules.Games
await Task.WhenAll(msgs.Select(toDelete => toDelete.DeleteAsync())).ConfigureAwait(false); await Task.WhenAll(msgs.Select(toDelete => toDelete.DeleteAsync())).ConfigureAwait(false);
await CurrencyHandler.AddCurrencyAsync((IGuildUser)imsg.Author, "Picked flower(s).", msgs.Count, false).ConfigureAwait(false); await CurrencyHandler.AddCurrencyAsync((IGuildUser)imsg.Author, "Picked flower(s).", msgs.Count, false).ConfigureAwait(false);
var msg = await channel.SendMessageAsync($"**{imsg.Author.Username}** picked {msgs.Count}{Gambling.Gambling.CurrencySign}!").ConfigureAwait(false); var msg = await channel.SendConfirmAsync($"**{imsg.Author}** picked {msgs.Count}{Gambling.Gambling.CurrencySign}!").ConfigureAwait(false);
var t = Task.Run(async () => var t = Task.Run(async () =>
{ {
await Task.Delay(10000).ConfigureAwait(false); await Task.Delay(10000).ConfigureAwait(false);
@ -135,7 +135,7 @@ namespace NadekoBot.Modules.Games
var removed = await CurrencyHandler.RemoveCurrencyAsync((IGuildUser)imsg.Author, "Planted a flower.", 1, false).ConfigureAwait(false); var removed = await CurrencyHandler.RemoveCurrencyAsync((IGuildUser)imsg.Author, "Planted a flower.", 1, false).ConfigureAwait(false);
if (!removed) if (!removed)
{ {
await channel.SendMessageAsync($"You don't have any {Gambling.Gambling.CurrencyPluralName}.").ConfigureAwait(false); await channel.SendErrorAsync($"You don't have any {Gambling.Gambling.CurrencyPluralName}.").ConfigureAwait(false);
return; return;
} }
@ -146,7 +146,7 @@ namespace NadekoBot.Modules.Games
var msgToSend = $"Oh how Nice! **{imsg.Author.Username}** planted {(vowelFirst ? "an" : "a")} {Gambling.Gambling.CurrencyName}. Pick it using {NadekoBot.ModulePrefixes[typeof(Games).Name]}pick"; var msgToSend = $"Oh how Nice! **{imsg.Author.Username}** planted {(vowelFirst ? "an" : "a")} {Gambling.Gambling.CurrencyName}. Pick it using {NadekoBot.ModulePrefixes[typeof(Games).Name]}pick";
if (file == null) if (file == null)
{ {
msg = await channel.SendMessageAsync(Gambling.Gambling.CurrencySign).ConfigureAwait(false); msg = await channel.SendConfirmAsync(Gambling.Gambling.CurrencySign).ConfigureAwait(false);
} }
else else
{ {
@ -184,11 +184,11 @@ namespace NadekoBot.Modules.Games
} }
if (enabled) if (enabled)
{ {
await channel.SendMessageAsync("`Currency generation enabled on this channel.`").ConfigureAwait(false); await channel.SendConfirmAsync("Currency generation enabled on this channel.").ConfigureAwait(false);
} }
else else
{ {
await channel.SendMessageAsync($"`Currency generation disabled on this channel.`").ConfigureAwait(false); await channel.SendConfirmAsync("Currency generation disabled on this channel.").ConfigureAwait(false);
} }
} }

View File

@ -1,6 +1,7 @@
using Discord; using Discord;
using Discord.Commands; using Discord.Commands;
using NadekoBot.Attributes; using NadekoBot.Attributes;
using NadekoBot.Extensions;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
@ -44,7 +45,7 @@ namespace NadekoBot.Modules.Games
await poll.StartPoll().ConfigureAwait(false); await poll.StartPoll().ConfigureAwait(false);
} }
else else
await channel.SendMessageAsync("`Poll is already running on this server.`").ConfigureAwait(false); await channel.SendErrorAsync("Poll is already running on this server.").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -91,7 +92,7 @@ namespace NadekoBot.Modules.Games
msgToSend += "\n**Private Message me with the corresponding number of the answer.**"; msgToSend += "\n**Private Message me with the corresponding number of the answer.**";
else else
msgToSend += "\n**Send a Message here with the corresponding number of the answer.**"; msgToSend += "\n**Send a Message here with the corresponding number of the answer.**";
await originalMessage.Channel.SendMessageAsync(msgToSend).ConfigureAwait(false); await originalMessage.Channel.SendConfirmAsync(msgToSend).ConfigureAwait(false);
} }
public async Task StopPoll() public async Task StopPoll()
@ -115,7 +116,7 @@ namespace NadekoBot.Modules.Games
$" has {kvp.Value} votes." + $" has {kvp.Value} votes." +
$"({kvp.Value * 1.0f / totalVotesCast * 100}%)\n"); $"({kvp.Value * 1.0f / totalVotesCast * 100}%)\n");
await originalMessage.Channel.SendMessageAsync($"📄 **Total votes cast**: {totalVotesCast}\n{closeMessage}").ConfigureAwait(false); await originalMessage.Channel.SendConfirmAsync($"📄 **Total votes cast**: {totalVotesCast}\n{closeMessage}").ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -166,11 +167,11 @@ namespace NadekoBot.Modules.Games
{ {
if (!isPublic) if (!isPublic)
{ {
await ch.SendMessageAsync($"Thanks for voting **{msg.Author.Username}**.").ConfigureAwait(false); await ch.SendConfirmAsync($"Thanks for voting **{msg.Author.Username}**.").ConfigureAwait(false);
} }
else else
{ {
var toDelete = await ch.SendMessageAsync($"{msg.Author.Mention} cast their vote.").ConfigureAwait(false); var toDelete = await ch.SendConfirmAsync($"{msg.Author.Mention} cast their vote.").ConfigureAwait(false);
await Task.Delay(5000); await Task.Delay(5000);
await toDelete.DeleteAsync().ConfigureAwait(false); await toDelete.DeleteAsync().ConfigureAwait(false);
} }

View File

@ -21,9 +21,9 @@ namespace NadekoBot.Modules.Games
public class TypingGame public class TypingGame
{ {
public const float WORD_VALUE = 4.5f; public const float WORD_VALUE = 4.5f;
private readonly ITextChannel channel; public ITextChannel Channel { get; }
public string CurrentSentence; public string CurrentSentence { get; private set; }
public bool IsActive; public bool IsActive { get; private set; }
private readonly Stopwatch sw; private readonly Stopwatch sw;
private readonly List<ulong> finishedUserIds; private readonly List<ulong> finishedUserIds;
private Logger _log { get; } private Logger _log { get; }
@ -31,14 +31,12 @@ namespace NadekoBot.Modules.Games
public TypingGame(ITextChannel channel) public TypingGame(ITextChannel channel)
{ {
_log = LogManager.GetCurrentClassLogger(); _log = LogManager.GetCurrentClassLogger();
this.channel = channel; this.Channel = channel;
IsActive = false; IsActive = false;
sw = new Stopwatch(); sw = new Stopwatch();
finishedUserIds = new List<ulong>(); finishedUserIds = new List<ulong>();
} }
public ITextChannel Channel { get; set; }
public async Task<bool> Stop() public async Task<bool> Stop()
{ {
if (!IsActive) return false; if (!IsActive) return false;
@ -47,7 +45,7 @@ namespace NadekoBot.Modules.Games
IsActive = false; IsActive = false;
sw.Stop(); sw.Stop();
sw.Reset(); sw.Reset();
try { await channel.SendMessageAsync("Typing contest stopped").ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); } try { await Channel.SendConfirmAsync("Typing contest stopped.").ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); }
return true; return true;
} }
@ -59,10 +57,10 @@ namespace NadekoBot.Modules.Games
var i = (int)(CurrentSentence.Length / WORD_VALUE * 1.7f); var i = (int)(CurrentSentence.Length / WORD_VALUE * 1.7f);
try try
{ {
await channel.SendMessageAsync($@":clock2: Next contest will last for {i} seconds. Type the bolded text as fast as you can.").ConfigureAwait(false); await Channel.SendConfirmAsync($@":clock2: Next contest will last for {i} seconds. Type the bolded text as fast as you can.").ConfigureAwait(false);
var msg = await channel.SendMessageAsync("Starting new typing contest in **3**...").ConfigureAwait(false); var msg = await Channel.SendMessageAsync("Starting new typing contest in **3**...").ConfigureAwait(false);
await Task.Delay(1000).ConfigureAwait(false); await Task.Delay(1000).ConfigureAwait(false);
try try
{ {
@ -118,7 +116,7 @@ namespace NadekoBot.Modules.Games
{ {
try try
{ {
if (channel == null || channel.Id != channel.Id) return; if (this.Channel == null || this.Channel.Id != this.Channel.Id) return;
var guess = msg.Content; var guess = msg.Content;
@ -126,11 +124,17 @@ namespace NadekoBot.Modules.Games
var decision = Judge(distance, guess.Length); var decision = Judge(distance, guess.Length);
if (decision && !finishedUserIds.Contains(msg.Author.Id)) if (decision && !finishedUserIds.Contains(msg.Author.Id))
{ {
var wpm = CurrentSentence.Length / WORD_VALUE / sw.Elapsed.Seconds * 60;
finishedUserIds.Add(msg.Author.Id); finishedUserIds.Add(msg.Author.Id);
await channel.SendMessageAsync($"{msg.Author.Mention} finished in **{sw.Elapsed.Seconds}** seconds with { distance } errors, **{ CurrentSentence.Length / WORD_VALUE / sw.Elapsed.Seconds * 60 }** WPM!").ConfigureAwait(false); await Extensions.Extensions.EmbedAsync(this.Channel, (Discord.API.Embed)new EmbedBuilder().WithColor((uint)NadekoBot.OkColor)
.WithTitle((string)$"{msg.Author} finished the race!")
.AddField(efb => efb.WithName("Place").WithValue($"#{finishedUserIds.Count}").WithIsInline(true))
.AddField(efb => efb.WithName("WPM").WithValue($"{wpm:F2} *[{sw.Elapsed.Seconds.ToString()}sec]*").WithIsInline(true))
.AddField(efb => efb.WithName((string)"Errors").WithValue((string)distance.ToString()).WithIsInline((bool)true))
.Build()).ConfigureAwait(false);
if (finishedUserIds.Count % 4 == 0) if (finishedUserIds.Count % 4 == 0)
{ {
await channel.SendMessageAsync($":exclamation: `A lot of people finished, here is the text for those still typing:`\n\n**{Format.Sanitize(CurrentSentence.Replace(" ", " \x200B")).SanitizeMentions()}**").ConfigureAwait(false); await Extensions.Extensions.SendConfirmAsync(this.Channel, (string)$":exclamation: A lot of people finished, here is the text for those still typing:\n\n**{Format.Sanitize((string)CurrentSentence.Replace((string)" ", (string)" \x200B")).SanitizeMentions()}**").ConfigureAwait(false);
} }
} }
} }
@ -172,7 +176,7 @@ namespace NadekoBot.Modules.Games
if (game.IsActive) if (game.IsActive)
{ {
await channel.SendMessageAsync( await channel.SendErrorAsync(
$"Contest already running in " + $"Contest already running in " +
$"{game.Channel.Mention} channel.") $"{game.Channel.Mention} channel.")
.ConfigureAwait(false); .ConfigureAwait(false);
@ -194,17 +198,17 @@ namespace NadekoBot.Modules.Games
await game.Stop().ConfigureAwait(false); await game.Stop().ConfigureAwait(false);
return; return;
} }
await channel.SendMessageAsync("No contest to stop on this channel.").ConfigureAwait(false); await channel.SendErrorAsync("No contest to stop on this channel.").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[OwnerOnly] [OwnerOnly]
public async Task Typeadd(IUserMessage imsg, [Remainder] string text) public async Task Typeadd(IUserMessage imsg, [Remainder] string text)
{ {
var channel = (ITextChannel)imsg.Channel; var channel = (ITextChannel)imsg.Channel;
TypingArticles.Add(new TypingArticle TypingArticles.Add(new TypingArticle
{ {
Title = $"Text added on {DateTime.UtcNow} by {imsg.Author}", Title = $"Text added on {DateTime.UtcNow} by {imsg.Author}",
@ -213,7 +217,7 @@ namespace NadekoBot.Modules.Games
File.WriteAllText(typingArticlesPath, JsonConvert.SerializeObject(TypingArticles)); File.WriteAllText(typingArticlesPath, JsonConvert.SerializeObject(TypingArticles));
await channel.SendMessageAsync("Added new article for typing game.").ConfigureAwait(false); await channel.SendConfirmAsync("Added new article for typing game.").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -229,11 +233,11 @@ namespace NadekoBot.Modules.Games
if (!articles.Any()) if (!articles.Any())
{ {
await channel.SendMessageAsync($"{imsg.Author.Mention} `No articles found on that page.`").ConfigureAwait(false); await channel.SendErrorAsync($"{imsg.Author.Mention} `No articles found on that page.`").ConfigureAwait(false);
return; return;
} }
var i = (page - 1) * 15; var i = (page - 1) * 15;
await channel.SendMessageAsync(String.Join("\n", articles.Select(a => $"`#{++i}` - {a.Text.TrimTo(50)}"))) await channel.SendConfirmAsync("List of articles for Type Race", String.Join("\n", articles.Select(a => $"`#{++i}` - {a.Text.TrimTo(50)}")))
.ConfigureAwait(false); .ConfigureAwait(false);
} }
@ -253,7 +257,7 @@ namespace NadekoBot.Modules.Games
File.WriteAllText(typingArticlesPath, JsonConvert.SerializeObject(TypingArticles)); File.WriteAllText(typingArticlesPath, JsonConvert.SerializeObject(TypingArticles));
await channel.SendMessageAsync($"`Removed typing article:` #{index + 1} - {removed.Text.TrimTo(50)}") await channel.SendConfirmAsync($"`Removed typing article:` #{index + 1} - {removed.Text.TrimTo(50)}")
.ConfigureAwait(false); .ConfigureAwait(false);
} }
} }

View File

@ -56,13 +56,13 @@ namespace NadekoBot.Modules.Games.Trivia
CurrentQuestion = TriviaQuestionPool.Instance.GetRandomQuestion(oldQuestions); CurrentQuestion = TriviaQuestionPool.Instance.GetRandomQuestion(oldQuestions);
if (CurrentQuestion == null) if (CurrentQuestion == null)
{ {
try { await channel.SendMessageAsync($":exclamation: Failed loading a trivia question").ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); } try { await channel.SendErrorAsync($":exclamation: Failed loading a trivia question.").ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); }
await End().ConfigureAwait(false); await End().ConfigureAwait(false);
return; return;
} }
oldQuestions.Add(CurrentQuestion); //add it to exclusion list so it doesn't show up again oldQuestions.Add(CurrentQuestion); //add it to exclusion list so it doesn't show up again
//sendquestion //sendquestion
try { await channel.SendMessageAsync($":question: **{CurrentQuestion.Question}**").ConfigureAwait(false); } try { await channel.SendConfirmAsync($":question: Question",$"**{CurrentQuestion.Question}**").ConfigureAwait(false); }
catch (HttpException ex) when (ex.StatusCode == System.Net.HttpStatusCode.NotFound || ex.StatusCode == System.Net.HttpStatusCode.Forbidden) catch (HttpException ex) when (ex.StatusCode == System.Net.HttpStatusCode.NotFound || ex.StatusCode == System.Net.HttpStatusCode.Forbidden)
{ {
break; break;
@ -80,7 +80,7 @@ namespace NadekoBot.Modules.Games.Trivia
//hint //hint
await Task.Delay(HintTimeoutMiliseconds, token).ConfigureAwait(false); await Task.Delay(HintTimeoutMiliseconds, token).ConfigureAwait(false);
if (ShowHints) if (ShowHints)
try { await channel.SendMessageAsync($":exclamation:**Hint:** {CurrentQuestion.GetHint()}").ConfigureAwait(false); } try { await channel.SendConfirmAsync($":exclamation: Hint", CurrentQuestion.GetHint()).ConfigureAwait(false); }
catch (HttpException ex) when (ex.StatusCode == System.Net.HttpStatusCode.NotFound || ex.StatusCode == System.Net.HttpStatusCode.Forbidden) catch (HttpException ex) when (ex.StatusCode == System.Net.HttpStatusCode.NotFound || ex.StatusCode == System.Net.HttpStatusCode.Forbidden)
{ {
break; break;
@ -94,7 +94,7 @@ namespace NadekoBot.Modules.Games.Trivia
catch (TaskCanceledException) { } //means someone guessed the answer catch (TaskCanceledException) { } //means someone guessed the answer
GameActive = false; GameActive = false;
if (!triviaCancelSource.IsCancellationRequested) if (!triviaCancelSource.IsCancellationRequested)
try { await channel.SendMessageAsync($":clock2: :question: **Time's up!** The correct answer was **{CurrentQuestion.Answer}**").ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); } try { await channel.SendConfirmAsync($":clock2: :question: **Time's up!** The correct answer was **{CurrentQuestion.Answer}**").ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); }
NadekoBot.Client.MessageReceived -= PotentialGuess; NadekoBot.Client.MessageReceived -= PotentialGuess;
// load next question if game is still running // load next question if game is still running
await Task.Delay(2000).ConfigureAwait(false); await Task.Delay(2000).ConfigureAwait(false);
@ -104,18 +104,25 @@ namespace NadekoBot.Modules.Games.Trivia
await End().ConfigureAwait(false); await End().ConfigureAwait(false);
} }
private async Task End() public async Task End()
{ {
ShouldStopGame = true; ShouldStopGame = true;
TriviaGame throwaway; TriviaGame throwaway;
Games.TriviaCommands.RunningTrivias.TryRemove(channel.Guild.Id, out throwaway); Games.TriviaCommands.RunningTrivias.TryRemove(channel.Guild.Id, out throwaway);
try { await channel.SendMessageAsync("**Trivia game ended**\n" + GetLeaderboard()).ConfigureAwait(false); } catch { } try
{
await channel.EmbedAsync(new EmbedBuilder().WithColor(NadekoBot.OkColor)
.WithTitle("Leaderboard")
.WithDescription(GetLeaderboard())
.Build(), "Trivia game ended.").ConfigureAwait(false);
}
catch { }
} }
public async Task StopGame() public async Task StopGame()
{ {
if (!ShouldStopGame) if (!ShouldStopGame)
try { await channel.SendMessageAsync(":exclamation: Trivia will stop after this question.").ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); } try { await channel.SendConfirmAsync(":exclamation: Trivia will stop after this question.").ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); }
ShouldStopGame = true; ShouldStopGame = true;
} }
@ -149,10 +156,10 @@ namespace NadekoBot.Modules.Games.Trivia
finally { _guessLock.Release(); } finally { _guessLock.Release(); }
if (!guess) return; if (!guess) return;
triviaCancelSource.Cancel(); triviaCancelSource.Cancel();
try { await channel.SendMessageAsync($"☑️ {guildUser.Mention} guessed it! The answer was: **{CurrentQuestion.Answer}**").ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); } try { await channel.SendConfirmAsync($"☑️ {guildUser.Mention} guessed it! The answer was: **{CurrentQuestion.Answer}**").ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); }
if (Users[guildUser] != WinRequirement) return; if (Users[guildUser] != WinRequirement) return;
ShouldStopGame = true; ShouldStopGame = true;
await channel.SendMessageAsync($":exclamation: We have a winner! It's {guildUser.Mention}.").ConfigureAwait(false); await channel.SendConfirmAsync($":exclamation: We have a winner! It's {guildUser.Mention}.").ConfigureAwait(false);
} }
catch (Exception ex) { _log.Warn(ex); } catch (Exception ex) { _log.Warn(ex); }
}); });
@ -165,7 +172,6 @@ namespace NadekoBot.Modules.Games.Trivia
return ""; return "";
var sb = new StringBuilder(); var sb = new StringBuilder();
sb.Append("**Leaderboard:**\n-----------\n");
foreach (var kvp in Users.OrderByDescending(kvp => kvp.Value)) foreach (var kvp in Users.OrderByDescending(kvp => kvp.Value))
{ {

View File

@ -1,6 +1,7 @@
using Discord; using Discord;
using Discord.Commands; using Discord.Commands;
using NadekoBot.Attributes; using NadekoBot.Attributes;
using NadekoBot.Extensions;
using NadekoBot.Modules.Games.Trivia; using NadekoBot.Modules.Games.Trivia;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
@ -36,12 +37,12 @@ namespace NadekoBot.Modules.Games
return; return;
var triviaGame = new TriviaGame(channel.Guild, (ITextChannel)umsg.Channel, showHints, number == 0 ? 10 : number); var triviaGame = new TriviaGame(channel.Guild, (ITextChannel)umsg.Channel, showHints, number == 0 ? 10 : number);
if (RunningTrivias.TryAdd(channel.Guild.Id, triviaGame)) if (RunningTrivias.TryAdd(channel.Guild.Id, triviaGame))
await channel.SendMessageAsync($"**Trivia game started! {triviaGame.WinRequirement} points needed to win.**").ConfigureAwait(false); await channel.SendConfirmAsync($"**Trivia game started! {triviaGame.WinRequirement} points needed to win.**").ConfigureAwait(false);
else else
await triviaGame.StopGame().ConfigureAwait(false); await triviaGame.StopGame().ConfigureAwait(false);
} }
else else
await channel.SendMessageAsync("Trivia game is already running on this server.\n" + trivia.CurrentQuestion).ConfigureAwait(false); await channel.SendErrorAsync("Trivia game is already running on this server.\n" + trivia.CurrentQuestion).ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -52,9 +53,9 @@ namespace NadekoBot.Modules.Games
TriviaGame trivia; TriviaGame trivia;
if (RunningTrivias.TryGetValue(channel.Guild.Id, out trivia)) if (RunningTrivias.TryGetValue(channel.Guild.Id, out trivia))
await channel.SendMessageAsync(trivia.GetLeaderboard()).ConfigureAwait(false); await channel.SendConfirmAsync("Leaderboard", trivia.GetLeaderboard()).ConfigureAwait(false);
else else
await channel.SendMessageAsync("No trivia is running on this server.").ConfigureAwait(false); await channel.SendErrorAsync("No trivia is running on this server.").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -64,12 +65,12 @@ namespace NadekoBot.Modules.Games
var channel = (ITextChannel)umsg.Channel; var channel = (ITextChannel)umsg.Channel;
TriviaGame trivia; TriviaGame trivia;
if (RunningTrivias.TryRemove(channel.Guild.Id, out trivia)) if (RunningTrivias.TryGetValue(channel.Guild.Id, out trivia))
{ {
await trivia.StopGame().ConfigureAwait(false); await trivia.StopGame().ConfigureAwait(false);
} }
else else
await channel.SendMessageAsync("No trivia is running on this server.").ConfigureAwait(false); await channel.SendErrorAsync("No trivia is running on this server.").ConfigureAwait(false);
} }
} }
} }

View File

@ -36,7 +36,7 @@ namespace NadekoBot.Modules.Games
if (listArr.Count() < 2) if (listArr.Count() < 2)
return; return;
var rng = new NadekoRandom(); var rng = new NadekoRandom();
await channel.SendMessageAsync(listArr[rng.Next(0, listArr.Length)]).ConfigureAwait(false); await channel.SendConfirmAsync("🤔", listArr[rng.Next(0, listArr.Length)]).ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -48,8 +48,11 @@ namespace NadekoBot.Modules.Games
if (string.IsNullOrWhiteSpace(question)) if (string.IsNullOrWhiteSpace(question))
return; return;
var rng = new NadekoRandom(); var rng = new NadekoRandom();
await channel.SendMessageAsync($@"❓ `Question` __**{question}**__
🎱 `8Ball Answers` __**{_8BallResponses.Shuffle().FirstOrDefault()}**__").ConfigureAwait(false); await channel.EmbedAsync(new EmbedBuilder().WithColor(NadekoBot.OkColor)
.AddField(efb => efb.WithName("❓ Question").WithValue(question).WithIsInline(false))
.AddField(efb => efb.WithName("🎱 8Ball").WithValue(_8BallResponses.Shuffle().FirstOrDefault()).WithIsInline(false))
.Build());
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -99,7 +102,7 @@ namespace NadekoBot.Modules.Games
else else
msg = $"{umsg.Author.Mention} won! {GetRPSPick(pick)} beats {GetRPSPick(nadekoPick)}"; msg = $"{umsg.Author.Mention} won! {GetRPSPick(pick)} beats {GetRPSPick(nadekoPick)}";
await channel.SendMessageAsync(msg).ConfigureAwait(false); await channel.SendConfirmAsync(msg).ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -108,7 +111,7 @@ namespace NadekoBot.Modules.Games
{ {
var channel = (ITextChannel)umsg.Channel; var channel = (ITextChannel)umsg.Channel;
await channel.SendMessageAsync( await channel.SendConfirmAsync(
$@"I'd just like to interject for moment. What you're refering to as {loonix}, is in fact, {guhnoo}/{loonix}, or as I've recently taken to calling it, {guhnoo} plus {loonix}. {loonix} is not an operating system unto itself, but rather another free component of a fully functioning {guhnoo} system made useful by the {guhnoo} corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX. $@"I'd just like to interject for moment. What you're refering to as {loonix}, is in fact, {guhnoo}/{loonix}, or as I've recently taken to calling it, {guhnoo} plus {loonix}. {loonix} is not an operating system unto itself, but rather another free component of a fully functioning {guhnoo} system made useful by the {guhnoo} corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX.
Many computer users run a modified version of the {guhnoo} system every day, without realizing it. Through a peculiar turn of events, the version of {guhnoo} which is widely used today is often called {loonix}, and many of its users are not aware that it is basically the {guhnoo} system, developed by the {guhnoo} Project. Many computer users run a modified version of the {guhnoo} system every day, without realizing it. Through a peculiar turn of events, the version of {guhnoo} which is widely used today is often called {loonix}, and many of its users are not aware that it is basically the {guhnoo} system, developed by the {guhnoo} Project.

View File

@ -523,7 +523,7 @@
}, },
{ {
"Category": "Acronym Soup", "Category": "Acronym Soup",
"Question": " BOS;big orange switch", "Question": " BOS",
"Answer": "boyfriend over shoulder" "Answer": "boyfriend over shoulder"
}, },
{ {
@ -1676,7 +1676,7 @@
"Answer": "Voyage of the Mimi" "Answer": "Voyage of the Mimi"
}, },
{ {
"Question": "Benazir Bhutto regained power in 1993 after being ousted how many years before;three", "Question": "Benazir Bhutto regained power in 1993 after being ousted how many years before",
"Answer": "3" "Answer": "3"
}, },
{ {
@ -5805,7 +5805,7 @@
"Answer": "pompidou" "Answer": "pompidou"
}, },
{ {
"Question": "In 1974 Soyuz ---------- is launched. ;fourteen", "Question": "In 1974 Soyuz ---------- is launched.",
"Answer": "14" "Answer": "14"
}, },
{ {
@ -5865,7 +5865,7 @@
"Answer": "fatima" "Answer": "fatima"
}, },
{ {
"Question": "In 1982 1st permanent artificial ---------- successfully implanted (U of Utah) in retired dentist Barney Clark; lived 112 days with the Jarvic-7 heart. ", "Question": "In 1982 1st permanent artificial ---------- successfully implanted (U of Utah) in retired dentist Barney Clark",
"Answer": "heart" "Answer": "heart"
}, },
{ {
@ -6186,7 +6186,7 @@
"Answer": "whitsun" "Answer": "whitsun"
}, },
{ {
"Question": "In the contract that gave cuba freedom from the us, what was required;permanent us navy base there", "Question": "In the contract that gave cuba freedom from the us, what was required",
"Answer": "permanent naval base" "Answer": "permanent naval base"
}, },
{ {
@ -7041,7 +7041,7 @@
}, },
{ {
"Category": "Music", "Category": "Music",
"Question": " what composer and organist was married twice and had 20 children;johann sebastian bach", "Question": " what composer and organist was married twice and had 20 children",
"Answer": "bach" "Answer": "bach"
}, },
{ {
@ -7414,12 +7414,12 @@
"Answer": "bones" "Answer": "bones"
}, },
{ {
"Question": "Other than the U.K. and Eire, name a European country where cars are driven on the left hand side of the road.;cyprus", "Question": "Other than the U.K. and Eire, name a European country where cars are driven on the left hand side of the road.",
"Answer": "malta" "Answer": "malta"
}, },
{ {
"Question": "Pagophobia is the fear of;ice", "Question": "Pagophobia is the fear of",
"Answer": "frost" "Answer": "ice"
}, },
{ {
"Question": "Pants", "Question": "Pants",
@ -7744,7 +7744,7 @@
"Answer": "parents-in-law" "Answer": "parents-in-law"
}, },
{ {
"Question": "Solar time what's the usual age for a jewish boy to celebrate his 'bar mitzvah';thirteen", "Question": "Solar time what's the usual age for a jewish boy to celebrate his 'bar mitzvah'",
"Answer": "13" "Answer": "13"
}, },
{ {
@ -7757,7 +7757,7 @@
"Answer": "immortality" "Answer": "immortality"
}, },
{ {
"Question": "Spectrophobia is the fear of;specters", "Question": "Spectrophobia is the fear of",
"Answer": "ghosts" "Answer": "ghosts"
}, },
{ {
@ -7871,8 +7871,8 @@
"Answer": "alaska" "Answer": "alaska"
}, },
{ {
"Question": "The canary islands in the pacific are named after what animal;dog", "Question": "The canary islands in the pacific are named after what animal",
"Answer": "dogs" "Answer": "dog"
}, },
{ {
"Question": "The childrens story 'The Rose and The Ring' was written by which 19th century novelist", "Question": "The childrens story 'The Rose and The Ring' was written by which 19th century novelist",
@ -7947,7 +7947,7 @@
"Answer": "galileo" "Answer": "galileo"
}, },
{ {
"Question": "The Irish Province of Connaught contains five counties. Sligo and Galway are two. Name one of the others. leitrim;mayo", "Question": "The Irish Province of Connaught contains five counties. Sligo, Mayo and Galway are three. Name one of the others.",
"Answer": "roscommon" "Answer": "roscommon"
}, },
{ {
@ -8035,8 +8035,8 @@
"Answer": "beard" "Answer": "beard"
}, },
{ {
"Question": "The ore pitchblende is the major source of which element;uranium", "Question": "The ore pitchblende is the major source of which element",
"Answer": "radium" "Answer": "uranium"
}, },
{ {
"Question": "The peace of Aix-la-Chapelle was celebrated by which piece of music", "Question": "The peace of Aix-la-Chapelle was celebrated by which piece of music",
@ -8171,7 +8171,7 @@
"Answer": "aardvark" "Answer": "aardvark"
}, },
{ {
"Question": "This company uses the slogan AOL;america on line", "Question": "This company uses the slogan AOL",
"Answer": "america online" "Answer": "america online"
}, },
{ {
@ -8251,7 +8251,7 @@
"Answer": "flies" "Answer": "flies"
}, },
{ {
"Question": "To the nearest minute, how long does it take sunlight to reach earth;eight", "Question": "To the nearest minute, how long does it take sunlight to reach earth",
"Answer": "8" "Answer": "8"
}, },
{ {
@ -8291,7 +8291,7 @@
"Answer": "mclaren" "Answer": "mclaren"
}, },
{ {
"Question": "To within 30 feet, how tall is the Eiffel Tower;nine hundred & eighty four", "Question": "To within 30 feet, how tall is the Eiffel Tower",
"Answer": "984" "Answer": "984"
}, },
{ {
@ -8337,8 +8337,8 @@
"Answer": "frigid" "Answer": "frigid"
}, },
{ {
"Question": "Unscramble the letters of the words 'no stamp' into a single english word;postman", "Question": "Unscramble the letters of the words 'no stamp' into a single english word.",
"Answer": "tampons" "Answer": "postman"
}, },
{ {
"Category": "UnScramble this Word", "Category": "UnScramble this Word",
@ -9760,7 +9760,7 @@
"Answer": "Augusta" "Answer": "Augusta"
}, },
{ {
"Question": "US Captials - Minnesota;St. Paul", "Question": "US Captials - Minnesota",
"Answer": "St Paul" "Answer": "St Paul"
}, },
{ {
@ -9805,7 +9805,7 @@
}, },
{ {
"Category": "Useless Facts", "Category": "Useless Facts",
"Question": " Banging your head against a wall can burn up to ----------- calories per hour.;one hundred and fifty", "Question": " Banging your head against a wall can burn up to ----------- calories per hour.",
"Answer": "150" "Answer": "150"
}, },
{ {
@ -9840,7 +9840,7 @@
}, },
{ {
"Category": "Useless Facts", "Category": "Useless Facts",
"Question": " It has been estimated that the typical American will spend an average of -------- years of his/her life reading newspapers.;two", "Question": " It has been estimated that the typical American will spend an average of -------- years of his/her life reading newspapers.",
"Answer": "2" "Answer": "2"
}, },
{ {
@ -9955,7 +9955,7 @@
}, },
{ {
"Category": "Useless Trivia", "Category": "Useless Trivia",
"Question": " A lifetime supply of all the vitamins you need weighs only about ---------- ounces.;eight", "Question": " A lifetime supply of all the vitamins you need weighs only about ---------- ounces.",
"Answer": "8" "Answer": "8"
}, },
{ {
@ -10045,7 +10045,7 @@
}, },
{ {
"Category": "Useless Trivia", "Category": "Useless Trivia",
"Question": " At birth a panda is smaller than a mouse and weighs about ---------- ounces.;four", "Question": " At birth a panda is smaller than a mouse and weighs about ---------- ounces.",
"Answer": "4" "Answer": "4"
}, },
{ {
@ -10160,7 +10160,7 @@
}, },
{ {
"Category": "Useless Trivia", "Category": "Useless Trivia",
"Question": " Gorillas often sleep for up to ---------- hours a day.;fourteen", "Question": " Gorillas often sleep for up to ---------- hours a day.",
"Answer": "14" "Answer": "14"
}, },
{ {
@ -10235,7 +10235,7 @@
}, },
{ {
"Category": "Useless Trivia", "Category": "Useless Trivia",
"Question": " In the Great Fire of London in 1666, half of London was burnt down but only ---------- people were injured.;six", "Question": " In the Great Fire of London in 1666, half of London was burnt down but only ---------- people were injured.",
"Answer": "6" "Answer": "6"
}, },
{ {
@ -10374,7 +10374,7 @@
}, },
{ {
"Category": "Video Games", "Category": "Video Games",
"Question": " 'Secret of Evermore' was entirely produced in which country?;U.S.A.;usa;America", "Question": " 'Secret of Evermore' was entirely produced in which country?",
"Answer": "United States" "Answer": "United States"
}, },
{ {
@ -10575,7 +10575,7 @@
"Answer": "swan" "Answer": "swan"
}, },
{ {
"Question": "What body of water is fed from the south by the Wadi Araba & from the north by the river Jordan;the dead sea", "Question": "What body of water is fed from the south by the Wadi Araba & from the north by the river Jordan",
"Answer": "dead sea" "Answer": "dead sea"
}, },
{ {
@ -10667,7 +10667,7 @@
"Answer": "black russian" "Answer": "black russian"
}, },
{ {
"Question": "What color is the blood of an octopus;pale bluish-green", "Question": "What color is the blood of an octopus",
"Answer": "bluish green" "Answer": "bluish green"
}, },
{ {
@ -11124,7 +11124,7 @@
"Answer": "fruit" "Answer": "fruit"
}, },
{ {
"Question": "What is 240 minutes in hours;four", "Question": "What is 240 minutes in hours",
"Answer": "4" "Answer": "4"
}, },
{ {
@ -11464,8 +11464,8 @@
"Answer": "five to seven" "Answer": "five to seven"
}, },
{ {
"Question": "What is the average temperature (f) at the South Pole;minus fifty six", "Question": "What is the average temperature (f) at the South Pole",
"Answer": "56" "Answer": "-56"
}, },
{ {
"Question": "What is the base twenty numbering system", "Question": "What is the base twenty numbering system",
@ -12318,7 +12318,7 @@
"Answer": "dreamt" "Answer": "dreamt"
}, },
{ {
"Question": "What is the point value of the 'f' in scrabble ;four", "Question": "What is the point value of the 'f' in scrabble",
"Answer": "4" "Answer": "4"
}, },
{ {
@ -12742,11 +12742,11 @@
"Answer": "gone with the wind" "Answer": "gone with the wind"
}, },
{ {
"Question": "What number does VII mean in roman numerals;seven", "Question": "What number does VII mean in roman numerals",
"Answer": "7" "Answer": "7"
}, },
{ {
"Question": "What number is at 6 oclock on a dartboard;three", "Question": "What number is at 6 oclock on a dartboard",
"Answer": "3" "Answer": "3"
}, },
{ {
@ -12798,7 +12798,7 @@
"Answer": "yucatan" "Answer": "yucatan"
}, },
{ {
"Question": "What percentage of alcohol is contained in a 100 proof mixture;fifty", "Question": "What percentage of alcohol is contained in a 100 proof mixture",
"Answer": "50" "Answer": "50"
}, },
{ {
@ -13035,8 +13035,8 @@
"Answer": "typhoon" "Answer": "typhoon"
}, },
{ {
"Question": "What structure in the back of the brain governs motor control;cerebellum", "Question": "What structure in the back of the brain governs motor contro",
"Answer": "the cerebellum" "Answer": "cerebellum"
}, },
{ {
"Question": "What style of dancing was popularized with rap music?", "Question": "What style of dancing was popularized with rap music?",
@ -13095,8 +13095,8 @@
"Answer": "bert and ernie" "Answer": "bert and ernie"
}, },
{ {
"Question": "What two countries were known as 'the yellow peril' in the 1890's ;china & japan", "Question": "What two countries were known as 'the yellow peril' in the 1890's",
"Answer": "japan & china" "Answer": "japan and china"
}, },
{ {
"Question": "What type of animal was selected to test the first electric toothbrush", "Question": "What type of animal was selected to test the first electric toothbrush",
@ -15659,7 +15659,7 @@
"Answer": "bugsy siegel" "Answer": "bugsy siegel"
}, },
{ {
"Question": "Whose grandson got the first phone call from a commercial cellular system, in 1983;alexander graham bell's;alexander graham bells", "Question": "Whose grandson got the first phone call from a commercial cellular system, in 1983",
"Answer": "alexander graham bell" "Answer": "alexander graham bell"
}, },
{ {