From 524452e72e0a84a267b009aa3b2317aa5a2f3f0e Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Fri, 2 Jun 2017 03:44:59 +0200 Subject: [PATCH] Changed some commands names to avoid conflicts --- .../Modules/ClashOfClans/ClashOfClans.cs | 8 +- .../Modules/Gambling/Commands/DrawCommand.cs | 2 +- src/NadekoBot/Modules/Music/Music.cs | 4 +- src/NadekoBot/Modules/Searches/Searches.cs | 1 - .../Modules/Utility/Commands/QuoteCommands.cs | 2 +- src/NadekoBot/Modules/Utility/Utility.cs | 2 +- src/NadekoBot/NadekoBot.cs | 10 ++ src/NadekoBot/Resources/CommandStrings.resx | 109 ++++++++---------- src/NadekoBot/_Extensions/Extensions.cs | 6 + .../_Extensions/IEnumerableExtensions.cs | 15 +++ 10 files changed, 90 insertions(+), 69 deletions(-) create mode 100644 src/NadekoBot/_Extensions/IEnumerableExtensions.cs diff --git a/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs b/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs index b650304d..cb11dd29 100644 --- a/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs +++ b/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs @@ -117,7 +117,7 @@ namespace NadekoBot.Modules.ClashOfClans [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] - public async Task Claim(int number, int baseNumber, [Remainder] string other_name = null) + public async Task BaseCall(int number, int baseNumber, [Remainder] string other_name = null) { var warsInfo = _service.GetWarInfo(Context.Guild, number); if (warsInfo == null || warsInfo.Item1.Count == 0) @@ -144,21 +144,21 @@ namespace NadekoBot.Modules.ClashOfClans [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] - public async Task ClaimFinish1(int number, int baseNumber = 0) + public async Task CallFinish1(int number, int baseNumber = 0) { await FinishClaim(number, baseNumber - 1, 1); } [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] - public async Task ClaimFinish2(int number, int baseNumber = 0) + public async Task CallFinish2(int number, int baseNumber = 0) { await FinishClaim(number, baseNumber - 1, 2); } [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] - public async Task ClaimFinish(int number, int baseNumber = 0) + public async Task CallFinish(int number, int baseNumber = 0) { await FinishClaim(number, baseNumber - 1); } diff --git a/src/NadekoBot/Modules/Gambling/Commands/DrawCommand.cs b/src/NadekoBot/Modules/Gambling/Commands/DrawCommand.cs index 73f0eccb..71fc5285 100644 --- a/src/NadekoBot/Modules/Gambling/Commands/DrawCommand.cs +++ b/src/NadekoBot/Modules/Gambling/Commands/DrawCommand.cs @@ -60,7 +60,7 @@ namespace NadekoBot.Modules.Gambling [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] - public async Task ShuffleDeck() + public async Task DeckShuffle() { //var channel = (ITextChannel)Context.Channel; diff --git a/src/NadekoBot/Modules/Music/Music.cs b/src/NadekoBot/Modules/Music/Music.cs index 607ad8f9..89ddfde5 100644 --- a/src/NadekoBot/Modules/Music/Music.cs +++ b/src/NadekoBot/Modules/Music/Music.cs @@ -493,7 +493,7 @@ namespace NadekoBot.Modules.Music [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] [Priority(0)] - public Task Remove(int num) + public Task SongRemove(int num) { MusicPlayer musicPlayer; if ((musicPlayer = _music.GetPlayer(Context.Guild.Id)) == null) @@ -508,7 +508,7 @@ namespace NadekoBot.Modules.Music [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] [Priority(1)] - public async Task Remove(string all) + public async Task SongRemove(string all) { if (all.Trim().ToUpperInvariant() != "ALL") return; diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index 9acb7391..a4f1b93a 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -667,7 +667,6 @@ namespace NadekoBot.Modules.Searches await Context.Channel.EmbedAsync(new EmbedBuilder().WithOkColor() .AddField(efb => efb.WithName("Username").WithValue(usr.ToString()).WithIsInline(false)) .AddField(efb => efb.WithName("Avatar Url").WithValue(shortenedAvatarUrl).WithIsInline(false)) - //.AddField(efb => efb.WithName("Avatar Id").WithValue(usr.AvatarId).WithIsInline(false)) .WithThumbnailUrl(avatarUrl), Context.User.Mention).ConfigureAwait(false); } diff --git a/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs b/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs index 7522ec63..7ac9d21f 100644 --- a/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs +++ b/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs @@ -86,7 +86,7 @@ namespace NadekoBot.Modules.Utility [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] - public async Task SearchQuote(string keyword, [Remainder] string text) + public async Task QuoteSearch(string keyword, [Remainder] string text) { if (string.IsNullOrWhiteSpace(keyword) || string.IsNullOrWhiteSpace(text)) return; diff --git a/src/NadekoBot/Modules/Utility/Utility.cs b/src/NadekoBot/Modules/Utility/Utility.cs index 2d1d2601..09fe2b7e 100644 --- a/src/NadekoBot/Modules/Utility/Utility.cs +++ b/src/NadekoBot/Modules/Utility/Utility.cs @@ -260,7 +260,7 @@ namespace NadekoBot.Modules.Utility [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] - public async Task UserId(IGuildUser target = null) + public async Task UserId([Remainder] IGuildUser target = null) { var usr = target ?? Context.User; await ReplyConfirmLocalized("userid", "🆔", Format.Bold(usr.ToString()), diff --git a/src/NadekoBot/NadekoBot.cs b/src/NadekoBot/NadekoBot.cs index 4caacb78..14730245 100644 --- a/src/NadekoBot/NadekoBot.cs +++ b/src/NadekoBot/NadekoBot.cs @@ -25,6 +25,7 @@ using NadekoBot.Services.Administration; using NadekoBot.Services.Permissions; using NadekoBot.Services.Utility; using NadekoBot.Services.Help; +using NadekoBot.Extensions; namespace NadekoBot { @@ -256,6 +257,15 @@ namespace NadekoBot await commandHandler.StartHandling().ConfigureAwait(false); var _ = await CommandService.AddModulesAsync(this.GetType().GetTypeInfo().Assembly); + + + //Console.WriteLine(string.Join(", ", CommandService.Commands + // .Distinct(x => x.Name + x.Module.Name) + // .SelectMany(x => x.Aliases) + // .GroupBy(x => x) + // .Where(x => x.Count() > 1) + // .Select(x => x.Key + $"({x.Count()})"))); + #if GLOBAL_NADEKO //unload modules which are not available on the public bot CommandService diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 0cbb588c..962d9312 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -550,13 +550,13 @@ `{0}cr Awesome Role` - rolecolor rc + rolecolor roleclr Set a role's color to the hex or 0-255 rgb color value provided. - `{0}rc Admin 255 200 100` or `{0}rc Admin ffba55` + `{0}roleclr Admin 255 200 100` or `{0}roleclr Admin ffba55` ban b @@ -676,7 +676,7 @@ `{0}schn NewName` - prune clr + prune clear `{0}prune` removes all Nadeko's messages in the last 100 messages. `{0}prune X` removes last `X` number of messages from the channel (up to 100). `{0}prune @Someone` removes all Someone's messages in the last 100 messages. `{0}prune @Someone X` removes last `X` number of 'Someone's' messages in the channel. @@ -871,7 +871,7 @@ Shows user ID. - `{0}uid` or `{0}uid "@SomeGuy"` + `{0}uid` or `{0}uid @SomeGuy` channelid cid @@ -1143,13 +1143,13 @@ `{0}.. abc` - + qsearch - + Shows a random quote for a keyword that contains any text specified in the search. - + `{0}qsearch keyword text` @@ -1161,14 +1161,14 @@ `{0}qid 123456` - - deletequote delq + + quotedel qdel - + Deletes a quote with the specified ID. You have to be either server Administrator or the creator of the quote to delete it. - - `{0}delq 123456` + + `{0}qdel 123456` draw @@ -1180,13 +1180,13 @@ `{0}draw` or `{0}draw 5` - shuffle sh + playlistshuffle plsh Shuffles the current playlist. - `{0}sh` + `{0}plsh` flip @@ -1267,7 +1267,7 @@ Give someone a certain amount of currency. - `{0}give 1 "@SomeGuy"` + `{0}give 1 @SomeGuy` award @@ -1285,7 +1285,7 @@ Takes a certain amount of currency from someone. - `{0}take 1 "@someguy"` + `{0}take 1 @SomeGuy` betroll br @@ -1611,14 +1611,14 @@ `{0}mv` - - remove rm + + songremove srm - Remove a song by its # in the queue, or 'all' to remove whole queue. + Remove a song by its # in the queue, or 'all' to remove all songs from the queue. - `{0}rm 5` + `{0}srm 5` movesong ms @@ -2059,7 +2059,7 @@ Returns a Google reverse image search for someone's avatar. - `{0}revav "@SomeGuy"` + `{0}revav @SomeGuy` revimg @@ -2089,13 +2089,13 @@ `{0}wiki query` - color clr + color Shows you what color corresponds to that hex. - `{0}clr 00ff00` + `{0}color 00ff00` videocall @@ -2104,7 +2104,7 @@ Creates a private <http://www.appear.in> video call link for you and other mentioned people. The link is sent to mentioned people via a private message. - `{0}videocall "@SomeGuy"` + `{0}videocall "@the First" "@Xyz"` avatar av @@ -2113,7 +2113,7 @@ Shows a mentioned person's avatar. - `{0}av "@SomeGuy"` + `{0}av @SomeGuy` hentai @@ -2169,15 +2169,6 @@ `{0}e621 yuri kissing` - - cp - - - We all know where this will lead you to. - - - `{0}cp` - boobs @@ -2223,44 +2214,44 @@ `{0}lw [war_number]` or `{0}lw` - - claim call c + + basecall - + Claims a certain base from a certain war. You can supply a name in the third optional argument to claim in someone else's place. - - `{0}call [war_number] [base_number] [optional_other_name]` + + `{0}basecall [war_number] [base_number] [optional_other_name]` - - claimfinish cf + + callfinish cf - + Finish your claim with 3 stars if you destroyed a base. First argument is the war number, optional second argument is a base number if you want to finish for someone else. - + `{0}cf 1` or `{0}cf 1 5` - - claimfinish2 cf2 + + callfinish2 cf2 - + Finish your claim with 2 stars if you destroyed a base. First argument is the war number, optional second argument is a base number if you want to finish for someone else. - + `{0}cf2 1` or `{0}cf2 1 5` - - claimfinish1 cf1 + + callfinish1 cf1 - + Finish your claim with 1 star if you destroyed a base. First argument is the war number, optional second argument is a base number if you want to finish for someone else. - + `{0}cf1 1` or `{0}cf1 1 5` - unclaim ucall uc + uncall Removes your claim from a certain war. Optional second argument denotes a person in whose place to unclaim @@ -2335,10 +2326,10 @@ Check how much currency a person has. (Defaults to yourself) - `{0}$$` or `{0}$$ @SomeGuy` + `{0}$` or `{0}$ @SomeGuy` - cash $$ + $ currency $$ $$$ cash cur Lists whole permission chain with their indexes. You can specify an optional page number if there are a lot of permissions. @@ -2403,14 +2394,14 @@ `{0}se A message full of SPECIAL emojis` - - shuffle sh + + deckshuffle dsh - + Reshuffles all cards back into the deck. - - `{0}sh` + + `{0}dsh` fwmsgs diff --git a/src/NadekoBot/_Extensions/Extensions.cs b/src/NadekoBot/_Extensions/Extensions.cs index 1ae07a8d..d0eba8dd 100644 --- a/src/NadekoBot/_Extensions/Extensions.cs +++ b/src/NadekoBot/_Extensions/Extensions.cs @@ -18,6 +18,12 @@ namespace NadekoBot.Extensions { public static class Extensions { + public static void ThrowIfNull(this T obj, string name) where T : class + { + if (obj == null) + throw new ArgumentNullException(nameof(name)); + } + public static ConcurrentDictionary ToConcurrent(this IEnumerable> dict) => new ConcurrentDictionary(dict); diff --git a/src/NadekoBot/_Extensions/IEnumerableExtensions.cs b/src/NadekoBot/_Extensions/IEnumerableExtensions.cs new file mode 100644 index 00000000..fc930fe0 --- /dev/null +++ b/src/NadekoBot/_Extensions/IEnumerableExtensions.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NadekoBot.Extensions +{ + public static class IEnumerableExtensions + { + public static IEnumerable Distinct(this IEnumerable data, Func getKey) => + data.GroupBy(x => getKey(x)) + .Select(x => x.First()); + } +}