From 7210b07e6ee17ad543b1d131c1d3ed05eda25202 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Fri, 29 Sep 2017 16:37:26 +0200 Subject: [PATCH] Fixed custom hangman categories. closes #1627 , Version upped. --- .../Modules/Administration/LogCommands.cs | 30 +++++++++---------- .../Gambling/CurrencyEventsCommands.cs | 2 +- .../Modules/Games/Common/Hangman/Hangman.cs | 4 +-- .../Modules/Games/Common/Hangman/TermPool.cs | 15 ++++------ .../Modules/Games/HangmanCommands.cs | 4 +-- src/NadekoBot/Services/Impl/StatsService.cs | 2 +- 6 files changed, 26 insertions(+), 31 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/LogCommands.cs b/src/NadekoBot/Modules/Administration/LogCommands.cs index daffd9f7..c3415246 100644 --- a/src/NadekoBot/Modules/Administration/LogCommands.cs +++ b/src/NadekoBot/Modules/Administration/LogCommands.cs @@ -124,49 +124,49 @@ namespace NadekoBot.Modules.Administration switch (type) { case LogType.Other: - channelId = logSetting.LogOtherId = (logSetting.LogOtherId == null ? channel.Id : default(ulong?)); + channelId = logSetting.LogOtherId = (logSetting.LogOtherId == null ? channel.Id : default); break; case LogType.MessageUpdated: - channelId = logSetting.MessageUpdatedId = (logSetting.MessageUpdatedId == null ? channel.Id : default(ulong?)); + channelId = logSetting.MessageUpdatedId = (logSetting.MessageUpdatedId == null ? channel.Id : default); break; case LogType.MessageDeleted: - channelId = logSetting.MessageDeletedId = (logSetting.MessageDeletedId == null ? channel.Id : default(ulong?)); + channelId = logSetting.MessageDeletedId = (logSetting.MessageDeletedId == null ? channel.Id : default); break; case LogType.UserJoined: - channelId = logSetting.UserJoinedId = (logSetting.UserJoinedId == null ? channel.Id : default(ulong?)); + channelId = logSetting.UserJoinedId = (logSetting.UserJoinedId == null ? channel.Id : default); break; case LogType.UserLeft: - channelId = logSetting.UserLeftId = (logSetting.UserLeftId == null ? channel.Id : default(ulong?)); + channelId = logSetting.UserLeftId = (logSetting.UserLeftId == null ? channel.Id : default); break; case LogType.UserBanned: - channelId = logSetting.UserBannedId = (logSetting.UserBannedId == null ? channel.Id : default(ulong?)); + channelId = logSetting.UserBannedId = (logSetting.UserBannedId == null ? channel.Id : default); break; case LogType.UserUnbanned: - channelId = logSetting.UserUnbannedId = (logSetting.UserUnbannedId == null ? channel.Id : default(ulong?)); + channelId = logSetting.UserUnbannedId = (logSetting.UserUnbannedId == null ? channel.Id : default); break; case LogType.UserUpdated: - channelId = logSetting.UserUpdatedId = (logSetting.UserUpdatedId == null ? channel.Id : default(ulong?)); + channelId = logSetting.UserUpdatedId = (logSetting.UserUpdatedId == null ? channel.Id : default); break; case LogType.UserMuted: - channelId = logSetting.UserMutedId = (logSetting.UserMutedId == null ? channel.Id : default(ulong?)); + channelId = logSetting.UserMutedId = (logSetting.UserMutedId == null ? channel.Id : default); break; case LogType.ChannelCreated: - channelId = logSetting.ChannelCreatedId = (logSetting.ChannelCreatedId == null ? channel.Id : default(ulong?)); + channelId = logSetting.ChannelCreatedId = (logSetting.ChannelCreatedId == null ? channel.Id : default); break; case LogType.ChannelDestroyed: - channelId = logSetting.ChannelDestroyedId = (logSetting.ChannelDestroyedId == null ? channel.Id : default(ulong?)); + channelId = logSetting.ChannelDestroyedId = (logSetting.ChannelDestroyedId == null ? channel.Id : default); break; case LogType.ChannelUpdated: - channelId = logSetting.ChannelUpdatedId = (logSetting.ChannelUpdatedId == null ? channel.Id : default(ulong?)); + channelId = logSetting.ChannelUpdatedId = (logSetting.ChannelUpdatedId == null ? channel.Id : default); break; case LogType.UserPresence: - channelId = logSetting.LogUserPresenceId = (logSetting.LogUserPresenceId == null ? channel.Id : default(ulong?)); + channelId = logSetting.LogUserPresenceId = (logSetting.LogUserPresenceId == null ? channel.Id : default); break; case LogType.VoicePresence: - channelId = logSetting.LogVoicePresenceId = (logSetting.LogVoicePresenceId == null ? channel.Id : default(ulong?)); + channelId = logSetting.LogVoicePresenceId = (logSetting.LogVoicePresenceId == null ? channel.Id : default); break; case LogType.VoicePresenceTTS: - channelId = logSetting.LogVoicePresenceTTSId = (logSetting.LogVoicePresenceTTSId == null ? channel.Id : default(ulong?)); + channelId = logSetting.LogVoicePresenceTTSId = (logSetting.LogVoicePresenceTTSId == null ? channel.Id : default); break; } diff --git a/src/NadekoBot/Modules/Gambling/CurrencyEventsCommands.cs b/src/NadekoBot/Modules/Gambling/CurrencyEventsCommands.cs index 0ad3ddf9..2ebaba46 100644 --- a/src/NadekoBot/Modules/Gambling/CurrencyEventsCommands.cs +++ b/src/NadekoBot/Modules/Gambling/CurrencyEventsCommands.cs @@ -192,7 +192,7 @@ namespace NadekoBot.Modules.Gambling if (users.Count > 0) { - await _cs.AddToManyAsync("", _amount, users.ToArray()).ConfigureAwait(false); + await _cs.AddToManyAsync("Reaction Event", _amount, users.ToArray()).ConfigureAwait(false); } users.Clear(); diff --git a/src/NadekoBot/Modules/Games/Common/Hangman/Hangman.cs b/src/NadekoBot/Modules/Games/Common/Hangman/Hangman.cs index 6c91edc1..c3c7f9e9 100644 --- a/src/NadekoBot/Modules/Games/Common/Hangman/Hangman.cs +++ b/src/NadekoBot/Modules/Games/Common/Hangman/Hangman.cs @@ -56,9 +56,9 @@ namespace NadekoBot.Modules.Games.Common.Hangman public Task EndedTask => _endingCompletionSource.Task; - public Hangman(TermType type) + public Hangman(string type) { - this.TermType = type.ToString().Replace('_', ' ').ToTitleCase(); + this.TermType = type.Trim().ToLowerInvariant().ToTitleCase(); this.Term = TermPool.GetTerm(type); } diff --git a/src/NadekoBot/Modules/Games/Common/Hangman/TermPool.cs b/src/NadekoBot/Modules/Games/Common/Hangman/TermPool.cs index 94423b54..58ba56c4 100644 --- a/src/NadekoBot/Modules/Games/Common/Hangman/TermPool.cs +++ b/src/NadekoBot/Modules/Games/Common/Hangman/TermPool.cs @@ -3,7 +3,6 @@ using NadekoBot.Modules.Games.Common.Hangman.Exceptions; using Newtonsoft.Json; using System; using System.Collections.Generic; -using System.Collections.Immutable; using System.IO; using System.Linq; @@ -25,21 +24,17 @@ namespace NadekoBot.Modules.Games.Common.Hangman } } - private static readonly ImmutableArray _termTypes = Enum.GetValues(typeof(TermType)) - .Cast() - .ToImmutableArray(); - - public static HangmanObject GetTerm(TermType type) + public static HangmanObject GetTerm(string type) { var rng = new NadekoRandom(); - if (type == TermType.Random) + if (type == "random") { var keys = Data.Keys.ToArray(); - - type = _termTypes[rng.Next(0, _termTypes.Length - 1)]; // - 1 because last one is 'all' + + type = Data.Keys.ToArray()[rng.Next(0, Data.Keys.Count())]; } - if (!Data.TryGetValue(type.ToString(), out var termTypes) || termTypes.Length == 0) + if (!Data.TryGetValue(type, out var termTypes) || termTypes.Length == 0) throw new TermNotFoundException(); var obj = termTypes[rng.Next(0, termTypes.Length)]; diff --git a/src/NadekoBot/Modules/Games/HangmanCommands.cs b/src/NadekoBot/Modules/Games/HangmanCommands.cs index 4070bee1..f95f1a99 100644 --- a/src/NadekoBot/Modules/Games/HangmanCommands.cs +++ b/src/NadekoBot/Modules/Games/HangmanCommands.cs @@ -29,12 +29,12 @@ namespace NadekoBot.Modules.Games [RequireContext(ContextType.Guild)] public async Task Hangmanlist() { - await Context.Channel.SendConfirmAsync(Format.Code(GetText("hangman_types", Prefix)) + "\n" + string.Join(", ", TermPool.Data.Keys)); + await Context.Channel.SendConfirmAsync(Format.Code(GetText("hangman_types", Prefix)) + "\n" + string.Join("\n", TermPool.Data.Keys)); } [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] - public async Task Hangman([Remainder]TermType type = TermType.Random) + public async Task Hangman([Remainder]string type = "random") { var hm = new Hangman(type); diff --git a/src/NadekoBot/Services/Impl/StatsService.cs b/src/NadekoBot/Services/Impl/StatsService.cs index 82d312bf..6c8611e0 100644 --- a/src/NadekoBot/Services/Impl/StatsService.cs +++ b/src/NadekoBot/Services/Impl/StatsService.cs @@ -20,7 +20,7 @@ namespace NadekoBot.Services.Impl private readonly IBotCredentials _creds; private readonly DateTime _started; - public const string BotVersion = "1.10.1"; + public const string BotVersion = "1.10.2"; public string Author => "Kwoth#2560"; public string Library => "Discord.Net";