Fixed custom hangman categories. closes #1627 , Version upped.

This commit is contained in:
Master Kwoth 2017-09-29 16:37:26 +02:00
parent 44cac90e34
commit 7210b07e6e
6 changed files with 26 additions and 31 deletions

View File

@ -124,49 +124,49 @@ namespace NadekoBot.Modules.Administration
switch (type) switch (type)
{ {
case LogType.Other: case LogType.Other:
channelId = logSetting.LogOtherId = (logSetting.LogOtherId == null ? channel.Id : default(ulong?)); channelId = logSetting.LogOtherId = (logSetting.LogOtherId == null ? channel.Id : default);
break; break;
case LogType.MessageUpdated: case LogType.MessageUpdated:
channelId = logSetting.MessageUpdatedId = (logSetting.MessageUpdatedId == null ? channel.Id : default(ulong?)); channelId = logSetting.MessageUpdatedId = (logSetting.MessageUpdatedId == null ? channel.Id : default);
break; break;
case LogType.MessageDeleted: case LogType.MessageDeleted:
channelId = logSetting.MessageDeletedId = (logSetting.MessageDeletedId == null ? channel.Id : default(ulong?)); channelId = logSetting.MessageDeletedId = (logSetting.MessageDeletedId == null ? channel.Id : default);
break; break;
case LogType.UserJoined: case LogType.UserJoined:
channelId = logSetting.UserJoinedId = (logSetting.UserJoinedId == null ? channel.Id : default(ulong?)); channelId = logSetting.UserJoinedId = (logSetting.UserJoinedId == null ? channel.Id : default);
break; break;
case LogType.UserLeft: case LogType.UserLeft:
channelId = logSetting.UserLeftId = (logSetting.UserLeftId == null ? channel.Id : default(ulong?)); channelId = logSetting.UserLeftId = (logSetting.UserLeftId == null ? channel.Id : default);
break; break;
case LogType.UserBanned: case LogType.UserBanned:
channelId = logSetting.UserBannedId = (logSetting.UserBannedId == null ? channel.Id : default(ulong?)); channelId = logSetting.UserBannedId = (logSetting.UserBannedId == null ? channel.Id : default);
break; break;
case LogType.UserUnbanned: case LogType.UserUnbanned:
channelId = logSetting.UserUnbannedId = (logSetting.UserUnbannedId == null ? channel.Id : default(ulong?)); channelId = logSetting.UserUnbannedId = (logSetting.UserUnbannedId == null ? channel.Id : default);
break; break;
case LogType.UserUpdated: case LogType.UserUpdated:
channelId = logSetting.UserUpdatedId = (logSetting.UserUpdatedId == null ? channel.Id : default(ulong?)); channelId = logSetting.UserUpdatedId = (logSetting.UserUpdatedId == null ? channel.Id : default);
break; break;
case LogType.UserMuted: case LogType.UserMuted:
channelId = logSetting.UserMutedId = (logSetting.UserMutedId == null ? channel.Id : default(ulong?)); channelId = logSetting.UserMutedId = (logSetting.UserMutedId == null ? channel.Id : default);
break; break;
case LogType.ChannelCreated: case LogType.ChannelCreated:
channelId = logSetting.ChannelCreatedId = (logSetting.ChannelCreatedId == null ? channel.Id : default(ulong?)); channelId = logSetting.ChannelCreatedId = (logSetting.ChannelCreatedId == null ? channel.Id : default);
break; break;
case LogType.ChannelDestroyed: case LogType.ChannelDestroyed:
channelId = logSetting.ChannelDestroyedId = (logSetting.ChannelDestroyedId == null ? channel.Id : default(ulong?)); channelId = logSetting.ChannelDestroyedId = (logSetting.ChannelDestroyedId == null ? channel.Id : default);
break; break;
case LogType.ChannelUpdated: case LogType.ChannelUpdated:
channelId = logSetting.ChannelUpdatedId = (logSetting.ChannelUpdatedId == null ? channel.Id : default(ulong?)); channelId = logSetting.ChannelUpdatedId = (logSetting.ChannelUpdatedId == null ? channel.Id : default);
break; break;
case LogType.UserPresence: case LogType.UserPresence:
channelId = logSetting.LogUserPresenceId = (logSetting.LogUserPresenceId == null ? channel.Id : default(ulong?)); channelId = logSetting.LogUserPresenceId = (logSetting.LogUserPresenceId == null ? channel.Id : default);
break; break;
case LogType.VoicePresence: case LogType.VoicePresence:
channelId = logSetting.LogVoicePresenceId = (logSetting.LogVoicePresenceId == null ? channel.Id : default(ulong?)); channelId = logSetting.LogVoicePresenceId = (logSetting.LogVoicePresenceId == null ? channel.Id : default);
break; break;
case LogType.VoicePresenceTTS: case LogType.VoicePresenceTTS:
channelId = logSetting.LogVoicePresenceTTSId = (logSetting.LogVoicePresenceTTSId == null ? channel.Id : default(ulong?)); channelId = logSetting.LogVoicePresenceTTSId = (logSetting.LogVoicePresenceTTSId == null ? channel.Id : default);
break; break;
} }

View File

@ -192,7 +192,7 @@ namespace NadekoBot.Modules.Gambling
if (users.Count > 0) if (users.Count > 0)
{ {
await _cs.AddToManyAsync("", _amount, users.ToArray()).ConfigureAwait(false); await _cs.AddToManyAsync("Reaction Event", _amount, users.ToArray()).ConfigureAwait(false);
} }
users.Clear(); users.Clear();

View File

@ -56,9 +56,9 @@ namespace NadekoBot.Modules.Games.Common.Hangman
public Task EndedTask => _endingCompletionSource.Task; 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); this.Term = TermPool.GetTerm(type);
} }

View File

@ -3,7 +3,6 @@ using NadekoBot.Modules.Games.Common.Hangman.Exceptions;
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -25,21 +24,17 @@ namespace NadekoBot.Modules.Games.Common.Hangman
} }
} }
private static readonly ImmutableArray<TermType> _termTypes = Enum.GetValues(typeof(TermType)) public static HangmanObject GetTerm(string type)
.Cast<TermType>()
.ToImmutableArray();
public static HangmanObject GetTerm(TermType type)
{ {
var rng = new NadekoRandom(); var rng = new NadekoRandom();
if (type == TermType.Random) if (type == "random")
{ {
var keys = Data.Keys.ToArray(); 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(); throw new TermNotFoundException();
var obj = termTypes[rng.Next(0, termTypes.Length)]; var obj = termTypes[rng.Next(0, termTypes.Length)];

View File

@ -29,12 +29,12 @@ namespace NadekoBot.Modules.Games
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Hangmanlist() 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] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [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); var hm = new Hangman(type);

View File

@ -20,7 +20,7 @@ namespace NadekoBot.Services.Impl
private readonly IBotCredentials _creds; private readonly IBotCredentials _creds;
private readonly DateTime _started; 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 Author => "Kwoth#2560";
public string Library => "Discord.Net"; public string Library => "Discord.Net";