From 10b3aa9ad3052284a144ac7b174151448a30da54 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Fri, 14 Oct 2016 10:50:04 +0200 Subject: [PATCH] Fixed some plural currency forms, added .scr, .lcr now shows only triggers --- .../CustomReactions/CustomReactions.cs | 24 ++++++++++++++++++- src/NadekoBot/Modules/Gambling/Gambling.cs | 12 +++++----- .../Resources/CommandStrings.Designer.cs | 4 ++-- src/NadekoBot/Resources/CommandStrings.resx | 4 ++-- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/NadekoBot/Modules/CustomReactions/CustomReactions.cs b/src/NadekoBot/Modules/CustomReactions/CustomReactions.cs index a8c71001..e5ace4d2 100644 --- a/src/NadekoBot/Modules/CustomReactions/CustomReactions.cs +++ b/src/NadekoBot/Modules/CustomReactions/CustomReactions.cs @@ -124,10 +124,32 @@ namespace NadekoBot.Modules.CustomReactions if (customReactions == null || !customReactions.Any()) await imsg.Channel.SendMessageAsync("`No custom reactions found`").ConfigureAwait(false); else - await imsg.Channel.SendMessageAsync(string.Join("\n", customReactions.OrderBy(cr => cr.Trigger).Skip((page - 1) * 10).Take(10))) + await imsg.Channel.SendMessageAsync($"`Page {page} of custom reactions:`\n" + string.Join("\n", customReactions.OrderBy(cr => cr.Trigger).Skip((page - 1) * 15).Take(15).Select(cr => $"`#{cr.Id}` `Trigger:` {cr.Trigger}"))) .ConfigureAwait(false); } + [NadekoCommand, Usage, Description, Aliases] + public async Task ShowCustReact(IUserMessage imsg, int id) + { + var channel = imsg.Channel as ITextChannel; + + ConcurrentHashSet customReactions; + if (channel == null) + customReactions = GlobalReactions; + else + customReactions = GuildReactions.GetOrAdd(channel.Guild.Id, new ConcurrentHashSet()); + + var found = customReactions.FirstOrDefault(cr => cr.Id == id); + + if (found == null) + await imsg.Channel.SendMessageAsync("`No custom reaction found with that id.`").ConfigureAwait(false); + else + { + await imsg.Channel.SendMessageAsync($"`Custom reaction #{id}`\n`Trigger:` {found.Trigger}\n`Response:` {found.Response}") + .ConfigureAwait(false); + } + } + [NadekoCommand, Usage, Description, Aliases] public async Task DelCustReact(IUserMessage imsg, int id) { diff --git a/src/NadekoBot/Modules/Gambling/Gambling.cs b/src/NadekoBot/Modules/Gambling/Gambling.cs index 6335295f..41cb7d77 100644 --- a/src/NadekoBot/Modules/Gambling/Gambling.cs +++ b/src/NadekoBot/Modules/Gambling/Gambling.cs @@ -96,7 +96,7 @@ namespace NadekoBot.Modules.Gambling return; } await CurrencyHandler.AddCurrencyAsync(receiver, $"Gift from {umsg.Author.Username} ({umsg.Author.Id}).", amount, true).ConfigureAwait(false); - await channel.SendMessageAsync($"{umsg.Author.Mention} successfully sent {amount} {Gambling.CurrencyPluralName}s to {receiver.Mention}!").ConfigureAwait(false); + await channel.SendMessageAsync($"{umsg.Author.Mention} successfully sent {amount} {(amount == 1 ? Gambling.CurrencyName : Gambling.CurrencyPluralName)} to {receiver.Mention}!").ConfigureAwait(false); } [NadekoCommand, Usage, Description, Aliases] @@ -117,7 +117,7 @@ namespace NadekoBot.Modules.Gambling await CurrencyHandler.AddCurrencyAsync(usrId, $"Awarded by bot owner. ({umsg.Author.Username}/{umsg.Author.Id})", (int)amount).ConfigureAwait(false); - await channel.SendMessageAsync($"{umsg.Author.Mention} successfully awarded {amount} {Gambling.CurrencyName}s to <@{usrId}>!").ConfigureAwait(false); + await channel.SendMessageAsync($"{umsg.Author.Mention} successfully awarded {amount} {(amount == 1 ? Gambling.CurrencyName : Gambling.CurrencyPluralName)} to <@{usrId}>!").ConfigureAwait(false); } [NadekoCommand, Usage, Description, Aliases] @@ -130,9 +130,9 @@ namespace NadekoBot.Modules.Gambling return; if(await CurrencyHandler.RemoveCurrencyAsync(user, $"Taken by bot owner.({umsg.Author.Username}/{umsg.Author.Id})", amount, true).ConfigureAwait(false)) - await channel.SendMessageAsync($"{umsg.Author.Mention} successfully took {amount} {Gambling.CurrencyPluralName} from {user}!").ConfigureAwait(false); + await channel.SendMessageAsync($"{umsg.Author.Mention} successfully took {amount} {(amount == 1? Gambling.CurrencyName : Gambling.CurrencyPluralName)} from {user}!").ConfigureAwait(false); else - await channel.SendMessageAsync($"{umsg.Author.Mention} was unable to take {amount} {Gambling.CurrencyPluralName} from {user} because the user doesn't have that much {Gambling.CurrencyPluralName}!").ConfigureAwait(false); + await channel.SendMessageAsync($"{umsg.Author.Mention} was unable to take {amount} {(amount == 1 ? Gambling.CurrencyName : Gambling.CurrencyPluralName)} from {user} because the user doesn't have that much {Gambling.CurrencyPluralName}!").ConfigureAwait(false); } @@ -146,9 +146,9 @@ namespace NadekoBot.Modules.Gambling return; if(await CurrencyHandler.RemoveCurrencyAsync(usrId, $"Taken by bot owner.({umsg.Author.Username}/{umsg.Author.Id})", amount).ConfigureAwait(false)) - await channel.SendMessageAsync($"{umsg.Author.Mention} successfully took {amount} {Gambling.CurrencyName}s from <@{usrId}>!").ConfigureAwait(false); + await channel.SendMessageAsync($"{umsg.Author.Mention} successfully took {amount} {(amount == 1 ? Gambling.CurrencyName : Gambling.CurrencyPluralName)} from <@{usrId}>!").ConfigureAwait(false); else - await channel.SendMessageAsync($"{umsg.Author.Mention} was unable to take {amount} {Gambling.CurrencyPluralName} from `{usrId}` because the user doesn't have that much {Gambling.CurrencyPluralName}!").ConfigureAwait(false); + await channel.SendMessageAsync($"{umsg.Author.Mention} was unable to take {amount} {(amount == 1 ? Gambling.CurrencyName : Gambling.CurrencyPluralName)} from `{usrId}` because the user doesn't have that much {Gambling.CurrencyPluralName}!").ConfigureAwait(false); } [NadekoCommand, Usage, Description, Aliases] diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index d4e09b34..7e72bcb8 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -6171,7 +6171,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Shows all possible responses from a single custom reaction.. + /// Looks up a localized string similar to Shows a custom reaction's response on a given ID.. /// public static string showcustreact_desc { get { @@ -6180,7 +6180,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `.scr %mention% bb`. + /// Looks up a localized string similar to `.scr 1`. /// public static string showcustreact_usage { get { diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 1314fa26..2e58df86 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -454,10 +454,10 @@ showcustreact scr - Shows all possible responses from a single custom reaction. + Shows a custom reaction's response on a given ID. - `.scr %mention% bb` + `.scr 1` editcustreact ecr