From 5da75c31b286b94f916b826b5ddcf774dd2d69e3 Mon Sep 17 00:00:00 2001 From: samvaio Date: Thu, 15 Jun 2017 09:54:42 +0530 Subject: [PATCH 01/15] Create Linux Guide.md Soundcloud api is no longer required. --- docs/guides/Linux Guide.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/guides/Linux Guide.md b/docs/guides/Linux Guide.md index f94c3f6e..acb61016 100644 --- a/docs/guides/Linux Guide.md +++ b/docs/guides/Linux Guide.md @@ -79,7 +79,6 @@ You will need the following for the next step: - **LoL Api Key** [(optional)](http://nadekobot.readthedocs.io/en/latest/JSON%20Explanations/#setting-up-your-api-keys) - **Mashape Key** [(optional)](http://nadekobot.readthedocs.io/en/latest/JSON%20Explanations/#setting-up-your-api-keys) - **Osu Api Key** [(optional)](http://nadekobot.readthedocs.io/en/latest/JSON%20Explanations/#setting-up-your-api-keys) -- **Sound Cloud Client Id** [(optional)](http://nadekobot.readthedocs.io/en/latest/JSON%20Explanations/#setting-up-your-api-keys) Once you have acquired them, press `5` to **Set up credentials.json** @@ -199,4 +198,4 @@ To set up Nadeko for music and Google API Keys, follow [Setting up your API keys [img7]: https://cdn.discordapp.com/attachments/251504306010849280/251505766370902016/setting_up_credentials.gif [setup credentials]: http://nadekobot.readthedocs.io/en/latest/JSON%20Explanations/#setting-up-credentialsjson-file [setup music]: http://nadekobot.readthedocs.io/en/latest/JSON%20Explanations/#setting-up-your-api-keys -[upgrading]: http://nadekobot.readthedocs.io/en/latest/guides/Upgrading%20Guide/ \ No newline at end of file +[upgrading]: http://nadekobot.readthedocs.io/en/latest/guides/Upgrading%20Guide/ From a0559b71305f345c87446ee002ae2346e710dc62 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Thu, 15 Jun 2017 13:09:55 +0200 Subject: [PATCH 02/15] patreon commands should be fixed --- src/NadekoBot/NadekoBot.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/NadekoBot/NadekoBot.cs b/src/NadekoBot/NadekoBot.cs index a2eede22..03617535 100644 --- a/src/NadekoBot/NadekoBot.cs +++ b/src/NadekoBot/NadekoBot.cs @@ -194,6 +194,7 @@ namespace NadekoBot .Add(repeaterService) .Add(converterService) .Add(verboseErrorsService) + .Add(patreonRewardsService) .Add(searchesService) .Add(streamNotificationService) .Add(animeSearchService) From e51d2bec2328d1998231f937c36e70c73386542e Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Thu, 15 Jun 2017 15:29:41 +0200 Subject: [PATCH 03/15] removed some unneeeded prints --- .../Modules/Administration/Administration.cs | 2 +- .../Commands/SelfAssignedRolesCommand.cs | 2 +- .../Games/Commands/Hangman/HangmanGame.cs | 2 +- .../Modules/Searches/Commands/LoLCommands.cs | 4 ++-- .../Searches/Commands/OverwatchCommands.cs | 1 - src/NadekoBot/NadekoBot.cs | 21 +++++++------------ .../ClashOfClans/ClashOfClansService.cs | 1 - .../Services/Games/ChatterBotSession.cs | 1 - src/NadekoBot/Services/Impl/BotCredentials.cs | 6 +++++- .../Services/Music/SoundCloudApiService.cs | 1 - .../Utility/MessageRepeaterService.cs | 1 - src/NadekoBot/_Extensions/Extensions.cs | 2 +- 12 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/Administration.cs b/src/NadekoBot/Modules/Administration/Administration.cs index 37defcd8..26491d0c 100644 --- a/src/NadekoBot/Modules/Administration/Administration.cs +++ b/src/NadekoBot/Modules/Administration/Administration.cs @@ -70,7 +70,7 @@ namespace NadekoBot.Modules.Administration catch (Exception ex) { await ReplyErrorLocalized("setrole_err").ConfigureAwait(false); - Console.WriteLine(ex.ToString()); + _log.Info(ex); } } diff --git a/src/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs b/src/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs index 6ac3c41f..9815fa1b 100644 --- a/src/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs +++ b/src/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs @@ -216,7 +216,7 @@ namespace NadekoBot.Modules.Administration catch (Exception ex) { await ReplyErrorLocalized("self_assign_perms").ConfigureAwait(false); - Console.WriteLine(ex); + _log.Info(ex); return; } var msg = await ReplyConfirmLocalized("self_assign_success",Format.Bold(role.Name)).ConfigureAwait(false); diff --git a/src/NadekoBot/Modules/Games/Commands/Hangman/HangmanGame.cs b/src/NadekoBot/Modules/Games/Commands/Hangman/HangmanGame.cs index 4793ea9b..376fe584 100644 --- a/src/NadekoBot/Modules/Games/Commands/Hangman/HangmanGame.cs +++ b/src/NadekoBot/Modules/Games/Commands/Hangman/HangmanGame.cs @@ -25,7 +25,7 @@ namespace NadekoBot.Modules.Games.Hangman } catch (Exception ex) { - Console.WriteLine(ex); + } } diff --git a/src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs b/src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs index 589eecaf..d7697a5c 100644 --- a/src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs @@ -173,7 +173,7 @@ namespace NadekoBot.Modules.Searches // .FirstOrDefault(jt => jt["role"].ToString() == role)?["general"]; // if (general == null) // { -// Console.WriteLine("General is null."); +// //Console.WriteLine("General is null."); // return; // } // //get build data for this role @@ -309,7 +309,7 @@ namespace NadekoBot.Modules.Searches // } // catch (Exception ex) // { -// Console.WriteLine(ex); +// //Console.WriteLine(ex); // await channel.SendMessageAsync("💢 Failed retreiving data for that champion.").ConfigureAwait(false); // } // }); diff --git a/src/NadekoBot/Modules/Searches/Commands/OverwatchCommands.cs b/src/NadekoBot/Modules/Searches/Commands/OverwatchCommands.cs index 75c880b0..98b7b583 100644 --- a/src/NadekoBot/Modules/Searches/Commands/OverwatchCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/OverwatchCommands.cs @@ -86,7 +86,6 @@ namespace NadekoBot.Modules.Searches { http.AddFakeHeaders(); var url = $"https://owapi.nadekobot.me/api/v3/u/{battletag}/stats"; - System.Console.WriteLine(url); var res = await http.GetStringAsync($"https://owapi.nadekobot.me/api/v3/u/{battletag}/stats"); var model = JsonConvert.DeserializeObject(res); switch (region) diff --git a/src/NadekoBot/NadekoBot.cs b/src/NadekoBot/NadekoBot.cs index 03617535..6bc2a657 100644 --- a/src/NadekoBot/NadekoBot.cs +++ b/src/NadekoBot/NadekoBot.cs @@ -331,23 +331,16 @@ namespace NadekoBot private static void SetupLogger() { - try + var logConfig = new LoggingConfiguration(); + var consoleTarget = new ColoredConsoleTarget() { - var logConfig = new LoggingConfiguration(); - var consoleTarget = new ColoredConsoleTarget() - { - Layout = @"${date:format=HH\:mm\:ss} ${logger} | ${message}" - }; - logConfig.AddTarget("Console", consoleTarget); + Layout = @"${date:format=HH\:mm\:ss} ${logger} | ${message}" + }; + logConfig.AddTarget("Console", consoleTarget); - logConfig.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, consoleTarget)); + logConfig.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, consoleTarget)); - LogManager.Configuration = logConfig; - } - catch (Exception ex) - { - Console.WriteLine(ex); - } + LogManager.Configuration = logConfig; } } } diff --git a/src/NadekoBot/Services/ClashOfClans/ClashOfClansService.cs b/src/NadekoBot/Services/ClashOfClans/ClashOfClansService.cs index 89a6c670..edb78512 100644 --- a/src/NadekoBot/Services/ClashOfClans/ClashOfClansService.cs +++ b/src/NadekoBot/Services/ClashOfClans/ClashOfClansService.cs @@ -128,7 +128,6 @@ namespace NadekoBot.Services.ClashOfClans SequenceNumber = i, }); } - Console.WriteLine(cw.Bases.Capacity); uow.ClashOfClans.Add(cw); await uow.CompleteAsync(); return cw; diff --git a/src/NadekoBot/Services/Games/ChatterBotSession.cs b/src/NadekoBot/Services/Games/ChatterBotSession.cs index 8d5e83a7..920ea709 100644 --- a/src/NadekoBot/Services/Games/ChatterBotSession.cs +++ b/src/NadekoBot/Services/Games/ChatterBotSession.cs @@ -30,7 +30,6 @@ namespace NadekoBot.Services.Games { var res = await http.GetStringAsync(string.Format(apiEndpoint, message)).ConfigureAwait(false); var cbr = JsonConvert.DeserializeObject(res); - //Console.WriteLine(cbr.Convo_id); return cbr.BotSay.Replace("
", "\n"); } } diff --git a/src/NadekoBot/Services/Impl/BotCredentials.cs b/src/NadekoBot/Services/Impl/BotCredentials.cs index 49eb56ec..828ed573 100644 --- a/src/NadekoBot/Services/Impl/BotCredentials.cs +++ b/src/NadekoBot/Services/Impl/BotCredentials.cs @@ -81,7 +81,11 @@ namespace NadekoBot.Services.Impl ulong.TryParse(data[nameof(ClientId)], out clId); ClientId = clId; - SoundCloudClientId = data[nameof(SoundCloudClientId)]; + var scId = data[nameof(SoundCloudClientId)]; + SoundCloudClientId = scId; + //SoundCloudClientId = string.IsNullOrWhiteSpace(scId) + // ? + // : scId; CarbonKey = data[nameof(CarbonKey)]; var dbSection = data.GetSection("db"); Db = new DBConfig(string.IsNullOrWhiteSpace(dbSection["Type"]) diff --git a/src/NadekoBot/Services/Music/SoundCloudApiService.cs b/src/NadekoBot/Services/Music/SoundCloudApiService.cs index 34240970..22a3ccda 100644 --- a/src/NadekoBot/Services/Music/SoundCloudApiService.cs +++ b/src/NadekoBot/Services/Music/SoundCloudApiService.cs @@ -27,7 +27,6 @@ namespace NadekoBot.Services.Music using (var http = new HttpClient()) { response = await http.GetStringAsync($"http://api.soundcloud.com/resolve?url={url}&client_id={_creds.SoundCloudClientId}").ConfigureAwait(false); - } diff --git a/src/NadekoBot/Services/Utility/MessageRepeaterService.cs b/src/NadekoBot/Services/Utility/MessageRepeaterService.cs index 9966969b..57873ef1 100644 --- a/src/NadekoBot/Services/Utility/MessageRepeaterService.cs +++ b/src/NadekoBot/Services/Utility/MessageRepeaterService.cs @@ -17,7 +17,6 @@ namespace NadekoBot.Services.Utility public MessageRepeaterService(NadekoBot bot, DiscordShardedClient client, IEnumerable gcs) { - System.Console.WriteLine(bot.Ready); var _ = Task.Run(async () => { while (!bot.Ready) diff --git a/src/NadekoBot/_Extensions/Extensions.cs b/src/NadekoBot/_Extensions/Extensions.cs index 362a1184..050903a2 100644 --- a/src/NadekoBot/_Extensions/Extensions.cs +++ b/src/NadekoBot/_Extensions/Extensions.cs @@ -94,7 +94,7 @@ namespace NadekoBot.Extensions } } } - catch (Exception ex) { Console.WriteLine(ex); } + catch (Exception ex) { } }; using (msg.OnReaction(client, changePage, changePage)) From dd1d21e29c1f09eef7c3bc3fd9dad05db628fd0b Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Thu, 15 Jun 2017 18:56:35 +0200 Subject: [PATCH 04/15] .scq fixed, local soundcloud api keys are no longer used, .scpl fix is coming soon:tm: --- src/NadekoBot/Modules/Music/Music.cs | 4 ++-- src/NadekoBot/Services/Music/MusicService.cs | 4 ++-- src/NadekoBot/Services/Music/SoundCloudApiService.cs | 12 +++++++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/NadekoBot/Modules/Music/Music.cs b/src/NadekoBot/Modules/Music/Music.cs index afb34192..86d7b4a6 100644 --- a/src/NadekoBot/Modules/Music/Music.cs +++ b/src/NadekoBot/Modules/Music/Music.cs @@ -431,7 +431,7 @@ namespace NadekoBot.Modules.Music using (var http = new HttpClient()) { - var scvids = JObject.Parse(await http.GetStringAsync($"http://api.soundcloud.com/resolve?url={pl}&client_id={_creds.SoundCloudClientId}").ConfigureAwait(false))["tracks"].ToObject(); + var scvids = JObject.Parse(await http.GetStringAsync($"http://scapi.nadekobot.me/resolve?url={pl}").ConfigureAwait(false))["tracks"].ToObject(); await _music.QueueSong(((IGuildUser)Context.User), (ITextChannel)Context.Channel, ((IGuildUser)Context.User).VoiceChannel, scvids[0].TrackLink).ConfigureAwait(false); MusicPlayer musicPlayer; @@ -446,7 +446,7 @@ namespace NadekoBot.Modules.Music { Title = svideo.FullName, Provider = "SoundCloud", - Uri = svideo.GetStreamLink(_creds), + Uri = await svideo.StreamLink(), ProviderType = MusicType.Normal, Query = svideo.TrackLink, }), ((IGuildUser)Context.User).Username); diff --git a/src/NadekoBot/Services/Music/MusicService.cs b/src/NadekoBot/Services/Music/MusicService.cs index 06748412..9ea7a958 100644 --- a/src/NadekoBot/Services/Music/MusicService.cs +++ b/src/NadekoBot/Services/Music/MusicService.cs @@ -281,7 +281,7 @@ namespace NadekoBot.Services.Music { Title = svideo.FullName, Provider = "SoundCloud", - Uri = svideo.GetStreamLink(_creds), + Uri = await svideo.StreamLink(), ProviderType = musicType, Query = svideo.TrackLink, AlbumArt = svideo.artwork_url, @@ -296,7 +296,7 @@ namespace NadekoBot.Services.Music { Title = svideo.FullName, Provider = "SoundCloud", - Uri = svideo.GetStreamLink(_creds), + Uri = await svideo.StreamLink(), ProviderType = MusicType.Soundcloud, Query = svideo.TrackLink, AlbumArt = svideo.artwork_url, diff --git a/src/NadekoBot/Services/Music/SoundCloudApiService.cs b/src/NadekoBot/Services/Music/SoundCloudApiService.cs index 22a3ccda..55a343f8 100644 --- a/src/NadekoBot/Services/Music/SoundCloudApiService.cs +++ b/src/NadekoBot/Services/Music/SoundCloudApiService.cs @@ -26,7 +26,7 @@ namespace NadekoBot.Services.Music using (var http = new HttpClient()) { - response = await http.GetStringAsync($"http://api.soundcloud.com/resolve?url={url}&client_id={_creds.SoundCloudClientId}").ConfigureAwait(false); + response = await http.GetStringAsync($"https://scapi.nadekobot.me/resolve?url={url}").ConfigureAwait(false); } @@ -50,7 +50,7 @@ namespace NadekoBot.Services.Music var response = ""; using (var http = new HttpClient()) { - response = await http.GetStringAsync($"http://api.soundcloud.com/tracks?q={Uri.EscapeDataString(query)}&client_id={_creds.SoundCloudClientId}").ConfigureAwait(false); + response = await http.GetStringAsync($"https://scapi.nadekobot.me/tracks?q={Uri.EscapeDataString(query)}").ConfigureAwait(false); } var responseObj = JsonConvert.DeserializeObject(response).Where(s => s.Streamable).FirstOrDefault(); @@ -74,7 +74,13 @@ namespace NadekoBot.Services.Music [JsonProperty("permalink_url")] public string TrackLink { get; set; } = ""; public string artwork_url { get; set; } = ""; - public string GetStreamLink(IBotCredentials creds) => $"https://api.soundcloud.com/tracks/{Id}/stream?client_id={creds.SoundCloudClientId}"; + public async Task StreamLink() + { + using (var http = new HttpClient()) + { + return await http.GetStringAsync($"http://scapi.nadekobot.me/stream/{Id}"); + } + } } public class SoundCloudUser { From 809219acc35177e9d4c2273d4bac2286870aac9d Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Thu, 15 Jun 2017 19:16:50 +0200 Subject: [PATCH 05/15] global nadeko compilation issue --- src/NadekoBot/Modules/Games/Commands/Hangman/HangmanGame.cs | 4 ++-- src/NadekoBot/Modules/Music/Music.cs | 2 +- src/NadekoBot/NadekoBot.cs | 5 +++-- src/NadekoBot/_Extensions/Extensions.cs | 5 ++++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/NadekoBot/Modules/Games/Commands/Hangman/HangmanGame.cs b/src/NadekoBot/Modules/Games/Commands/Hangman/HangmanGame.cs index 376fe584..7cecf927 100644 --- a/src/NadekoBot/Modules/Games/Commands/Hangman/HangmanGame.cs +++ b/src/NadekoBot/Modules/Games/Commands/Hangman/HangmanGame.cs @@ -23,9 +23,9 @@ namespace NadekoBot.Modules.Games.Hangman { data = JsonConvert.DeserializeObject>(File.ReadAllText(termsPath)); } - catch (Exception ex) + catch (Exception) { - + //ignored } } diff --git a/src/NadekoBot/Modules/Music/Music.cs b/src/NadekoBot/Modules/Music/Music.cs index 86d7b4a6..afd60bb2 100644 --- a/src/NadekoBot/Modules/Music/Music.cs +++ b/src/NadekoBot/Modules/Music/Music.cs @@ -431,7 +431,7 @@ namespace NadekoBot.Modules.Music using (var http = new HttpClient()) { - var scvids = JObject.Parse(await http.GetStringAsync($"http://scapi.nadekobot.me/resolve?url={pl}").ConfigureAwait(false))["tracks"].ToObject(); + var scvids = JObject.Parse(await http.GetStringAsync($"https://scapi.nadekobot.me/resolve?url={pl}").ConfigureAwait(false))["tracks"].ToObject(); await _music.QueueSong(((IGuildUser)Context.User), (ITextChannel)Context.Channel, ((IGuildUser)Context.User).VoiceChannel, scvids[0].TrackLink).ConfigureAwait(false); MusicPlayer musicPlayer; diff --git a/src/NadekoBot/NadekoBot.cs b/src/NadekoBot/NadekoBot.cs index 6bc2a657..59c6196d 100644 --- a/src/NadekoBot/NadekoBot.cs +++ b/src/NadekoBot/NadekoBot.cs @@ -27,6 +27,7 @@ using NadekoBot.Services.Utility; using NadekoBot.Services.Help; using System.IO; using NadekoBot.Services.Pokemon; +using NadekoBot.DataStructures; namespace NadekoBot { @@ -279,7 +280,7 @@ namespace NadekoBot 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) @@ -287,8 +288,8 @@ namespace NadekoBot // .Where(x => x.Count() > 1) // .Select(x => x.Key + $"({x.Count()})"))); +//unload modules which are not available on the public bot #if GLOBAL_NADEKO - //unload modules which are not available on the public bot CommandService .Modules .ToArray() diff --git a/src/NadekoBot/_Extensions/Extensions.cs b/src/NadekoBot/_Extensions/Extensions.cs index 050903a2..4520ebd4 100644 --- a/src/NadekoBot/_Extensions/Extensions.cs +++ b/src/NadekoBot/_Extensions/Extensions.cs @@ -94,7 +94,10 @@ namespace NadekoBot.Extensions } } } - catch (Exception ex) { } + catch (Exception) + { + //ignored + } }; using (msg.OnReaction(client, changePage, changePage)) From 06693b9b34eb4b4e0861431d7bc41e35285373af Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Thu, 15 Jun 2017 19:18:55 +0200 Subject: [PATCH 06/15] another fix --- src/NadekoBot/NadekoBot.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/NadekoBot/NadekoBot.cs b/src/NadekoBot/NadekoBot.cs index 59c6196d..1279730d 100644 --- a/src/NadekoBot/NadekoBot.cs +++ b/src/NadekoBot/NadekoBot.cs @@ -28,6 +28,7 @@ using NadekoBot.Services.Help; using System.IO; using NadekoBot.Services.Pokemon; using NadekoBot.DataStructures; +using NadekoBot.Extensions; namespace NadekoBot { From 4e7b7a6ee5ef2b5009d2ce7590c92ed545e98a55 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Thu, 15 Jun 2017 20:04:15 +0200 Subject: [PATCH 07/15] invalid hex error --- src/NadekoBot/Modules/Searches/Searches.cs | 14 +++++++++++++- .../Services/Administration/VplusTService.cs | 17 ++++++----------- .../_strings/ResponseStrings.en-US.json | 1 + 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index 8e1b2a2c..b7886f44 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -637,9 +637,21 @@ namespace NadekoBot.Modules.Searches color = color?.Trim().Replace("#", ""); if (string.IsNullOrWhiteSpace(color)) return; + ImageSharp.Color clr; + try + { + clr = ImageSharp.Color.FromHex(color); + } + catch + { + await ReplyErrorLocalized("hex_invalid").ConfigureAwait(false); + return; + } + + var img = new ImageSharp.Image(50, 50); - img.BackgroundColor(ImageSharp.Color.FromHex(color)); + img.BackgroundColor(clr); await Context.Channel.SendFileAsync(img.ToStream(), $"{color}.png").ConfigureAwait(false); } diff --git a/src/NadekoBot/Services/Administration/VplusTService.cs b/src/NadekoBot/Services/Administration/VplusTService.cs index 469aab02..3d9e86cd 100644 --- a/src/NadekoBot/Services/Administration/VplusTService.cs +++ b/src/NadekoBot/Services/Administration/VplusTService.cs @@ -93,16 +93,11 @@ namespace NadekoBot.Services.Administration var beforeRoleName = GetRoleName(beforeVch); var beforeRole = guild.Roles.FirstOrDefault(x => x.Name == beforeRoleName); if (beforeRole != null) - try - { - _log.Info("Removing role " + beforeRoleName + " from user " + user.Username); - await user.RemoveRoleAsync(beforeRole).ConfigureAwait(false); - await Task.Delay(200).ConfigureAwait(false); - } - catch (Exception ex) - { - _log.Warn(ex); - } + { + _log.Info("Removing role " + beforeRoleName + " from user " + user.Username); + await user.RemoveRoleAsync(beforeRole).ConfigureAwait(false); + await Task.Delay(200).ConfigureAwait(false); + } } var afterVch = after.VoiceChannel; if (afterVch != null && guild.AFKChannel?.Id != afterVch.Id) @@ -130,7 +125,7 @@ namespace NadekoBot.Services.Administration .ConfigureAwait(false); await Task.Delay(50).ConfigureAwait(false); } - _log.Warn("Adding role " + roleToAdd.Name + " to user " + user.Username); + _log.Info("Adding role " + roleToAdd.Name + " to user " + user.Username); await user.AddRoleAsync(roleToAdd).ConfigureAwait(false); } } diff --git a/src/NadekoBot/_strings/ResponseStrings.en-US.json b/src/NadekoBot/_strings/ResponseStrings.en-US.json index cca1c577..2aef3353 100644 --- a/src/NadekoBot/_strings/ResponseStrings.en-US.json +++ b/src/NadekoBot/_strings/ResponseStrings.en-US.json @@ -534,6 +534,7 @@ "searches_hashtag_error": "Failed finding a definition for that tag.", "searches_height_weight": "Height/Weight", "searches_height_weight_val": "{0}m/{1}kg", + "searches_hex_invalid": "Invalid color specified.", "searches_humidity": "Humidity", "searches_image_search_for": "Image search for:", "searches_imdb_fail": "Failed to find that movie.", From 3bf224ab57601f2cac84bbdf72bda3556086c717 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Thu, 15 Jun 2017 20:20:34 +0200 Subject: [PATCH 08/15] .resetglobalperms .resetperms fixed --- src/NadekoBot/Modules/Gambling/Gambling.cs | 4 ++++ .../Modules/Permissions/Commands/ResetPermissionsCommands.cs | 2 +- src/NadekoBot/NadekoBot.cs | 2 +- src/NadekoBot/_strings/ResponseStrings.en-US.json | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/NadekoBot/Modules/Gambling/Gambling.cs b/src/NadekoBot/Modules/Gambling/Gambling.cs index 2b9cc67e..9fe01df2 100644 --- a/src/NadekoBot/Modules/Gambling/Gambling.cs +++ b/src/NadekoBot/Modules/Gambling/Gambling.cs @@ -43,6 +43,10 @@ namespace NadekoBot.Modules.Gambling var members = role.Members().Where(u => u.Status != UserStatus.Offline); var membersArray = members as IUser[] ?? members.ToArray(); + if (membersArray.Length == 0) + { + + } var usr = membersArray[new NadekoRandom().Next(0, membersArray.Length)]; await Context.Channel.SendConfirmAsync("🎟 "+ GetText("raffled_user"), $"**{usr.Username}#{usr.Discriminator}**", footer: $"ID: {usr.Id}").ConfigureAwait(false); } diff --git a/src/NadekoBot/Modules/Permissions/Commands/ResetPermissionsCommands.cs b/src/NadekoBot/Modules/Permissions/Commands/ResetPermissionsCommands.cs index 0ecb39f1..049b4782 100644 --- a/src/NadekoBot/Modules/Permissions/Commands/ResetPermissionsCommands.cs +++ b/src/NadekoBot/Modules/Permissions/Commands/ResetPermissionsCommands.cs @@ -6,7 +6,7 @@ using NadekoBot.Services.Database.Models; using NadekoBot.Services.Permissions; using System.Threading.Tasks; -namespace NadekoBot.Modules.Permissions.Commands +namespace NadekoBot.Modules.Permissions { public partial class Permissions { diff --git a/src/NadekoBot/NadekoBot.cs b/src/NadekoBot/NadekoBot.cs index 1279730d..6408ce93 100644 --- a/src/NadekoBot/NadekoBot.cs +++ b/src/NadekoBot/NadekoBot.cs @@ -290,7 +290,7 @@ namespace NadekoBot // .Select(x => x.Key + $"({x.Count()})"))); //unload modules which are not available on the public bot -#if GLOBAL_NADEKO +#if GLOBAL_NADEKO CommandService .Modules .ToArray() diff --git a/src/NadekoBot/_strings/ResponseStrings.en-US.json b/src/NadekoBot/_strings/ResponseStrings.en-US.json index 2aef3353..98df2300 100644 --- a/src/NadekoBot/_strings/ResponseStrings.en-US.json +++ b/src/NadekoBot/_strings/ResponseStrings.en-US.json @@ -153,7 +153,7 @@ "administration_old_nick": "Old nickname", "administration_old_topic": "Old topic", "administration_perms": "Error. Most likely I don't have sufficient permissions.", - "administration_perms_reset": "Permissions for this server are reset.", + "permissions_perms_reset": "Permissions for this server are reset.", "administration_prot_active": "Active protections", "administration_prot_disable": "{0} has been **disabled** on this server.", "administration_prot_enable": "{0} Enabled", @@ -765,7 +765,7 @@ "gambling_shop_role": "You will get {0} role.", "gambling_type": "Type", "utility_clpa_next_update": "Next update in {0}", - "administration_global_perms_reset": "Global permissions have been reset.", + "permissions_global_perms_reset": "Global permissions have been reset.", "administration_gvc_disabled": "Game Voice Channel feature has been disabled on this server.", "administration_gvc_enabled": "{0} is a Game Voice Channel now.", "administration_not_in_voice": "You are not in a voice channel on this server.", From fa58bad1499f853409ee4b654864c51472caf167 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Thu, 15 Jun 2017 22:35:12 +0200 Subject: [PATCH 09/15] fixed .qdel and greetdmmessage if it's an embed, thanks to gwen lol --- src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs | 2 +- src/NadekoBot/Services/GreetSettingsService.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs b/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs index 7ac9d21f..5ac2e69a 100644 --- a/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs +++ b/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs @@ -170,7 +170,7 @@ namespace NadekoBot.Modules.Utility [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] - public async Task DeleteQuote(int id) + public async Task QuoteDelete(int id) { var isAdmin = ((IGuildUser) Context.Message.Author).GuildPermissions.Administrator; diff --git a/src/NadekoBot/Services/GreetSettingsService.cs b/src/NadekoBot/Services/GreetSettingsService.cs index 7e5c8128..6e2e630d 100644 --- a/src/NadekoBot/Services/GreetSettingsService.cs +++ b/src/NadekoBot/Services/GreetSettingsService.cs @@ -141,7 +141,7 @@ namespace NadekoBot.Services if (channel != null) { CREmbed embedData; - if (CREmbed.TryParse(conf.ChannelGreetMessageText, out embedData)) + if (CREmbed.TryParse(conf.DmGreetMessageText, out embedData)) { embedData.PlainText = embedData.PlainText?.Replace("%user%", user.ToString()).Replace("%id%", user.Id.ToString()).Replace("%server%", user.Guild.Name); embedData.Description = embedData.Description?.Replace("%user%", user.ToString()).Replace("%id%", user.Id.ToString()).Replace("%server%", user.Guild.Name); From 3cfe783ac9f4e5e17348a590ab94fc62930f4dea Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Fri, 16 Jun 2017 00:43:35 +0200 Subject: [PATCH 10/15] .$ should be now usable in dms --- src/NadekoBot/Modules/Gambling/Gambling.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/NadekoBot/Modules/Gambling/Gambling.cs b/src/NadekoBot/Modules/Gambling/Gambling.cs index 9fe01df2..500319ca 100644 --- a/src/NadekoBot/Modules/Gambling/Gambling.cs +++ b/src/NadekoBot/Modules/Gambling/Gambling.cs @@ -53,7 +53,6 @@ namespace NadekoBot.Modules.Gambling [NadekoCommand, Usage, Description, Aliases] [Priority(0)] - [RequireContext(ContextType.Guild)] public async Task Cash([Remainder] IUser user = null) { if(user == null) From f56b6f804a0d8664191a192274c53c871b1e96f8 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Fri, 16 Jun 2017 00:44:54 +0200 Subject: [PATCH 11/15] fixed issues and updated commandlist --- docs/Commands List.md | 9 ++++++--- src/NadekoBot/Resources/CommandStrings.resx | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/Commands List.md b/docs/Commands List.md index f69cc211..d90dd900 100644 --- a/docs/Commands List.md +++ b/docs/Commands List.md @@ -181,7 +181,7 @@ Commands and aliases | Description | Usage `.claimwaifu` `.claim` | Claim a waifu for yourself by spending currency. You must spend at least 10% more than her current value unless she set `.affinity` towards you. | `.claim 50 @Himesama` `.divorce` | Releases your claim on a specific waifu. You will get some of the money you've spent back unless that waifu has an affinity towards you. 6 hours cooldown. | `.divorce @CheatingSloot` `.affinity` | Sets your affinity towards someone you want to be claimed by. Setting affinity will reduce their `.claim` on you by 20%. You can leave second argument empty to clear your affinity. 30 minutes cooldown. | `.affinity @MyHusband` or `.affinity` -`.waifus` `.waifulb` | Shows top 9 waifus. | `.waifus` +`.waifus` `.waifulb` | Shows top 9 waifus. You can specify another page to show other waifus. | `.waifus` or `.waifulb 3` `.waifuinfo` `.waifustats` | Shows waifu stats for a target person. Defaults to you if no user is provided. | `.waifuinfo @MyCrush` or `.waifuinfo` ###### [Back to ToC](#table-of-contents) @@ -197,7 +197,7 @@ Commands and aliases | Description | Usage `.linux` | Prints a customizable Linux interjection | `.linux Spyware Windows` `.acrophobia` `.acro` | Starts an Acrophobia game. Second argument is optional round length in seconds. (default is 60) | `.acro` or `.acro 30` `.cleverbot` | Toggles cleverbot session. When enabled, the bot will reply to messages starting with bot mention in the server. Custom reactions starting with %mention% won't work if cleverbot is enabled. **Requires ManageMessages server permission.** | `.cleverbot` -`.hangmanlist` | Shows a list of hangman term types. | `. hangmanlist` +`.hangmanlist` | Shows a list of hangman term types. | `.hangmanlist` `.hangman` | Starts a game of hangman in the channel. Use `.hangmanlist` to see a list of available term types. Defaults to 'all'. | `.hangman` or `.hangman movies` `.pick` | Picks the currency planted in this channel. 60 seconds cooldown. | `.pick` `.plant` | Spend an amount of currency to plant it in this channel. Default is 1. (If bot is restarted or crashes, the currency will be lost) | `.plant` or `.plant 5` @@ -239,6 +239,7 @@ Commands and aliases | Description | Usage `.pause` `.p` | Pauses or Unpauses the song. | `.p` `.fairplay` `.fp` | Toggles fairplay. While enabled, the bot will prioritize songs from users who didn't have their song recently played instead of the song's position in the queue. | `.fp` `.queue` `.q` `.yq` | Queue a song using keywords or a link. Bot will join your voice channel. **You must be in a voice channel**. | `.q Dream Of Venice` +`.queuesearch` `.qs` `.yqs` | Search for top 5 youtube song result using keywords, and type the index of the song to play that song. Bot will join your voice channel. **You must be in a voice channel**. | `.qs Dream Of Venice` `.soundcloudqueue` `.sq` | Queue a soundcloud song using keywords. Bot will join your voice channel. **You must be in a voice channel**. | `.sq Dream Of Venice` `.listqueue` `.lq` | Lists 15 currently queued songs per page. Default page is 1. | `.lq` or `.lq 2` `.nowplaying` `.np` | Shows the song that the bot is currently playing. | `.np` @@ -317,6 +318,8 @@ Commands and aliases | Description | Usage `.listglobalperms` `.lgp` | Lists global permissions set by the bot owner. **Bot owner only** | `.lgp` `.globalmodule` `.gmod` | Toggles whether a module can be used on any server. **Bot owner only** | `.gmod nsfw` `.globalcommand` `.gcmd` | Toggles whether a command can be used on any server. **Bot owner only** | `.gcmd .stats` +`.resetperms` | Resets the bot's permissions module on this server to the default value. **Requires Administrator server permission.** | `.resetperms` +`.resetglobalperms` | Resets global permissions set by bot owner. **Bot owner only** | `.resetglobalperms` ###### [Back to ToC](#table-of-contents) @@ -432,7 +435,7 @@ Commands and aliases | Description | Usage `.qsearch` | Shows a random quote for a keyword that contains any text specified in the search. | `.qsearch keyword text` `.quoteid` `.qid` | Displays the quote with the specified ID number. Quote ID numbers can be found by typing `.liqu [num]` where `[num]` is a number of a page which contains 15 quotes. | `.qid 123456` `..` | Adds a new quote with the specified name and message. | `.. sayhi Hi` -`.deletequote_cmd` | deletequote_desc | deletequote_usage +`.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. | `.qdel 123456` `.delallq` `.daq` | Deletes all quotes on a specified keyword. **Requires Administrator server permission.** | `.delallq kek` `.remind` | Sends a message to you or a channel after certain amount of time. First argument is `me`/`here`/'channelname'. Second argument is time in a descending order (mo>w>d>h>m) example: 1w5d3h10m. Third argument is a (multiword) message. | `.remind me 1d5h Do something` or `.remind #general 1m Start now!` `.remindtemplate` | Sets message for when the remind is triggered. Available placeholders are `%user%` - user who ran the command, `%message%` - Message specified in the remind, `%target%` - target channel of the remind. **Bot owner only** | `.remindtemplate %user%, do %message%!` diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 7f3f4bfe..708abfe8 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -2779,7 +2779,7 @@ Shows a list of hangman term types. - `{0} hangmanlist` + `{0}hangmanlist` hangman From 0cf1d328d3f33392e698dc8950e402bd60ecc8a6 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Fri, 16 Jun 2017 00:55:04 +0200 Subject: [PATCH 12/15] filtered words are now paginated --- .../Permissions/Commands/FilterCommands.cs | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/NadekoBot/Modules/Permissions/Commands/FilterCommands.cs b/src/NadekoBot/Modules/Permissions/Commands/FilterCommands.cs index a19b4189..371678ff 100644 --- a/src/NadekoBot/Modules/Permissions/Commands/FilterCommands.cs +++ b/src/NadekoBot/Modules/Permissions/Commands/FilterCommands.cs @@ -1,11 +1,13 @@ using Discord; using Discord.Commands; +using Discord.WebSocket; using Microsoft.EntityFrameworkCore; using NadekoBot.Attributes; using NadekoBot.Extensions; using NadekoBot.Services; using NadekoBot.Services.Permissions; using System.Collections.Concurrent; +using System.Linq; using System.Threading.Tasks; namespace NadekoBot.Modules.Permissions @@ -181,14 +183,25 @@ namespace NadekoBot.Modules.Permissions [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] - public async Task LstFilterWords() + public async Task LstFilterWords(int page = 1) { + page--; + if (page < 0) + return; + var channel = (ITextChannel)Context.Channel; - _service.ServerFilteredWords.TryGetValue(channel.Guild.Id, out ConcurrentHashSet filteredWords); + _service.ServerFilteredWords.TryGetValue(channel.Guild.Id, out var fwHash); - await channel.SendConfirmAsync(GetText("filter_word_list"), string.Join("\n", filteredWords)) - .ConfigureAwait(false); + var fws = fwHash.ToArray(); + + await channel.SendPaginatedConfirmAsync((DiscordShardedClient)Context.Client, + page, + (curPage) => + new EmbedBuilder() + .WithTitle(GetText("filter_word_list")) + .WithDescription(string.Join("\n", fws.Skip(curPage * 10).Take(10))) + , fws.Length / 10).ConfigureAwait(false); } } } From 6bc4bb7803a3633ec2ecb38686008d43e86b5311 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Fri, 16 Jun 2017 01:55:14 +0200 Subject: [PATCH 13/15] moved some stuff around --- .../Modules/Gambling/Commands/AnimalRacing.cs | 14 ++++++---- .../Gambling/Commands/CurrencyEvents.cs | 2 +- .../Modules/Games/Commands/Acropobia.cs | 4 +-- .../Games/Commands/Hangman/HangmanGame.cs | 4 +-- .../Games/Commands/Models/TypingGame.cs | 4 +-- .../Games/Commands/Trivia/TriviaGame.cs | 4 +-- src/NadekoBot/Modules/NadekoModule.cs | 28 +++++++++++-------- src/NadekoBot/Services/CommandHandler.cs | 1 - src/NadekoBot/Services/Games/GamesService.cs | 11 ++++---- .../Services/Searches/SearchesService.cs | 4 +-- 10 files changed, 41 insertions(+), 35 deletions(-) diff --git a/src/NadekoBot/Modules/Gambling/Commands/AnimalRacing.cs b/src/NadekoBot/Modules/Gambling/Commands/AnimalRacing.cs index 70b0dd14..4db985e5 100644 --- a/src/NadekoBot/Modules/Gambling/Commands/AnimalRacing.cs +++ b/src/NadekoBot/Modules/Gambling/Commands/AnimalRacing.cs @@ -250,12 +250,16 @@ namespace NadekoBot.Modules.Gambling private Task Client_MessageReceived(SocketMessage imsg) { - var msg = imsg as SocketUserMessage; - if (msg == null) + var _ = Task.Run(() => + { + var msg = imsg as SocketUserMessage; + if (msg == null) + return Task.CompletedTask; + if ((msg.Author.Id == _client.CurrentUser.Id) || !(imsg.Channel is ITextChannel) || imsg.Channel != _raceChannel) + return Task.CompletedTask; + Interlocked.Increment(ref _messagesSinceGameStarted); return Task.CompletedTask; - if ((msg.Author.Id == _client.CurrentUser.Id) || !(imsg.Channel is ITextChannel) || imsg.Channel != _raceChannel) - return Task.CompletedTask; - Interlocked.Increment(ref _messagesSinceGameStarted); + }); return Task.CompletedTask; } diff --git a/src/NadekoBot/Modules/Gambling/Commands/CurrencyEvents.cs b/src/NadekoBot/Modules/Gambling/Commands/CurrencyEvents.cs index 9ae419be..76369c15 100644 --- a/src/NadekoBot/Modules/Gambling/Commands/CurrencyEvents.cs +++ b/src/NadekoBot/Modules/Gambling/Commands/CurrencyEvents.cs @@ -122,7 +122,7 @@ namespace NadekoBot.Modules.Gambling }); } - return Task.Delay(0); + return Task.CompletedTask; } public async Task FlowerReactionEvent(ICommandContext context, int amount) diff --git a/src/NadekoBot/Modules/Games/Commands/Acropobia.cs b/src/NadekoBot/Modules/Games/Commands/Acropobia.cs index dd1c49b2..0d8e337f 100644 --- a/src/NadekoBot/Modules/Games/Commands/Acropobia.cs +++ b/src/NadekoBot/Modules/Games/Commands/Acropobia.cs @@ -184,9 +184,8 @@ $@"-- await End().ConfigureAwait(false); } - private async Task PotentialAcro(SocketMessage arg) + private Task PotentialAcro(SocketMessage arg) { - await Task.Yield(); var _ = Task.Run(async () => { try @@ -285,6 +284,7 @@ $@"-- _log.Warn(ex); } }); + return Task.CompletedTask; } public async Task End() diff --git a/src/NadekoBot/Modules/Games/Commands/Hangman/HangmanGame.cs b/src/NadekoBot/Modules/Games/Commands/Hangman/HangmanGame.cs index 7cecf927..24ca87c9 100644 --- a/src/NadekoBot/Modules/Games/Commands/Hangman/HangmanGame.cs +++ b/src/NadekoBot/Modules/Games/Commands/Hangman/HangmanGame.cs @@ -117,9 +117,8 @@ namespace NadekoBot.Modules.Games.Hangman await GameChannel.EmbedAsync(embed.WithOkColor()).ConfigureAwait(false); } - private async Task PotentialGuess(SocketMessage msg) + private Task PotentialGuess(SocketMessage msg) { - await Task.Yield(); var _ = Task.Run(async () => { try @@ -194,6 +193,7 @@ namespace NadekoBot.Modules.Games.Hangman } catch (Exception ex) { _log.Warn(ex); } }); + return Task.CompletedTask; } public string GetHangman() => $@". ┌─────┐ diff --git a/src/NadekoBot/Modules/Games/Commands/Models/TypingGame.cs b/src/NadekoBot/Modules/Games/Commands/Models/TypingGame.cs index eff53fb4..db670fd2 100644 --- a/src/NadekoBot/Modules/Games/Commands/Models/TypingGame.cs +++ b/src/NadekoBot/Modules/Games/Commands/Models/TypingGame.cs @@ -107,9 +107,8 @@ namespace NadekoBot.Modules.Games.Models _client.MessageReceived += AnswerReceived; } - private async Task AnswerReceived(SocketMessage imsg) + private Task AnswerReceived(SocketMessage imsg) { - await Task.Yield(); var _ = Task.Run(async () => { try @@ -145,6 +144,7 @@ namespace NadekoBot.Modules.Games.Models } catch (Exception ex) { _log.Warn(ex); } }); + return Task.CompletedTask; } private bool Judge(int errors, int textLength) => errors <= textLength / 25; diff --git a/src/NadekoBot/Modules/Games/Commands/Trivia/TriviaGame.cs b/src/NadekoBot/Modules/Games/Commands/Trivia/TriviaGame.cs index 8a89dbbf..ea6e1e2c 100644 --- a/src/NadekoBot/Modules/Games/Commands/Trivia/TriviaGame.cs +++ b/src/NadekoBot/Modules/Games/Commands/Trivia/TriviaGame.cs @@ -178,9 +178,8 @@ namespace NadekoBot.Modules.Games.Trivia try { await Channel.SendConfirmAsync(GetText("trivia_game"), GetText("trivia_stopping")).ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); } } - private async Task PotentialGuess(SocketMessage imsg) + private Task PotentialGuess(SocketMessage imsg) { - await Task.Yield(); var _ = Task.Run(async () => { try @@ -242,6 +241,7 @@ namespace NadekoBot.Modules.Games.Trivia } catch (Exception ex) { _log.Warn(ex); } }); + return Task.CompletedTask; } public string GetLeaderboard() diff --git a/src/NadekoBot/Modules/NadekoModule.cs b/src/NadekoBot/Modules/NadekoModule.cs index 1282fd5a..cfc96dce 100644 --- a/src/NadekoBot/Modules/NadekoModule.cs +++ b/src/NadekoBot/Modules/NadekoModule.cs @@ -14,10 +14,10 @@ namespace NadekoBot.Modules { protected readonly Logger _log; protected CultureInfo _cultureInfo; - + public readonly string ModuleTypeName; public readonly string LowerModuleTypeName; - + public NadekoStrings _strings { get; set; } public CommandHandler _cmdHandler { get; set; } public ILocalization _localization { get; set; } @@ -34,7 +34,7 @@ namespace NadekoBot.Modules protected override void BeforeExecute() { - _cultureInfo =_localization.GetCultureInfo(Context.Guild?.Id); + _cultureInfo = _localization.GetCultureInfo(Context.Guild?.Id); } //public Task ReplyConfirmLocalized(string titleKey, string textKey, string url = null, string footer = null) @@ -56,7 +56,7 @@ namespace NadekoBot.Modules // var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo); // return Context.Channel.SendErrorAsync(title, text, url, footer); //} - + protected string GetText(string key) => _strings.GetText(key, _cultureInfo, LowerModuleTypeName); @@ -111,16 +111,20 @@ namespace NadekoBot.Modules Task MessageReceived(SocketMessage arg) { - if (!(arg is SocketUserMessage userMsg) || - !(userMsg.Channel is ITextChannel chan) || - userMsg.Author.Id != userId || - userMsg.Channel.Id != channelId) + var _ = Task.Run(() => { - return Task.CompletedTask; - } + if (!(arg is SocketUserMessage userMsg) || + !(userMsg.Channel is ITextChannel chan) || + userMsg.Author.Id != userId || + userMsg.Channel.Id != channelId) + { + return Task.CompletedTask; + } - userInputTask.SetResult(arg.Content); - userMsg.DeleteAfter(1); + userInputTask.SetResult(arg.Content); + userMsg.DeleteAfter(1); + return Task.CompletedTask; + }); return Task.CompletedTask; } } diff --git a/src/NadekoBot/Services/CommandHandler.cs b/src/NadekoBot/Services/CommandHandler.cs index 193515b1..2177ce01 100644 --- a/src/NadekoBot/Services/CommandHandler.cs +++ b/src/NadekoBot/Services/CommandHandler.cs @@ -187,7 +187,6 @@ namespace NadekoBot.Services private async Task MessageReceivedHandler(SocketMessage msg) { - await Task.Yield(); try { if (msg.Author.IsBot || !_bot.Ready) //no bots, wait until bot connected and initialized diff --git a/src/NadekoBot/Services/Games/GamesService.cs b/src/NadekoBot/Services/Games/GamesService.cs index 03b247fa..24139906 100644 --- a/src/NadekoBot/Services/Games/GamesService.cs +++ b/src/NadekoBot/Services/Games/GamesService.cs @@ -97,19 +97,18 @@ namespace NadekoBot.Services.Games private string GetText(ITextChannel ch, string key, params object[] rep) => _strings.GetText(key, ch.GuildId, "Games".ToLowerInvariant(), rep); - private async Task PotentialFlowerGeneration(SocketMessage imsg) + private Task PotentialFlowerGeneration(SocketMessage imsg) { - await Task.Yield(); var msg = imsg as SocketUserMessage; if (msg == null || msg.Author.IsBot) - return; + return Task.CompletedTask; var channel = imsg.Channel as ITextChannel; if (channel == null) - return; + return Task.CompletedTask; if (!GenerationChannels.Contains(channel.Id)) - return; + return Task.CompletedTask; var _ = Task.Run(async () => { @@ -159,7 +158,7 @@ namespace NadekoBot.Services.Games LogManager.GetCurrentClassLogger().Warn(ex); } }); - return; + return Task.CompletedTask; } } } diff --git a/src/NadekoBot/Services/Searches/SearchesService.cs b/src/NadekoBot/Services/Searches/SearchesService.cs index f37f9ec4..864c9522 100644 --- a/src/NadekoBot/Services/Searches/SearchesService.cs +++ b/src/NadekoBot/Services/Searches/SearchesService.cs @@ -39,9 +39,8 @@ namespace NadekoBot.Services.Searches _log = LogManager.GetCurrentClassLogger(); //translate commands - _client.MessageReceived += async (msg) => + _client.MessageReceived += (msg) => { - await Task.Yield(); var _ = Task.Run(async () => { try @@ -70,6 +69,7 @@ namespace NadekoBot.Services.Searches } catch { } }); + return Task.CompletedTask; }; //pokemon commands From 8801a7451bbd772a7e2926cc4e8730dcbf46513a Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Fri, 16 Jun 2017 17:47:02 +0200 Subject: [PATCH 14/15] Disabled log commands on the public bot, added something for xnaas, closes #1245 --- .../20170616154106_crstartswith.Designer.cs | 1568 +++++++++++++++++ .../Migrations/20170616154106_crstartswith.cs | 25 + .../NadekoSqliteContextModelSnapshot.cs | 2 + .../Administration/Commands/LogCommand.cs | 2 + src/NadekoBot/NadekoBot.cs | 2 +- .../Administration/LogCommandService.cs | 62 +- .../CustomReactions/CustomReactionsService.cs | 8 +- .../Services/Database/Models/BotConfig.cs | 1 + src/NadekoBot/Services/Impl/StatsService.cs | 22 +- 9 files changed, 1648 insertions(+), 44 deletions(-) create mode 100644 src/NadekoBot/Migrations/20170616154106_crstartswith.Designer.cs create mode 100644 src/NadekoBot/Migrations/20170616154106_crstartswith.cs diff --git a/src/NadekoBot/Migrations/20170616154106_crstartswith.Designer.cs b/src/NadekoBot/Migrations/20170616154106_crstartswith.Designer.cs new file mode 100644 index 00000000..57e8960b --- /dev/null +++ b/src/NadekoBot/Migrations/20170616154106_crstartswith.Designer.cs @@ -0,0 +1,1568 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using NadekoBot.Services.Database; +using NadekoBot.Services.Database.Models; + +namespace NadekoBot.Migrations +{ + [DbContext(typeof(NadekoContext))] + [Migration("20170616154106_crstartswith")] + partial class crstartswith + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { + modelBuilder + .HasAnnotation("ProductVersion", "1.1.1"); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.AntiRaidSetting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Action"); + + b.Property("DateAdded"); + + b.Property("GuildConfigId"); + + b.Property("Seconds"); + + b.Property("UserThreshold"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId") + .IsUnique(); + + b.ToTable("AntiRaidSetting"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.AntiSpamIgnore", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AntiSpamSettingId"); + + b.Property("ChannelId"); + + b.Property("DateAdded"); + + b.HasKey("Id"); + + b.HasIndex("AntiSpamSettingId"); + + b.ToTable("AntiSpamIgnore"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.AntiSpamSetting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Action"); + + b.Property("DateAdded"); + + b.Property("GuildConfigId"); + + b.Property("MessageThreshold"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId") + .IsUnique(); + + b.ToTable("AntiSpamSetting"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.BlacklistItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BotConfigId"); + + b.Property("DateAdded"); + + b.Property("ItemId"); + + b.Property("Type"); + + b.HasKey("Id"); + + b.HasIndex("BotConfigId"); + + b.ToTable("BlacklistItem"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.BlockedCmdOrMdl", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BotConfigId"); + + b.Property("BotConfigId1"); + + b.Property("DateAdded"); + + b.Property("Name"); + + b.HasKey("Id"); + + b.HasIndex("BotConfigId"); + + b.HasIndex("BotConfigId1"); + + b.ToTable("BlockedCmdOrMdl"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.BotConfig", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BetflipMultiplier"); + + b.Property("Betroll100Multiplier"); + + b.Property("Betroll67Multiplier"); + + b.Property("Betroll91Multiplier"); + + b.Property("BufferSize"); + + b.Property("CurrencyDropAmount"); + + b.Property("CurrencyDropAmountMax"); + + b.Property("CurrencyGenerationChance"); + + b.Property("CurrencyGenerationCooldown"); + + b.Property("CurrencyName"); + + b.Property("CurrencyPluralName"); + + b.Property("CurrencySign"); + + b.Property("CustomReactionsStartWith"); + + b.Property("DMHelpString"); + + b.Property("DateAdded"); + + b.Property("DefaultPrefix"); + + b.Property("ErrorColor"); + + b.Property("ForwardMessages"); + + b.Property("ForwardToAllOwners"); + + b.Property("HelpString"); + + b.Property("Locale"); + + b.Property("MigrationVersion"); + + b.Property("MinimumBetAmount"); + + b.Property("OkColor"); + + b.Property("PermissionVersion"); + + b.Property("RemindMessageFormat"); + + b.Property("RotatingStatuses"); + + b.Property("TriviaCurrencyReward"); + + b.HasKey("Id"); + + b.ToTable("BotConfig"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ClashCaller", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BaseDestroyed"); + + b.Property("CallUser"); + + b.Property("ClashWarId"); + + b.Property("DateAdded"); + + b.Property("SequenceNumber"); + + b.Property("Stars"); + + b.Property("TimeAdded"); + + b.HasKey("Id"); + + b.HasIndex("ClashWarId"); + + b.ToTable("ClashCallers"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ClashWar", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("DateAdded"); + + b.Property("EnemyClan"); + + b.Property("GuildId"); + + b.Property("Size"); + + b.Property("StartedAt"); + + b.Property("WarState"); + + b.HasKey("Id"); + + b.ToTable("ClashOfClans"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.CommandAlias", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("DateAdded"); + + b.Property("GuildConfigId"); + + b.Property("Mapping"); + + b.Property("Trigger"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("CommandAlias"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.CommandCooldown", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("CommandName"); + + b.Property("DateAdded"); + + b.Property("GuildConfigId"); + + b.Property("Seconds"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("CommandCooldown"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.CommandPrice", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BotConfigId"); + + b.Property("CommandName"); + + b.Property("DateAdded"); + + b.Property("Price"); + + b.HasKey("Id"); + + b.HasIndex("BotConfigId"); + + b.HasIndex("Price") + .IsUnique(); + + b.ToTable("CommandPrice"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ConvertUnit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("DateAdded"); + + b.Property("InternalTrigger"); + + b.Property("Modifier"); + + b.Property("UnitType"); + + b.HasKey("Id"); + + b.ToTable("ConversionUnits"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Currency", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Amount"); + + b.Property("DateAdded"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Currency"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.CurrencyTransaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Amount"); + + b.Property("DateAdded"); + + b.Property("Reason"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.ToTable("CurrencyTransactions"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.CustomReaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AutoDeleteTrigger"); + + b.Property("DateAdded"); + + b.Property("DmResponse"); + + b.Property("GuildId"); + + b.Property("IsRegex"); + + b.Property("OwnerOnly"); + + b.Property("Response"); + + b.Property("Trigger"); + + b.HasKey("Id"); + + b.ToTable("CustomReactions"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.DiscordUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AvatarId"); + + b.Property("DateAdded"); + + b.Property("Discriminator"); + + b.Property("UserId"); + + b.Property("Username"); + + b.HasKey("Id"); + + b.HasAlternateKey("UserId"); + + b.ToTable("DiscordUser"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Donator", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Amount"); + + b.Property("DateAdded"); + + b.Property("Name"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Donators"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.EightBallResponse", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BotConfigId"); + + b.Property("DateAdded"); + + b.Property("Text"); + + b.HasKey("Id"); + + b.HasIndex("BotConfigId"); + + b.ToTable("EightBallResponses"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.FilterChannelId", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("DateAdded"); + + b.Property("GuildConfigId"); + + b.Property("GuildConfigId1"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.HasIndex("GuildConfigId1"); + + b.ToTable("FilterChannelId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.FilteredWord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("DateAdded"); + + b.Property("GuildConfigId"); + + b.Property("Word"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("FilteredWord"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.FollowedStream", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("DateAdded"); + + b.Property("GuildConfigId"); + + b.Property("GuildId"); + + b.Property("Type"); + + b.Property("Username"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("FollowedStream"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.GCChannelId", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("DateAdded"); + + b.Property("GuildConfigId"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("GCChannelId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.GuildConfig", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AutoAssignRoleId"); + + b.Property("AutoDeleteByeMessages"); + + b.Property("AutoDeleteByeMessagesTimer"); + + b.Property("AutoDeleteGreetMessages"); + + b.Property("AutoDeleteGreetMessagesTimer"); + + b.Property("AutoDeleteSelfAssignedRoleMessages"); + + b.Property("ByeMessageChannelId"); + + b.Property("ChannelByeMessageText"); + + b.Property("ChannelGreetMessageText"); + + b.Property("CleverbotEnabled"); + + b.Property("DateAdded"); + + b.Property("DefaultMusicVolume"); + + b.Property("DeleteMessageOnCommand"); + + b.Property("DmGreetMessageText"); + + b.Property("ExclusiveSelfAssignedRoles"); + + b.Property("FilterInvites"); + + b.Property("FilterWords"); + + b.Property("GameVoiceChannel"); + + b.Property("GreetMessageChannelId"); + + b.Property("GuildId"); + + b.Property("Locale"); + + b.Property("LogSettingId"); + + b.Property("MuteRoleName"); + + b.Property("PermissionRole"); + + b.Property("Prefix"); + + b.Property("RootPermissionId"); + + b.Property("SendChannelByeMessage"); + + b.Property("SendChannelGreetMessage"); + + b.Property("SendDmGreetMessage"); + + b.Property("TimeZoneId"); + + b.Property("VerboseErrors"); + + b.Property("VerbosePermissions"); + + b.Property("VoicePlusTextEnabled"); + + b.Property("WarningsInitialized"); + + b.HasKey("Id"); + + b.HasIndex("GuildId") + .IsUnique(); + + b.HasIndex("LogSettingId"); + + b.HasIndex("RootPermissionId"); + + b.ToTable("GuildConfigs"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.GuildRepeater", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("DateAdded"); + + b.Property("GuildConfigId"); + + b.Property("GuildId"); + + b.Property("Interval"); + + b.Property("Message"); + + b.Property("StartTimeOfDay"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("GuildRepeater"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredLogChannel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("DateAdded"); + + b.Property("LogSettingId"); + + b.HasKey("Id"); + + b.HasIndex("LogSettingId"); + + b.ToTable("IgnoredLogChannels"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredVoicePresenceChannel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("DateAdded"); + + b.Property("LogSettingId"); + + b.HasKey("Id"); + + b.HasIndex("LogSettingId"); + + b.ToTable("IgnoredVoicePresenceCHannels"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.LogSetting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelCreated"); + + b.Property("ChannelCreatedId"); + + b.Property("ChannelDestroyed"); + + b.Property("ChannelDestroyedId"); + + b.Property("ChannelId"); + + b.Property("ChannelUpdated"); + + b.Property("ChannelUpdatedId"); + + b.Property("DateAdded"); + + b.Property("IsLogging"); + + b.Property("LogOtherId"); + + b.Property("LogUserPresence"); + + b.Property("LogUserPresenceId"); + + b.Property("LogVoicePresence"); + + b.Property("LogVoicePresenceId"); + + b.Property("LogVoicePresenceTTSId"); + + b.Property("MessageDeleted"); + + b.Property("MessageDeletedId"); + + b.Property("MessageUpdated"); + + b.Property("MessageUpdatedId"); + + b.Property("UserBanned"); + + b.Property("UserBannedId"); + + b.Property("UserJoined"); + + b.Property("UserJoinedId"); + + b.Property("UserLeft"); + + b.Property("UserLeftId"); + + b.Property("UserMutedId"); + + b.Property("UserPresenceChannelId"); + + b.Property("UserUnbanned"); + + b.Property("UserUnbannedId"); + + b.Property("UserUpdated"); + + b.Property("UserUpdatedId"); + + b.Property("VoicePresenceChannelId"); + + b.HasKey("Id"); + + b.ToTable("LogSettings"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ModulePrefix", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BotConfigId"); + + b.Property("DateAdded"); + + b.Property("ModuleName"); + + b.Property("Prefix"); + + b.HasKey("Id"); + + b.HasIndex("BotConfigId"); + + b.ToTable("ModulePrefixes"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.MusicPlaylist", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Author"); + + b.Property("AuthorId"); + + b.Property("DateAdded"); + + b.Property("Name"); + + b.HasKey("Id"); + + b.ToTable("MusicPlaylists"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.MutedUserId", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("DateAdded"); + + b.Property("GuildConfigId"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("MutedUserId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("DateAdded"); + + b.Property("NextId"); + + b.Property("PrimaryTarget"); + + b.Property("PrimaryTargetId"); + + b.Property("SecondaryTarget"); + + b.Property("SecondaryTargetName"); + + b.Property("State"); + + b.HasKey("Id"); + + b.HasIndex("NextId") + .IsUnique(); + + b.ToTable("Permission"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Permissionv2", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("DateAdded"); + + b.Property("GuildConfigId"); + + b.Property("Index"); + + b.Property("PrimaryTarget"); + + b.Property("PrimaryTargetId"); + + b.Property("SecondaryTarget"); + + b.Property("SecondaryTargetName"); + + b.Property("State"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("Permissionv2"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.PlayingStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BotConfigId"); + + b.Property("DateAdded"); + + b.Property("Status"); + + b.HasKey("Id"); + + b.HasIndex("BotConfigId"); + + b.ToTable("PlayingStatus"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.PlaylistSong", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("DateAdded"); + + b.Property("MusicPlaylistId"); + + b.Property("Provider"); + + b.Property("ProviderType"); + + b.Property("Query"); + + b.Property("Title"); + + b.Property("Uri"); + + b.HasKey("Id"); + + b.HasIndex("MusicPlaylistId"); + + b.ToTable("PlaylistSong"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Quote", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AuthorId"); + + b.Property("AuthorName") + .IsRequired(); + + b.Property("DateAdded"); + + b.Property("GuildId"); + + b.Property("Keyword") + .IsRequired(); + + b.Property("Text") + .IsRequired(); + + b.HasKey("Id"); + + b.ToTable("Quotes"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.RaceAnimal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BotConfigId"); + + b.Property("DateAdded"); + + b.Property("Icon"); + + b.Property("Name"); + + b.HasKey("Id"); + + b.HasIndex("BotConfigId"); + + b.ToTable("RaceAnimals"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Reminder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChannelId"); + + b.Property("DateAdded"); + + b.Property("IsPrivate"); + + b.Property("Message"); + + b.Property("ServerId"); + + b.Property("UserId"); + + b.Property("When"); + + b.HasKey("Id"); + + b.ToTable("Reminders"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.RewardedUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AmountRewardedThisMonth"); + + b.Property("DateAdded"); + + b.Property("LastReward"); + + b.Property("PatreonUserId"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("RewardedUsers"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.SelfAssignedRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("DateAdded"); + + b.Property("GuildId"); + + b.Property("RoleId"); + + b.HasKey("Id"); + + b.HasIndex("GuildId", "RoleId") + .IsUnique(); + + b.ToTable("SelfAssignableRoles"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ShopEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AuthorId"); + + b.Property("DateAdded"); + + b.Property("GuildConfigId"); + + b.Property("Index"); + + b.Property("Name"); + + b.Property("Price"); + + b.Property("RoleId"); + + b.Property("RoleName"); + + b.Property("Type"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("ShopEntry"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ShopEntryItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("DateAdded"); + + b.Property("ShopEntryId"); + + b.Property("Text"); + + b.HasKey("Id"); + + b.HasIndex("ShopEntryId"); + + b.ToTable("ShopEntryItem"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.SlowmodeIgnoredRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("DateAdded"); + + b.Property("GuildConfigId"); + + b.Property("RoleId"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("SlowmodeIgnoredRole"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.SlowmodeIgnoredUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("DateAdded"); + + b.Property("GuildConfigId"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("SlowmodeIgnoredUser"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.StartupCommand", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BotConfigId"); + + b.Property("ChannelId"); + + b.Property("ChannelName"); + + b.Property("CommandText"); + + b.Property("DateAdded"); + + b.Property("GuildId"); + + b.Property("GuildName"); + + b.Property("Index"); + + b.Property("VoiceChannelId"); + + b.Property("VoiceChannelName"); + + b.HasKey("Id"); + + b.HasIndex("BotConfigId"); + + b.ToTable("StartupCommand"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.UnmuteTimer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("DateAdded"); + + b.Property("GuildConfigId"); + + b.Property("UnmuteAt"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("UnmuteTimer"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.UserPokeTypes", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("DateAdded"); + + b.Property("UserId"); + + b.Property("type"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("PokeGame"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.VcRoleInfo", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("DateAdded"); + + b.Property("GuildConfigId"); + + b.Property("RoleId"); + + b.Property("VoiceChannelId"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("VcRoleInfo"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.WaifuInfo", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AffinityId"); + + b.Property("ClaimerId"); + + b.Property("DateAdded"); + + b.Property("Price"); + + b.Property("WaifuId"); + + b.HasKey("Id"); + + b.HasIndex("AffinityId"); + + b.HasIndex("ClaimerId"); + + b.HasIndex("WaifuId") + .IsUnique(); + + b.ToTable("WaifuInfo"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.WaifuUpdate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("DateAdded"); + + b.Property("NewId"); + + b.Property("OldId"); + + b.Property("UpdateType"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("NewId"); + + b.HasIndex("OldId"); + + b.HasIndex("UserId"); + + b.ToTable("WaifuUpdates"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Warning", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("DateAdded"); + + b.Property("Forgiven"); + + b.Property("ForgivenBy"); + + b.Property("GuildId"); + + b.Property("Moderator"); + + b.Property("Reason"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.ToTable("Warnings"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.WarningPunishment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Count"); + + b.Property("DateAdded"); + + b.Property("GuildConfigId"); + + b.Property("Punishment"); + + b.Property("Time"); + + b.HasKey("Id"); + + b.HasIndex("GuildConfigId"); + + b.ToTable("WarningPunishment"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.AntiRaidSetting", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig", "GuildConfig") + .WithOne("AntiRaidSetting") + .HasForeignKey("NadekoBot.Services.Database.Models.AntiRaidSetting", "GuildConfigId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.AntiSpamIgnore", b => + { + b.HasOne("NadekoBot.Services.Database.Models.AntiSpamSetting") + .WithMany("IgnoredChannels") + .HasForeignKey("AntiSpamSettingId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.AntiSpamSetting", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig", "GuildConfig") + .WithOne("AntiSpamSetting") + .HasForeignKey("NadekoBot.Services.Database.Models.AntiSpamSetting", "GuildConfigId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.BlacklistItem", b => + { + b.HasOne("NadekoBot.Services.Database.Models.BotConfig") + .WithMany("Blacklist") + .HasForeignKey("BotConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.BlockedCmdOrMdl", b => + { + b.HasOne("NadekoBot.Services.Database.Models.BotConfig") + .WithMany("BlockedCommands") + .HasForeignKey("BotConfigId"); + + b.HasOne("NadekoBot.Services.Database.Models.BotConfig") + .WithMany("BlockedModules") + .HasForeignKey("BotConfigId1"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ClashCaller", b => + { + b.HasOne("NadekoBot.Services.Database.Models.ClashWar", "ClashWar") + .WithMany("Bases") + .HasForeignKey("ClashWarId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.CommandAlias", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("CommandAliases") + .HasForeignKey("GuildConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.CommandCooldown", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("CommandCooldowns") + .HasForeignKey("GuildConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.CommandPrice", b => + { + b.HasOne("NadekoBot.Services.Database.Models.BotConfig") + .WithMany("CommandPrices") + .HasForeignKey("BotConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.EightBallResponse", b => + { + b.HasOne("NadekoBot.Services.Database.Models.BotConfig") + .WithMany("EightBallResponses") + .HasForeignKey("BotConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.FilterChannelId", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("FilterInvitesChannelIds") + .HasForeignKey("GuildConfigId"); + + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("FilterWordsChannelIds") + .HasForeignKey("GuildConfigId1"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.FilteredWord", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("FilteredWords") + .HasForeignKey("GuildConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.FollowedStream", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("FollowedStreams") + .HasForeignKey("GuildConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.GCChannelId", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("GenerateCurrencyChannelIds") + .HasForeignKey("GuildConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.GuildConfig", b => + { + b.HasOne("NadekoBot.Services.Database.Models.LogSetting", "LogSetting") + .WithMany() + .HasForeignKey("LogSettingId"); + + b.HasOne("NadekoBot.Services.Database.Models.Permission", "RootPermission") + .WithMany() + .HasForeignKey("RootPermissionId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.GuildRepeater", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("GuildRepeaters") + .HasForeignKey("GuildConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredLogChannel", b => + { + b.HasOne("NadekoBot.Services.Database.Models.LogSetting", "LogSetting") + .WithMany("IgnoredChannels") + .HasForeignKey("LogSettingId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.IgnoredVoicePresenceChannel", b => + { + b.HasOne("NadekoBot.Services.Database.Models.LogSetting", "LogSetting") + .WithMany("IgnoredVoicePresenceChannelIds") + .HasForeignKey("LogSettingId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ModulePrefix", b => + { + b.HasOne("NadekoBot.Services.Database.Models.BotConfig") + .WithMany("ModulePrefixes") + .HasForeignKey("BotConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.MutedUserId", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("MutedUsers") + .HasForeignKey("GuildConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Permission", b => + { + b.HasOne("NadekoBot.Services.Database.Models.Permission", "Next") + .WithOne("Previous") + .HasForeignKey("NadekoBot.Services.Database.Models.Permission", "NextId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.Permissionv2", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("Permissions") + .HasForeignKey("GuildConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.PlayingStatus", b => + { + b.HasOne("NadekoBot.Services.Database.Models.BotConfig") + .WithMany("RotatingStatusMessages") + .HasForeignKey("BotConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.PlaylistSong", b => + { + b.HasOne("NadekoBot.Services.Database.Models.MusicPlaylist") + .WithMany("Songs") + .HasForeignKey("MusicPlaylistId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.RaceAnimal", b => + { + b.HasOne("NadekoBot.Services.Database.Models.BotConfig") + .WithMany("RaceAnimals") + .HasForeignKey("BotConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ShopEntry", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("ShopEntries") + .HasForeignKey("GuildConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.ShopEntryItem", b => + { + b.HasOne("NadekoBot.Services.Database.Models.ShopEntry") + .WithMany("Items") + .HasForeignKey("ShopEntryId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.SlowmodeIgnoredRole", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("SlowmodeIgnoredRoles") + .HasForeignKey("GuildConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.SlowmodeIgnoredUser", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("SlowmodeIgnoredUsers") + .HasForeignKey("GuildConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.StartupCommand", b => + { + b.HasOne("NadekoBot.Services.Database.Models.BotConfig") + .WithMany("StartupCommands") + .HasForeignKey("BotConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.UnmuteTimer", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("UnmuteTimers") + .HasForeignKey("GuildConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.VcRoleInfo", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("VcRoleInfos") + .HasForeignKey("GuildConfigId"); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.WaifuInfo", b => + { + b.HasOne("NadekoBot.Services.Database.Models.DiscordUser", "Affinity") + .WithMany() + .HasForeignKey("AffinityId"); + + b.HasOne("NadekoBot.Services.Database.Models.DiscordUser", "Claimer") + .WithMany() + .HasForeignKey("ClaimerId"); + + b.HasOne("NadekoBot.Services.Database.Models.DiscordUser", "Waifu") + .WithOne() + .HasForeignKey("NadekoBot.Services.Database.Models.WaifuInfo", "WaifuId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.WaifuUpdate", b => + { + b.HasOne("NadekoBot.Services.Database.Models.DiscordUser", "New") + .WithMany() + .HasForeignKey("NewId"); + + b.HasOne("NadekoBot.Services.Database.Models.DiscordUser", "Old") + .WithMany() + .HasForeignKey("OldId"); + + b.HasOne("NadekoBot.Services.Database.Models.DiscordUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("NadekoBot.Services.Database.Models.WarningPunishment", b => + { + b.HasOne("NadekoBot.Services.Database.Models.GuildConfig") + .WithMany("WarnPunishments") + .HasForeignKey("GuildConfigId"); + }); + } + } +} diff --git a/src/NadekoBot/Migrations/20170616154106_crstartswith.cs b/src/NadekoBot/Migrations/20170616154106_crstartswith.cs new file mode 100644 index 00000000..53aa582f --- /dev/null +++ b/src/NadekoBot/Migrations/20170616154106_crstartswith.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace NadekoBot.Migrations +{ + public partial class crstartswith : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "CustomReactionsStartWith", + table: "BotConfig", + nullable: false, + defaultValue: false); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "CustomReactionsStartWith", + table: "BotConfig"); + } + } +} diff --git a/src/NadekoBot/Migrations/NadekoSqliteContextModelSnapshot.cs b/src/NadekoBot/Migrations/NadekoSqliteContextModelSnapshot.cs index 03ae1303..44ce853f 100644 --- a/src/NadekoBot/Migrations/NadekoSqliteContextModelSnapshot.cs +++ b/src/NadekoBot/Migrations/NadekoSqliteContextModelSnapshot.cs @@ -149,6 +149,8 @@ namespace NadekoBot.Migrations b.Property("CurrencySign"); + b.Property("CustomReactionsStartWith"); + b.Property("DMHelpString"); b.Property("DateAdded"); diff --git a/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs b/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs index 050e840f..9823d735 100644 --- a/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs +++ b/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs @@ -1,6 +1,7 @@ using Discord; using Discord.Commands; using NadekoBot.Attributes; +using NadekoBot.DataStructures; using NadekoBot.Extensions; using NadekoBot.Modules.Permissions; using NadekoBot.Services; @@ -16,6 +17,7 @@ namespace NadekoBot.Modules.Administration public partial class Administration { [Group] + [NoPublicBot] public class LogCommands : NadekoSubmodule { private readonly LogCommandService _lc; diff --git a/src/NadekoBot/NadekoBot.cs b/src/NadekoBot/NadekoBot.cs index 6408ce93..ac99d01e 100644 --- a/src/NadekoBot/NadekoBot.cs +++ b/src/NadekoBot/NadekoBot.cs @@ -145,7 +145,7 @@ namespace NadekoBot var clashService = new ClashOfClansService(Client, Db, Localization, Strings); var musicService = new MusicService(GoogleApi, Strings, Localization, Db, soundcloudApiService, Credentials, AllGuildConfigs); - var crService = new CustomReactionsService(permissionsService, Db, Client, CommandHandler); + var crService = new CustomReactionsService(permissionsService, Db, Client, CommandHandler, BotConfig); #region Games var gamesService = new GamesService(Client, BotConfig, AllGuildConfigs, Strings, Images, CommandHandler); diff --git a/src/NadekoBot/Services/Administration/LogCommandService.cs b/src/NadekoBot/Services/Administration/LogCommandService.cs index 51871987..84555345 100644 --- a/src/NadekoBot/Services/Administration/LogCommandService.cs +++ b/src/NadekoBot/Services/Administration/LogCommandService.cs @@ -94,9 +94,8 @@ namespace NadekoBot.Services.Administration private string GetText(IGuild guild, string key, params object[] replacements) => _strings.GetText(key, guild.Id, "Administration".ToLowerInvariant(), replacements); - private async Task _client_UserUpdated(SocketUser before, SocketUser uAfter) + private Task _client_UserUpdated(SocketUser before, SocketUser uAfter) { - await Task.Yield(); var _ = Task.Run(async () => { try @@ -164,11 +163,11 @@ namespace NadekoBot.Services.Administration // ignored } }); + return Task.CompletedTask; } - private async Task _client_UserVoiceStateUpdated_TTS(SocketUser iusr, SocketVoiceState before, SocketVoiceState after) + private Task _client_UserVoiceStateUpdated_TTS(SocketUser iusr, SocketVoiceState before, SocketVoiceState after) { - await Task.Yield(); var _ = Task.Run(async () => { try @@ -212,11 +211,11 @@ namespace NadekoBot.Services.Administration // ignored } }); + return Task.CompletedTask; } - private async void MuteCommands_UserMuted(IGuildUser usr, MuteType muteType) + private void MuteCommands_UserMuted(IGuildUser usr, MuteType muteType) { - await Task.Yield(); var _ = Task.Run(async () => { try @@ -257,9 +256,8 @@ namespace NadekoBot.Services.Administration }); } - private async void MuteCommands_UserUnmuted(IGuildUser usr, MuteType muteType) + private void MuteCommands_UserUnmuted(IGuildUser usr, MuteType muteType) { - await Task.Yield(); var _ = Task.Run(async () => { try @@ -301,9 +299,8 @@ namespace NadekoBot.Services.Administration }); } - public async Task TriggeredAntiProtection(PunishmentAction action, ProtectionType protection, params IGuildUser[] users) + public Task TriggeredAntiProtection(PunishmentAction action, ProtectionType protection, params IGuildUser[] users) { - await Task.Yield(); var _ = Task.Run(async () => { try @@ -348,11 +345,11 @@ namespace NadekoBot.Services.Administration // ignored } }); + return Task.CompletedTask; } - private async Task _client_GuildUserUpdated(SocketGuildUser before, SocketGuildUser after) + private Task _client_GuildUserUpdated(SocketGuildUser before, SocketGuildUser after) { - await Task.Yield(); var _ = Task.Run(async () => { try @@ -397,11 +394,11 @@ namespace NadekoBot.Services.Administration // ignored } }); + return Task.CompletedTask; } - private async Task _client_ChannelUpdated(IChannel cbefore, IChannel cafter) + private Task _client_ChannelUpdated(IChannel cbefore, IChannel cafter) { - await Task.Yield(); var _ = Task.Run(async () => { try @@ -448,11 +445,11 @@ namespace NadekoBot.Services.Administration // ignored } }); + return Task.CompletedTask; } - private async Task _client_ChannelDestroyed(IChannel ich) + private Task _client_ChannelDestroyed(IChannel ich) { - await Task.Yield(); var _ = Task.Run(async () => { try @@ -487,11 +484,11 @@ namespace NadekoBot.Services.Administration // ignored } }); + return Task.CompletedTask; } - private async Task _client_ChannelCreated(IChannel ich) + private Task _client_ChannelCreated(IChannel ich) { - await Task.Yield(); var _ = Task.Run(async () => { try @@ -522,11 +519,11 @@ namespace NadekoBot.Services.Administration } catch (Exception ex) { _log.Warn(ex); } }); + return Task.CompletedTask; } - private async Task _client_UserVoiceStateUpdated(SocketUser iusr, SocketVoiceState before, SocketVoiceState after) + private Task _client_UserVoiceStateUpdated(SocketUser iusr, SocketVoiceState before, SocketVoiceState after) { - await Task.Yield(); var _ = Task.Run(async () => { try @@ -576,11 +573,11 @@ namespace NadekoBot.Services.Administration // ignored } }); + return Task.CompletedTask; } - private async Task _client_UserPresenceUpdated(Optional optGuild, SocketUser usr, SocketPresence before, SocketPresence after) + private Task _client_UserPresenceUpdated(Optional optGuild, SocketUser usr, SocketPresence before, SocketPresence after) { - await Task.Yield(); var _ = Task.Run(async () => { try @@ -619,11 +616,11 @@ namespace NadekoBot.Services.Administration // ignored } }); + return Task.CompletedTask; } - private async Task _client_UserLeft(IGuildUser usr) + private Task _client_UserLeft(IGuildUser usr) { - await Task.Yield(); var _ = Task.Run(async () => { try @@ -649,6 +646,7 @@ namespace NadekoBot.Services.Administration // ignored } }); + return Task.CompletedTask; } private Task _client_UserJoined(IGuildUser usr) @@ -678,9 +676,8 @@ namespace NadekoBot.Services.Administration return Task.CompletedTask; } - private async Task _client_UserUnbanned(IUser usr, IGuild guild) + private Task _client_UserUnbanned(IUser usr, IGuild guild) { - await Task.Yield(); var _ = Task.Run(async () => { try @@ -703,11 +700,11 @@ namespace NadekoBot.Services.Administration } catch (Exception ex) { _log.Warn(ex); } }); + return Task.CompletedTask; } - private async Task _client_UserBanned(IUser usr, IGuild guild) + private Task _client_UserBanned(IUser usr, IGuild guild) { - await Task.Yield(); var _ = Task.Run(async () => { try @@ -729,11 +726,11 @@ namespace NadekoBot.Services.Administration } catch (Exception ex) { _log.Warn(ex); } }); + return Task.CompletedTask; } - private async Task _client_MessageDeleted(Cacheable optMsg, ISocketMessageChannel ch) + private Task _client_MessageDeleted(Cacheable optMsg, ISocketMessageChannel ch) { - await Task.Yield(); var _ = Task.Run(async () => { try @@ -772,11 +769,11 @@ namespace NadekoBot.Services.Administration // ignored } }); + return Task.CompletedTask; } - private async Task _client_MessageUpdated(Cacheable optmsg, SocketMessage imsg2, ISocketMessageChannel ch) + private Task _client_MessageUpdated(Cacheable optmsg, SocketMessage imsg2, ISocketMessageChannel ch) { - await Task.Yield(); var _ = Task.Run(async () => { try @@ -821,6 +818,7 @@ namespace NadekoBot.Services.Administration // ignored } }); + return Task.CompletedTask; } public enum LogType diff --git a/src/NadekoBot/Services/CustomReactions/CustomReactionsService.cs b/src/NadekoBot/Services/CustomReactions/CustomReactionsService.cs index b63101e1..07edf058 100644 --- a/src/NadekoBot/Services/CustomReactions/CustomReactionsService.cs +++ b/src/NadekoBot/Services/CustomReactions/CustomReactionsService.cs @@ -25,15 +25,17 @@ namespace NadekoBot.Services.CustomReactions private readonly DiscordShardedClient _client; private readonly PermissionService _perms; private readonly CommandHandler _cmd; + private readonly BotConfig _bc; public CustomReactionsService(PermissionService perms, DbService db, - DiscordShardedClient client, CommandHandler cmd) + DiscordShardedClient client, CommandHandler cmd, BotConfig bc) { _log = LogManager.GetCurrentClassLogger(); _db = db; _client = client; _perms = perms; _cmd = cmd; + _bc = bc; var sw = Stopwatch.StartNew(); using (var uow = _db.UnitOfWork) @@ -66,7 +68,7 @@ namespace NadekoBot.Services.CustomReactions var hasTarget = cr.Response.ToLowerInvariant().Contains("%target%"); var trigger = cr.TriggerWithContext(umsg, _client).Trim().ToLowerInvariant(); - return ((hasTarget && content.StartsWith(trigger + " ")) || content == trigger); + return ((hasTarget && content.StartsWith(trigger + " ")) || (_bc.CustomReactionsStartWith && content.StartsWith(trigger)) || content == trigger); }).ToArray(); if (rs.Length != 0) @@ -87,7 +89,7 @@ namespace NadekoBot.Services.CustomReactions return false; var hasTarget = cr.Response.ToLowerInvariant().Contains("%target%"); var trigger = cr.TriggerWithContext(umsg, _client).Trim().ToLowerInvariant(); - return ((hasTarget && content.StartsWith(trigger + " ")) || content == trigger); + return ((hasTarget && content.StartsWith(trigger + " ")) || (_bc.CustomReactionsStartWith && content.StartsWith(trigger)) || content == trigger); }).ToArray(); if (grs.Length == 0) return null; diff --git a/src/NadekoBot/Services/Database/Models/BotConfig.cs b/src/NadekoBot/Services/Database/Models/BotConfig.cs index 84d1fb1e..0fa46b84 100644 --- a/src/NadekoBot/Services/Database/Models/BotConfig.cs +++ b/src/NadekoBot/Services/Database/Models/BotConfig.cs @@ -67,6 +67,7 @@ Nadeko Support Server: https://discord.gg/nadekobot"; public HashSet BlockedModules { get; set; } public int PermissionVersion { get; set; } = 1; public string DefaultPrefix { get; set; } = "."; + public bool CustomReactionsStartWith { get; set; } = false; } public class BlockedCmdOrMdl : DbEntity diff --git a/src/NadekoBot/Services/Impl/StatsService.cs b/src/NadekoBot/Services/Impl/StatsService.cs index cc08aecb..bcd4a092 100644 --- a/src/NadekoBot/Services/Impl/StatsService.cs +++ b/src/NadekoBot/Services/Impl/StatsService.cs @@ -47,20 +47,26 @@ namespace NadekoBot.Services.Impl _client.ChannelCreated += (c) => { - if (c is ITextChannel) - Interlocked.Increment(ref _textChannels); - else if (c is IVoiceChannel) - Interlocked.Increment(ref _voiceChannels); + var _ = Task.Run(() => + { + if (c is ITextChannel) + Interlocked.Increment(ref _textChannels); + else if (c is IVoiceChannel) + Interlocked.Increment(ref _voiceChannels); + }); return Task.CompletedTask; }; _client.ChannelDestroyed += (c) => { - if (c is ITextChannel) - Interlocked.Decrement(ref _textChannels); - else if (c is IVoiceChannel) - Interlocked.Decrement(ref _voiceChannels); + var _ = Task.Run(() => + { + if (c is ITextChannel) + Interlocked.Decrement(ref _textChannels); + else if (c is IVoiceChannel) + Interlocked.Decrement(ref _voiceChannels); + }); return Task.CompletedTask; }; From 270600198b7eff256133ed4e68e60e15606f8294 Mon Sep 17 00:00:00 2001 From: xnaas Date: Fri, 16 Jun 2017 13:19:29 -0500 Subject: [PATCH 15/15] Update CustomReactionsService.cs I'm a picky POS. :D --- .../Services/CustomReactions/CustomReactionsService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NadekoBot/Services/CustomReactions/CustomReactionsService.cs b/src/NadekoBot/Services/CustomReactions/CustomReactionsService.cs index 07edf058..206b0bd9 100644 --- a/src/NadekoBot/Services/CustomReactions/CustomReactionsService.cs +++ b/src/NadekoBot/Services/CustomReactions/CustomReactionsService.cs @@ -68,7 +68,7 @@ namespace NadekoBot.Services.CustomReactions var hasTarget = cr.Response.ToLowerInvariant().Contains("%target%"); var trigger = cr.TriggerWithContext(umsg, _client).Trim().ToLowerInvariant(); - return ((hasTarget && content.StartsWith(trigger + " ")) || (_bc.CustomReactionsStartWith && content.StartsWith(trigger)) || content == trigger); + return ((hasTarget && content.StartsWith(trigger + " ")) || (_bc.CustomReactionsStartWith && content.StartsWith(trigger + " ")) || content == trigger); }).ToArray(); if (rs.Length != 0) @@ -89,7 +89,7 @@ namespace NadekoBot.Services.CustomReactions return false; var hasTarget = cr.Response.ToLowerInvariant().Contains("%target%"); var trigger = cr.TriggerWithContext(umsg, _client).Trim().ToLowerInvariant(); - return ((hasTarget && content.StartsWith(trigger + " ")) || (_bc.CustomReactionsStartWith && content.StartsWith(trigger)) || content == trigger); + return ((hasTarget && content.StartsWith(trigger + " ")) || (_bc.CustomReactionsStartWith && content.StartsWith(trigger + " ")) || content == trigger); }).ToArray(); if (grs.Length == 0) return null;