diff --git a/src/NadekoBot/Modules/Administration/AdministrationModule.cs b/src/NadekoBot/Modules/Administration/AdministrationModule.cs index 917f8c97..05011cba 100644 --- a/src/NadekoBot/Modules/Administration/AdministrationModule.cs +++ b/src/NadekoBot/Modules/Administration/AdministrationModule.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using NadekoBot.Services; using NadekoBot.Attributes; using System.Text.RegularExpressions; +using Discord.WebSocket; //todo fix delmsgoncmd //todo DB @@ -18,7 +19,7 @@ namespace NadekoBot.Modules.Administration [Module(".", AppendSpace = false)] public partial class Administration : DiscordModule { - public Administration(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client) : base(loc, cmds, config, client) + public Administration(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client) : base(loc, cmds, config, client) { } @@ -462,7 +463,7 @@ namespace NadekoBot.Modules.Administration { var channel = msg.Channel as ITextChannel; int limit = (count < 100) ? count : 100; - var enumerable = (await msg.Channel.GetMessagesAsync(limit: limit)); + var enumerable = (await msg.Channel.GetMessagesAsync(limit: limit)).Where(m => m.Author == user); await msg.Channel.DeleteMessagesAsync(enumerable); } ////todo owner only diff --git a/src/NadekoBot/Modules/Administration/Commands/AutoAssignRole.cs b/src/NadekoBot/Modules/Administration/Commands/AutoAssignRole.cs index b2a7bfc1..75a12f99 100644 --- a/src/NadekoBot/Modules/Administration/Commands/AutoAssignRole.cs +++ b/src/NadekoBot/Modules/Administration/Commands/AutoAssignRole.cs @@ -4,7 +4,7 @@ using Discord.WebSocket; using NadekoBot.Attributes; using System.Threading.Tasks; -namespace NadekoBot.Modules.Administration.Commands +namespace NadekoBot.Modules.Administration { //todo DB public partial class Administration @@ -12,8 +12,9 @@ namespace NadekoBot.Modules.Administration.Commands [Group] public class AutoAssignRole { - public AutoAssignRole(DiscordSocketClient _client) + public AutoAssignRole() { + var _client = NadekoBot.Client; _client.UserJoined += (user) => { //var config = SpecificConfigurations.Default.Of(e.Server.Id); diff --git a/src/NadekoBot/Modules/Administration/Commands/CrossServerTextChannel.cs b/src/NadekoBot/Modules/Administration/Commands/CrossServerTextChannel.cs index c08683d6..66f31d8f 100644 --- a/src/NadekoBot/Modules/Administration/Commands/CrossServerTextChannel.cs +++ b/src/NadekoBot/Modules/Administration/Commands/CrossServerTextChannel.cs @@ -8,7 +8,7 @@ //using System.Linq; ////todo DB -//namespace NadekoBot.Modules.Administration.Commands +//namespace NadekoBot.Modules.Administration //{ // class CrossServerTextChannel : DiscordCommand // { diff --git a/src/NadekoBot/Modules/Administration/Commands/IncidentsCommands.cs b/src/NadekoBot/Modules/Administration/Commands/IncidentsCommands.cs index 9fa17495..5fd22dda 100644 --- a/src/NadekoBot/Modules/Administration/Commands/IncidentsCommands.cs +++ b/src/NadekoBot/Modules/Administration/Commands/IncidentsCommands.cs @@ -6,7 +6,7 @@ //using System.Linq; ////todo DB -//namespace NadekoBot.Modules.Administration.Commands +//namespace NadekoBot.Modules.Administration //{ // internal class IncidentsCommands : DiscordCommand // { diff --git a/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs b/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs index 29da6a02..498621c6 100644 --- a/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs +++ b/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs @@ -11,7 +11,7 @@ ////todo DB ////todo Add flags for every event -//namespace NadekoBot.Modules.Administration.Commands +//namespace NadekoBot.Modules.Administration //{ // internal class LogCommand : DiscordCommand // { diff --git a/src/NadekoBot/Modules/Administration/Commands/MessageRepeater.cs b/src/NadekoBot/Modules/Administration/Commands/MessageRepeater.cs index 4101cf53..6192ea95 100644 --- a/src/NadekoBot/Modules/Administration/Commands/MessageRepeater.cs +++ b/src/NadekoBot/Modules/Administration/Commands/MessageRepeater.cs @@ -8,7 +8,7 @@ //using System.Timers; ////todo DB ////todo persist restarts -//namespace NadekoBot.Modules.Administration.Commands +//namespace NadekoBot.Modules.Administration //{ // class MessageRepeater : DiscordCommand // { diff --git a/src/NadekoBot/Modules/Administration/Commands/PlayingRotate.cs b/src/NadekoBot/Modules/Administration/Commands/PlayingRotate.cs index 362d691b..6b105a37 100644 --- a/src/NadekoBot/Modules/Administration/Commands/PlayingRotate.cs +++ b/src/NadekoBot/Modules/Administration/Commands/PlayingRotate.cs @@ -13,7 +13,7 @@ //using Timer = System.Timers.Timer; ////todo DB -//namespace NadekoBot.Modules.Administration.Commands +//namespace NadekoBot.Modules.Administration //{ // internal class PlayingRotate : DiscordCommand // { diff --git a/src/NadekoBot/Modules/Administration/Commands/RatelimitCommand.cs b/src/NadekoBot/Modules/Administration/Commands/RatelimitCommand.cs index b0d5ef84..18f67780 100644 --- a/src/NadekoBot/Modules/Administration/Commands/RatelimitCommand.cs +++ b/src/NadekoBot/Modules/Administration/Commands/RatelimitCommand.cs @@ -9,7 +9,7 @@ using System.Collections.Concurrent; using System.Threading.Tasks; //todo rewrite to accept msg/sec (for example 1/5 - 1 message every 5 seconds) -namespace NadekoBot.Modules.Administration.Commands +namespace NadekoBot.Modules.Administration { public partial class Administration { @@ -21,16 +21,16 @@ namespace NadekoBot.Modules.Administration.Commands private static readonly TimeSpan ratelimitTime = new TimeSpan(0, 0, 0, 5); private DiscordSocketClient _client { get; } - public RatelimitCommand(DiscordSocketClient client) + public RatelimitCommand() { - this._client = client; + this._client = NadekoBot.Client; _client.MessageReceived += async (imsg) => { var channel = imsg.Channel as ITextChannel; - if (channel == null || await imsg.IsAuthor(client)) + if (channel == null || await imsg.IsAuthor(_client)) return; ConcurrentDictionary userTimePair; if (!RatelimitingChannels.TryGetValue(channel.Id, out userTimePair)) return; diff --git a/src/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs b/src/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs index 6f69d0ba..7bb9235a 100644 --- a/src/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs +++ b/src/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs @@ -8,7 +8,7 @@ //using System.Text; //using System.Threading.Tasks; ////todo DB -//namespace NadekoBot.Modules.Administration.Commands +//namespace NadekoBot.Modules.Administration //{ // internal class SelfAssignedRolesCommand : DiscordCommand // { diff --git a/src/NadekoBot/Modules/Administration/Commands/SelfCommands.cs b/src/NadekoBot/Modules/Administration/Commands/SelfCommands.cs index 7eb2bb04..79ace8a1 100644 --- a/src/NadekoBot/Modules/Administration/Commands/SelfCommands.cs +++ b/src/NadekoBot/Modules/Administration/Commands/SelfCommands.cs @@ -6,7 +6,7 @@ //using System.Threading.Tasks; ////todo owner only -//namespace NadekoBot.Modules.Administration.Commands +//namespace NadekoBot.Modules.Administration //{ // public partial class Administration // { diff --git a/src/NadekoBot/Modules/Administration/Commands/ServerGreetCommand.cs b/src/NadekoBot/Modules/Administration/Commands/ServerGreetCommand.cs index d8a08c86..4fa51a62 100644 --- a/src/NadekoBot/Modules/Administration/Commands/ServerGreetCommand.cs +++ b/src/NadekoBot/Modules/Administration/Commands/ServerGreetCommand.cs @@ -7,7 +7,7 @@ //// todo DB //// todo rewrite -//namespace NadekoBot.Modules.Administration.Commands +//namespace NadekoBot.Modules.Administration //{ // internal class ServerGreetCommand : DiscordCommand // { diff --git a/src/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommand.cs b/src/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommand.cs index e1671395..7d8bab1a 100644 --- a/src/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommand.cs +++ b/src/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommand.cs @@ -11,7 +11,7 @@ ////todo DB ////todo rewrite -//namespace NadekoBot.Modules.Administration.Commands +//namespace NadekoBot.Modules.Administration //{ // internal class VoicePlusTextCommand : DiscordCommand // { diff --git a/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs b/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs index 2368480a..413f672b 100644 --- a/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs +++ b/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using Discord; using NadekoBot.Services; using NadekoBot.Attributes; +using Discord.WebSocket; //todo DB namespace NadekoBot.Modules.ClashOfClans @@ -17,7 +18,7 @@ namespace NadekoBot.Modules.ClashOfClans { public static ConcurrentDictionary> ClashWars { get; set; } = new ConcurrentDictionary>(); - public ClashOfClans(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client) : base(loc, cmds, config, client) + public ClashOfClans(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client) : base(loc, cmds, config, client) { } diff --git a/src/NadekoBot/Modules/DiscordModule.cs b/src/NadekoBot/Modules/DiscordModule.cs index 456c83a8..bf8719f1 100644 --- a/src/NadekoBot/Modules/DiscordModule.cs +++ b/src/NadekoBot/Modules/DiscordModule.cs @@ -1,5 +1,6 @@ using Discord; using Discord.Commands; +using Discord.WebSocket; using NadekoBot.Services; using NLog; @@ -10,10 +11,10 @@ namespace NadekoBot.Modules protected ILocalization _l; protected CommandService _commands; protected IBotConfiguration _config; - protected IDiscordClient _client; + protected DiscordSocketClient _client; protected Logger _log; - public DiscordModule(ILocalization loc, CommandService cmds, IBotConfiguration config,IDiscordClient client) + public DiscordModule(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client) { _l = loc; _commands = cmds; diff --git a/src/NadekoBot/Modules/Gambling/Commands/AnimalRacing.cs b/src/NadekoBot/Modules/Gambling/Commands/AnimalRacing.cs index 83a4882e..72538677 100644 --- a/src/NadekoBot/Modules/Gambling/Commands/AnimalRacing.cs +++ b/src/NadekoBot/Modules/Gambling/Commands/AnimalRacing.cs @@ -10,7 +10,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -namespace NadekoBot.Modules.Gambling.Commands +namespace NadekoBot.Modules.Gambling { public partial class Gambling { diff --git a/src/NadekoBot/Modules/Gambling/Commands/Models/Cards.cs b/src/NadekoBot/Modules/Gambling/Commands/Models/Cards.cs index 8eb94642..5517d5d1 100644 --- a/src/NadekoBot/Modules/Gambling/Commands/Models/Cards.cs +++ b/src/NadekoBot/Modules/Gambling/Commands/Models/Cards.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; -namespace NadekoBot.Modules.Gambling.Commands.Models +namespace NadekoBot.Modules.Gambling.Models { public class Cards { diff --git a/src/NadekoBot/Modules/Gambling/Gambling.cs b/src/NadekoBot/Modules/Gambling/Gambling.cs index 493804b4..c7d2677c 100644 --- a/src/NadekoBot/Modules/Gambling/Gambling.cs +++ b/src/NadekoBot/Modules/Gambling/Gambling.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using NadekoBot.Services; +using Discord.WebSocket; //todo DB namespace NadekoBot.Modules.Gambling @@ -14,7 +15,7 @@ namespace NadekoBot.Modules.Gambling [Module("$", AppendSpace = false)] public partial class Gambling : DiscordModule { - public Gambling(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client) : base(loc, cmds, config, client) + public Gambling(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client) : base(loc, cmds, config, client) { } diff --git a/src/NadekoBot/Modules/Games/Commands/LeetCommands.cs b/src/NadekoBot/Modules/Games/Commands/LeetCommands.cs index daf04553..dd660876 100644 --- a/src/NadekoBot/Modules/Games/Commands/LeetCommands.cs +++ b/src/NadekoBot/Modules/Games/Commands/LeetCommands.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; // taken from // http://www.codeproject.com/Tips/207582/L-t-Tr-nsl-t-r-Leet-Translator (thanks) // because i don't want to waste my time on this cancerous command -namespace NadekoBot.Modules.Games.Commands +namespace NadekoBot.Modules.Games { public partial class GamesModule { diff --git a/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs b/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs index 75bdf2c0..9262678b 100644 --- a/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs +++ b/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs @@ -14,7 +14,7 @@ ////todo DI into partials ////todo DB -//namespace NadekoBot.Modules.Games.Commands +//namespace NadekoBot.Modules.Games //{ // /// // /// Flower picking/planting idea is given to me by its diff --git a/src/NadekoBot/Modules/Games/Commands/PollCommands.cs b/src/NadekoBot/Modules/Games/Commands/PollCommands.cs index 4059fcfc..0f3d1721 100644 --- a/src/NadekoBot/Modules/Games/Commands/PollCommands.cs +++ b/src/NadekoBot/Modules/Games/Commands/PollCommands.cs @@ -8,7 +8,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -namespace NadekoBot.Modules.Games.Commands +namespace NadekoBot.Modules.Games { public partial class GamesModule { diff --git a/src/NadekoBot/Modules/Games/Commands/SpeedTypingCommands.cs b/src/NadekoBot/Modules/Games/Commands/SpeedTypingCommands.cs index 2cfb51cc..cd561349 100644 --- a/src/NadekoBot/Modules/Games/Commands/SpeedTypingCommands.cs +++ b/src/NadekoBot/Modules/Games/Commands/SpeedTypingCommands.cs @@ -12,7 +12,7 @@ ////todo DB ////todo Rewrite? -//namespace NadekoBot.Modules.Games.Commands +//namespace NadekoBot.Modules.Games //{ // public static class SentencesProvider // { diff --git a/src/NadekoBot/Modules/Games/Commands/Trivia/TriviaGame.cs b/src/NadekoBot/Modules/Games/Commands/Trivia/TriviaGame.cs index 203914ce..271ca03c 100644 --- a/src/NadekoBot/Modules/Games/Commands/Trivia/TriviaGame.cs +++ b/src/NadekoBot/Modules/Games/Commands/Trivia/TriviaGame.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; // todo rewrite? // todo DB -namespace NadekoBot.Modules.Games.Commands.Trivia +namespace NadekoBot.Modules.Games.Trivia { public class TriviaGame { diff --git a/src/NadekoBot/Modules/Games/Commands/Trivia/TriviaQuestion.cs b/src/NadekoBot/Modules/Games/Commands/Trivia/TriviaQuestion.cs index f6ec9cd3..84f332bb 100644 --- a/src/NadekoBot/Modules/Games/Commands/Trivia/TriviaQuestion.cs +++ b/src/NadekoBot/Modules/Games/Commands/Trivia/TriviaQuestion.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text.RegularExpressions; // THANKS @ShoMinamimoto for suggestions and coding help -namespace NadekoBot.Modules.Games.Commands.Trivia +namespace NadekoBot.Modules.Games.Trivia { public class TriviaQuestion { diff --git a/src/NadekoBot/Modules/Games/Commands/Trivia/TriviaQuestionPool.cs b/src/NadekoBot/Modules/Games/Commands/Trivia/TriviaQuestionPool.cs index 7ffe615f..fd21086f 100644 --- a/src/NadekoBot/Modules/Games/Commands/Trivia/TriviaQuestionPool.cs +++ b/src/NadekoBot/Modules/Games/Commands/Trivia/TriviaQuestionPool.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; -namespace NadekoBot.Modules.Games.Commands.Trivia +namespace NadekoBot.Modules.Games.Trivia { public class TriviaQuestionPool { diff --git a/src/NadekoBot/Modules/Games/Commands/TriviaCommands.cs b/src/NadekoBot/Modules/Games/Commands/TriviaCommands.cs index 98ca7cf5..956b40fa 100644 --- a/src/NadekoBot/Modules/Games/Commands/TriviaCommands.cs +++ b/src/NadekoBot/Modules/Games/Commands/TriviaCommands.cs @@ -1,14 +1,14 @@ using Discord; using Discord.Commands; using NadekoBot.Attributes; -using NadekoBot.Modules.Games.Commands.Trivia; +using NadekoBot.Modules.Games.Trivia; using System; using System.Collections.Concurrent; using System.Linq; using System.Threading.Tasks; //todo Rewrite? Fix trivia not stopping bug -namespace NadekoBot.Modules.Games.Commands +namespace NadekoBot.Modules.Games { public partial class GamesModule { diff --git a/src/NadekoBot/Modules/Games/Games.cs b/src/NadekoBot/Modules/Games/Games.cs index 7f5e4429..bf9a3413 100644 --- a/src/NadekoBot/Modules/Games/Games.cs +++ b/src/NadekoBot/Modules/Games/Games.cs @@ -7,6 +7,7 @@ using System; using System.Linq; using System.Collections.Generic; using NadekoBot.Extensions; +using Discord.WebSocket; namespace NadekoBot.Modules.Games { @@ -15,8 +16,9 @@ namespace NadekoBot.Modules.Games { //todo DB private IEnumerable _8BallResponses; - public Games(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client) : base(loc, cmds, config, client) + public Games(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client) : base(loc, cmds, config, client) { + _8BallResponses = config.EightBallResponses; } [LocalizedCommand, LocalizedDescription, LocalizedSummary] diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index e3469f1c..2d38e4dd 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -8,6 +8,7 @@ using NadekoBot.Attributes; using System; using System.IO; using System.Text; +using Discord.WebSocket; namespace NadekoBot.Modules.Help { @@ -20,7 +21,7 @@ namespace NadekoBot.Modules.Help return str + String.Format(str, NadekoBot.Credentials.ClientId); } } - public Help(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client) : base(loc, cmds, config, client) + public Help(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client) : base(loc, cmds, config, client) { } diff --git a/src/NadekoBot/Modules/NSFW/NSFW.cs b/src/NadekoBot/Modules/NSFW/NSFW.cs index e9d165ca..269ce7ce 100644 --- a/src/NadekoBot/Modules/NSFW/NSFW.cs +++ b/src/NadekoBot/Modules/NSFW/NSFW.cs @@ -10,13 +10,14 @@ using System.Net.Http; using System.Text.RegularExpressions; using System.Xml.Linq; using System.Net; +using Discord.WebSocket; namespace NadekoBot.Modules.NSFW { [Module("~", AppendSpace = false)] public class NSFW : DiscordModule { - public NSFW(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client) : base(loc, cmds, config, client) + public NSFW(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client) : base(loc, cmds, config, client) { } diff --git a/src/NadekoBot/Modules/Pokemon/Pokemon.cs b/src/NadekoBot/Modules/Pokemon/Pokemon.cs index 84ce306d..d5624c15 100644 --- a/src/NadekoBot/Modules/Pokemon/Pokemon.cs +++ b/src/NadekoBot/Modules/Pokemon/Pokemon.cs @@ -3,13 +3,14 @@ using Discord; using NadekoBot.Attributes; using System.Threading.Tasks; using NadekoBot.Services; +using Discord.WebSocket; -namespace NadekoBot.Modules.Games.Commands +namespace NadekoBot.Modules.Games { [Module(">", AppendSpace = false)] public partial class Pokemon : DiscordModule { - public Pokemon(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client) : base(loc, cmds, config, client) + public Pokemon(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client) : base(loc, cmds, config, client) { } diff --git a/src/NadekoBot/Modules/Searches/Commands/AnimeSearchCommands.cs b/src/NadekoBot/Modules/Searches/Commands/AnimeSearchCommands.cs index 7333d00a..f9b309d8 100644 --- a/src/NadekoBot/Modules/Searches/Commands/AnimeSearchCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/AnimeSearchCommands.cs @@ -7,7 +7,7 @@ //using System.Threading.Tasks; //// todo RestSharp -//namespace NadekoBot.Modules.Searches.Commands +//namespace NadekoBot.Modules.Searches //{ // public partial class SearchesModule // { diff --git a/src/NadekoBot/Modules/Searches/Commands/ConverterCommands.cs b/src/NadekoBot/Modules/Searches/Commands/ConverterCommands.cs index cb7a278c..14651abb 100644 --- a/src/NadekoBot/Modules/Searches/Commands/ConverterCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/ConverterCommands.cs @@ -8,7 +8,7 @@ //using System.Threading.Tasks; ////todo Unit Conversion lib -//namespace NadekoBot.Modules.Searches.Commands +//namespace NadekoBot.Modules.Searches //{ // class ConverterCommand : DiscordCommand // { diff --git a/src/NadekoBot/Modules/Searches/Commands/EvalCommand.cs b/src/NadekoBot/Modules/Searches/Commands/EvalCommand.cs index 8d3eef9c..617682d2 100644 --- a/src/NadekoBot/Modules/Searches/Commands/EvalCommand.cs +++ b/src/NadekoBot/Modules/Searches/Commands/EvalCommand.cs @@ -6,7 +6,7 @@ //using System.Threading.Tasks; //todo mathos parser replacement -//namespace NadekoBot.Modules.Searches.Commands +//namespace NadekoBot.Modules.Searches //{ // class CalcCommand : DiscordCommand // { diff --git a/src/NadekoBot/Modules/Searches/Commands/IMDB/ImdbScraper.cs b/src/NadekoBot/Modules/Searches/Commands/IMDB/ImdbScraper.cs index b7ac2751..fc8c7ec8 100644 --- a/src/NadekoBot/Modules/Searches/Commands/IMDB/ImdbScraper.cs +++ b/src/NadekoBot/Modules/Searches/Commands/IMDB/ImdbScraper.cs @@ -1,4 +1,4 @@ -using NadekoBot.Modules.Searches.Commands.Models; +using NadekoBot.Modules.Searches.Models; using System; using System.Collections.Generic; using System.Linq; @@ -17,7 +17,7 @@ using System.Threading.Tasks; * Last Updated: Feb, 2016 *******************************************************************************/ -namespace NadekoBot.Modules.Searches.Commands.IMDB +namespace NadekoBot.Modules.Searches.IMDB { public static class ImdbScraper { @@ -49,7 +49,7 @@ namespace NadekoBot.Modules.Searches.Commands.IMDB public static async Task GetIMDBId(string MovieName) { string imdbUrl = await GetIMDbUrlAsync(System.Uri.EscapeUriString(MovieName)); - return match(@"http://www.imdb.com/title/(tt\d{7})", imdbUrl); + return Match(@"http://www.imdb.com/title/(tt\d{7})", imdbUrl); } //Get IMDb URL from search results private static async Task GetIMDbUrlAsync(string MovieName) @@ -65,17 +65,17 @@ namespace NadekoBot.Modules.Searches.Commands.IMDB private static async Task ParseIMDbPage(string imdbUrl, bool GetExtraInfo, ImdbMovie mov) { string html = await GetUrlDataAsync(imdbUrl + "combined"); - mov.Id = match(@"", html); + mov.Id = Match(@"", html); if (!string.IsNullOrEmpty(mov.Id)) { mov.Status = true; - mov.Title = match(@"(IMDb \- )*(.*?) \(.*?", html, 2); - mov.OriginalTitle = match(@"title-extra"">(.*?)<", html); - mov.Year = match(@".*?\(.*?(\d{4}).*?).*?", match(@"(.*?)", html)); - mov.Rating = match(@"(\d.\d)/10", html); - mov.Genres = MatchAll(@"(.*?)", match(@"Genre.?:(.*?)(|See more)", html)).Cast().ToList(); - mov.Plot = match(@"Plot:.*?|See more)", html)).Cast().ToList(); + mov.Plot = Match(@"Plot:.*?
(.*?)(.*?", html); if (!string.IsNullOrEmpty(mov.Poster) && mov.Poster.IndexOf("media-imdb.com") > 0) { mov.Poster = Regex.Replace(mov.Poster, @"_V1.*?.jpg", "_V1._SY200.jpg"); @@ -97,7 +97,7 @@ namespace NadekoBot.Modules.Searches.Commands.IMDB { Dictionary release = new Dictionary(); string releasehtml = await GetUrlDataAsync("http://www.imdb.com/title/" + mov.Id + "/releaseinfo"); - foreach (string r in MatchAll(@"(.*?)", match(@"\n*?(.*?)
", releasehtml))) + foreach (string r in MatchAll(@"(.*?)", Match(@"\n*?(.*?)
", releasehtml))) { Match rd = new Regex(@"(.*?)\n*?.*?(.*?)", RegexOptions.Multiline).Match(r); release[StripHTML(rd.Groups[1].Value.Trim())] = StripHTML(rd.Groups[2].Value.Trim()); @@ -105,7 +105,7 @@ namespace NadekoBot.Modules.Searches.Commands.IMDB //mov.ReleaseDates = release; Dictionary aka = new Dictionary(); - List list = MatchAll(@".*?(.*?)", match(@"\n*?(.*?)
", releasehtml)); + List list = MatchAll(@".*?(.*?)", Match(@"\n*?(.*?)
", releasehtml)); foreach (string r in list) { Match rd = new Regex(@"\n*?.*?(.*?)\n*?.*?(.*?)", RegexOptions.Multiline).Match(r); @@ -122,11 +122,11 @@ namespace NadekoBot.Modules.Searches.Commands.IMDB List list = new List(); string mediaurl = "http://www.imdb.com/title/" + mov.Id + "/mediaindex"; string mediahtml = await GetUrlDataAsync(mediaurl); - int pagecount = MatchAll(@"
", match(@"(.*?)", mediahtml)).Count; + int pagecount = MatchAll(@"", Match(@"(.*?)", mediahtml)).Count; for (int p = 1; p <= pagecount + 1; p++) { mediahtml = await GetUrlDataAsync(mediaurl + "?page=" + p); - foreach (Match m in new Regex(@"src=""(.*?)""", RegexOptions.Multiline).Matches(match(@"
(.*?)
", mediahtml))) + foreach (Match m in new Regex(@"src=""(.*?)""", RegexOptions.Multiline).Matches(Match(@"
(.*?)
", mediahtml))) { String image = m.Groups[1].Value; list.Add(Regex.Replace(image, @"_V1\..*?.jpg", "_V1._SY0.jpg")); @@ -147,7 +147,7 @@ namespace NadekoBot.Modules.Searches.Commands.IMDB } /*******************************[ Helper Methods ]********************************/ //Match single instance - private static string match(string regex, string html, int i = 1) + private static string Match(string regex, string html, int i = 1) { return new Regex(regex, RegexOptions.Multiline).Match(html).Groups[i].Value.Trim(); } diff --git a/src/NadekoBot/Modules/Searches/Commands/JokeCommands.cs b/src/NadekoBot/Modules/Searches/Commands/JokeCommands.cs index c20354fe..03e5363b 100644 --- a/src/NadekoBot/Modules/Searches/Commands/JokeCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/JokeCommands.cs @@ -1,9 +1,10 @@ using Discord; using Discord.Commands; using NadekoBot.Attributes; -using NadekoBot.Modules.Searches.Commands.Models; +using NadekoBot.Modules.Searches.Models; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using NLog; using System; using System.Collections.Generic; using System.IO; @@ -11,21 +12,34 @@ using System.Linq; using System.Net.Http; using System.Threading.Tasks; -namespace NadekoBot.Modules.Searches.Commands +namespace NadekoBot.Modules.Searches { - public partial class SearchesModule + public partial class Searches { [Group] public class JokeCommands { //todo DB - private List wowJokes; + private List wowJokes = new List(); private List magicItems; + private Logger _log; public JokeCommands() { - wowJokes = JsonConvert.DeserializeObject>(File.ReadAllText("data/wowjokes.json")); - magicItems = JsonConvert.DeserializeObject>(File.ReadAllText("data/magicitems.json")); + _log = LogManager.GetCurrentClassLogger(); + if (File.Exists("data/wowjokes.json")) + { + wowJokes = JsonConvert.DeserializeObject>(File.ReadAllText("data/wowjokes.json")); + } + else + _log.Warn("data/wowjokes.json is missing. WOW Jokes are not loaded."); + + if (File.Exists("data/magicitems.json")) + { + magicItems = JsonConvert.DeserializeObject>(File.ReadAllText("data/magicitems.json")); + } + else + _log.Warn("data/magicitems.json is missing. Magic items are not loaded."); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] diff --git a/src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs b/src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs index edc90d4e..dfc25b3e 100644 --- a/src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs @@ -11,7 +11,7 @@ using System.Text; using System.Threading.Tasks; //todo drawing -namespace NadekoBot.Modules.Searches.Commands +namespace NadekoBot.Modules.Searches { public partial class Searches { diff --git a/src/NadekoBot/Modules/Searches/Commands/MemegenCommands.cs b/src/NadekoBot/Modules/Searches/Commands/MemegenCommands.cs index d9bbd55d..d551655c 100644 --- a/src/NadekoBot/Modules/Searches/Commands/MemegenCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/MemegenCommands.cs @@ -11,14 +11,10 @@ using NadekoBot.Attributes; using System.Net.Http; using NadekoBot.Extensions; -namespace NadekoBot.Modules.Searches.Commands +namespace NadekoBot.Modules.Searches { - public partial class SearchesModule : DiscordModule + public partial class Searches { - public SearchesModule(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client) : base(loc, cmds, config, client) - { - } - [LocalizedCommand, LocalizedDescription, LocalizedSummary] [RequireContext(ContextType.Guild)] public async Task Memelist(IMessage imsg) diff --git a/src/NadekoBot/Modules/Searches/Commands/Models/ImdbMovie.cs b/src/NadekoBot/Modules/Searches/Commands/Models/ImdbMovie.cs index 56bbc890..64f819ab 100644 --- a/src/NadekoBot/Modules/Searches/Commands/Models/ImdbMovie.cs +++ b/src/NadekoBot/Modules/Searches/Commands/Models/ImdbMovie.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Net; -namespace NadekoBot.Modules.Searches.Commands.Models +namespace NadekoBot.Modules.Searches.Models { public class ImdbMovie { diff --git a/src/NadekoBot/Modules/Searches/Commands/Models/MagicItem.cs b/src/NadekoBot/Modules/Searches/Commands/Models/MagicItem.cs index a7346247..53397e8e 100644 --- a/src/NadekoBot/Modules/Searches/Commands/Models/MagicItem.cs +++ b/src/NadekoBot/Modules/Searches/Commands/Models/MagicItem.cs @@ -1,4 +1,4 @@ -namespace NadekoBot.Modules.Searches.Commands.Models +namespace NadekoBot.Modules.Searches.Models { class MagicItem { diff --git a/src/NadekoBot/Modules/Searches/Commands/Models/SearchPokemon.cs b/src/NadekoBot/Modules/Searches/Commands/Models/SearchPokemon.cs index 5bafd0d2..be5411d1 100644 --- a/src/NadekoBot/Modules/Searches/Commands/Models/SearchPokemon.cs +++ b/src/NadekoBot/Modules/Searches/Commands/Models/SearchPokemon.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace NadekoBot.Modules.Searches.Commands.Models +namespace NadekoBot.Modules.Searches.Models { public class SearchPokemon { diff --git a/src/NadekoBot/Modules/Searches/Commands/Models/WikipediaApiModel.cs b/src/NadekoBot/Modules/Searches/Commands/Models/WikipediaApiModel.cs index b064b1ca..ed961a2a 100644 --- a/src/NadekoBot/Modules/Searches/Commands/Models/WikipediaApiModel.cs +++ b/src/NadekoBot/Modules/Searches/Commands/Models/WikipediaApiModel.cs @@ -1,4 +1,4 @@ -namespace NadekoBot.Modules.Searches.Commands.Models +namespace NadekoBot.Modules.Searches.Models { public class WikipediaApiModel { diff --git a/src/NadekoBot/Modules/Searches/Commands/Models/WoWJoke.cs b/src/NadekoBot/Modules/Searches/Commands/Models/WoWJoke.cs index 590da6be..b353abd9 100644 --- a/src/NadekoBot/Modules/Searches/Commands/Models/WoWJoke.cs +++ b/src/NadekoBot/Modules/Searches/Commands/Models/WoWJoke.cs @@ -1,4 +1,4 @@ -namespace NadekoBot.Modules.Searches.Commands.Models +namespace NadekoBot.Modules.Searches.Models { public class WoWJoke { diff --git a/src/NadekoBot/Modules/Searches/Commands/OsuCommands.cs b/src/NadekoBot/Modules/Searches/Commands/OsuCommands.cs index 082a4790..3731ff8c 100644 --- a/src/NadekoBot/Modules/Searches/Commands/OsuCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/OsuCommands.cs @@ -7,7 +7,7 @@ //using System.Text.RegularExpressions; //todo DI into partials -//namespace NadekoBot.Modules.Searches.Commands +//namespace NadekoBot.Modules.Searches //{ // internal class OsuCommands : DiscordCommand // { diff --git a/src/NadekoBot/Modules/Searches/Commands/PokemonSearchCommands.cs b/src/NadekoBot/Modules/Searches/Commands/PokemonSearchCommands.cs index 88a1fa65..48789faf 100644 --- a/src/NadekoBot/Modules/Searches/Commands/PokemonSearchCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/PokemonSearchCommands.cs @@ -1,15 +1,16 @@ using Discord; using Discord.Commands; using NadekoBot.Attributes; -using NadekoBot.Modules.Searches.Commands.Models; +using NadekoBot.Modules.Searches.Models; using Newtonsoft.Json; +using NLog; using System.Collections.Generic; using System.IO; using System.Threading.Tasks; -namespace NadekoBot.Modules.Searches.Commands +namespace NadekoBot.Modules.Searches { - public partial class SearchesModule : DiscordModule + public partial class Searches { [Group] public class PokemonSearchCommands @@ -21,12 +22,21 @@ namespace NadekoBot.Modules.Searches.Commands public const string PokemonAbilitiesFile = "data/pokemon/pokemon_abilities.json"; public const string PokemonListFile = "data/pokemon/pokemon_list.json"; + private Logger _log; public PokemonSearchCommands() { - if(File.Exists(PokemonListFile)) - pokemons = JsonConvert.DeserializeObject>(File.ReadAllText(PokemonListFile)); - pokemonAbilities = JsonConvert.DeserializeObject>(File.ReadAllText(PokemonAbilitiesFile)); + _log = LogManager.GetCurrentClassLogger(); + if (File.Exists(PokemonListFile)) + { + pokemons = JsonConvert.DeserializeObject>(File.ReadAllText(PokemonListFile)); + } + else + _log.Warn(PokemonListFile + " is missing. Pokemon abilities not loaded."); + if (File.Exists(PokemonAbilitiesFile)) + pokemonAbilities = JsonConvert.DeserializeObject>(File.ReadAllText(PokemonAbilitiesFile)); + else + _log.Warn(PokemonAbilitiesFile + " is missing. Pokemon abilities not loaded."); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -71,4 +81,4 @@ namespace NadekoBot.Modules.Searches.Commands } } } -} +} \ No newline at end of file diff --git a/src/NadekoBot/Modules/Searches/Commands/StreamNotificationCommands.cs b/src/NadekoBot/Modules/Searches/Commands/StreamNotificationCommands.cs index 746fcc56..9b915794 100644 --- a/src/NadekoBot/Modules/Searches/Commands/StreamNotificationCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/StreamNotificationCommands.cs @@ -10,9 +10,9 @@ //using System.Threading; //todo DB -//namespace NadekoBot.Modules.Searches.Commands +//namespace NadekoBot.Modules.Searches //{ -// public partial class SearchesModule : DiscordModule +// public partial class Searches // { // [Group] // public class StreamNotificationCommands @@ -72,7 +72,7 @@ // }, null, TimeSpan.Zero, TimeSpan.FromSeconds(15)); // } -// public StreamNotifications(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client) : base(loc, cmds, config, client) +// public StreamNotifications(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client) : base(loc, cmds, config, client) // { // } diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index e423207c..4c5cadb9 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -1,6 +1,5 @@ using Discord; using Discord.Commands; -using NadekoBot.Modules.Searches.Commands.IMDB; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; @@ -12,8 +11,9 @@ using NadekoBot.Attributes; using NadekoBot.Extensions; using System.Text.RegularExpressions; using System.Net; -using NadekoBot.Modules.Searches.Commands.Models; -using NCalc; +using Discord.WebSocket; +using NadekoBot.Modules.Searches.Models; +using NadekoBot.Modules.Searches.IMDB; namespace NadekoBot.Modules.Searches { @@ -22,19 +22,10 @@ namespace NadekoBot.Modules.Searches { private IYoutubeService _yt { get; } - public Searches(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client, IYoutubeService youtube) : base(loc, cmds, config, client) + public Searches(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client, IYoutubeService youtube) : base(loc, cmds, config, client) { _yt = youtube; } - - [LocalizedCommand, LocalizedDescription, LocalizedSummary] - [RequireContext(ContextType.Guild)] - public async Task Calc(IMessage msg, [Remainder] string calculation) - { - var channel = msg.Channel as ITextChannel; - - } - [LocalizedCommand, LocalizedDescription, LocalizedSummary] [RequireContext(ContextType.Guild)] public async Task Weather(IMessage imsg, string city, string country) @@ -257,7 +248,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】 [LocalizedCommand, LocalizedDescription, LocalizedSummary] [RequireContext(ContextType.Guild)] - public async Task UrbanDictionary(IMessage imsg, [Remainder] string query = null) + public async Task Ud(IMessage imsg, [Remainder] string query = null) { var channel = imsg.Channel as ITextChannel; diff --git a/src/NadekoBot/Modules/Translator/Translator.cs b/src/NadekoBot/Modules/Translator/Translator.cs index 430ee760..c6833b4c 100644 --- a/src/NadekoBot/Modules/Translator/Translator.cs +++ b/src/NadekoBot/Modules/Translator/Translator.cs @@ -5,13 +5,14 @@ using NadekoBot.Extensions; using System; using System.Threading.Tasks; using NadekoBot.Services; +using Discord.WebSocket; namespace NadekoBot.Modules.Translator { [Module("~", AppendSpace = false)] public class Translator : DiscordModule { - public Translator(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client) : base(loc, cmds, config, client) + public Translator(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client) : base(loc, cmds, config, client) { } diff --git a/src/NadekoBot/Modules/Utility/Commands/Remind.cs b/src/NadekoBot/Modules/Utility/Commands/Remind.cs index 3eaa2b37..be814fea 100644 --- a/src/NadekoBot/Modules/Utility/Commands/Remind.cs +++ b/src/NadekoBot/Modules/Utility/Commands/Remind.cs @@ -9,7 +9,7 @@ //using System.Text.RegularExpressions; //using System.Timers; -//namespace NadekoBot.Modules.Utility.Commands +//namespace NadekoBot.Modules.Utility //{ // class Remind : DiscordCommand // { diff --git a/src/NadekoBot/Modules/Utility/Utility.cs b/src/NadekoBot/Modules/Utility/Utility.cs index 19c3628c..166c9eb5 100644 --- a/src/NadekoBot/Modules/Utility/Utility.cs +++ b/src/NadekoBot/Modules/Utility/Utility.cs @@ -10,6 +10,7 @@ using NadekoBot.Extensions; using System.Text.RegularExpressions; using System.Collections.Generic; using System.Reflection; +using Discord.WebSocket; namespace NadekoBot.Modules.Utility { @@ -17,7 +18,7 @@ namespace NadekoBot.Modules.Utility [Module(".", AppendSpace = false)] public partial class Utility : DiscordModule { - public Utility(ILocalization loc, CommandService cmds, IBotConfiguration config, IDiscordClient client) : base(loc, cmds, config, client) + public Utility(ILocalization loc, CommandService cmds, IBotConfiguration config, DiscordSocketClient client) : base(loc, cmds, config, client) { } diff --git a/src/NadekoBot/NadekoBot.cs b/src/NadekoBot/NadekoBot.cs index 9acc34ac..dda384bd 100644 --- a/src/NadekoBot/NadekoBot.cs +++ b/src/NadekoBot/NadekoBot.cs @@ -52,7 +52,7 @@ namespace NadekoBot var depMap = new DependencyMap(); depMap.Add(Localizer); depMap.Add(Config); - depMap.Add(Client); + depMap.Add(Client); depMap.Add(Commands); depMap.Add(Youtube); diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index c1790e81..bf1f80b2 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -575,27 +575,27 @@ namespace NadekoBot.Resources { /// /// Looks up a localized string similar to Shows a mentioned person's avatar.. /// - public static string av_desc { + public static string avatar_desc { get { - return ResourceManager.GetString("av_desc", resourceCulture); + return ResourceManager.GetString("avatar_desc", resourceCulture); } } /// /// Looks up a localized string similar to `~av "@SomeGuy"`. /// - public static string av_summary { + public static string avatar_summary { get { - return ResourceManager.GetString("av_summary", resourceCulture); + return ResourceManager.GetString("avatar_summary", resourceCulture); } } /// /// Looks up a localized string similar to av. /// - public static string av_text { + public static string avatar_text { get { - return ResourceManager.GetString("av_text", resourceCulture); + return ResourceManager.GetString("avatar_text", resourceCulture); } } @@ -7406,27 +7406,27 @@ namespace NadekoBot.Resources { /// /// Looks up a localized string similar to Shows weather data for a specified city and a country. BOTH ARE REQUIRED. Use country abbrevations.. /// - public static string we_desc { + public static string weather_desc { get { - return ResourceManager.GetString("we_desc", resourceCulture); + return ResourceManager.GetString("weather_desc", resourceCulture); } } /// /// Looks up a localized string similar to `~we Moscow RF`. /// - public static string we_summary { + public static string weather_summary { get { - return ResourceManager.GetString("we_summary", resourceCulture); + return ResourceManager.GetString("weather_summary", resourceCulture); } } /// /// Looks up a localized string similar to we. /// - public static string we_text { + public static string weather_text { get { - return ResourceManager.GetString("we_text", resourceCulture); + return ResourceManager.GetString("weather_text", resourceCulture); } } @@ -7541,27 +7541,27 @@ namespace NadekoBot.Resources { /// /// Looks up a localized string similar to Searches youtubes and shows the first result. /// - public static string yt_desc { + public static string youtube_desc { get { - return ResourceManager.GetString("yt_desc", resourceCulture); + return ResourceManager.GetString("youtube_desc", resourceCulture); } } /// /// Looks up a localized string similar to `~yt query`. /// - public static string yt_summary { + public static string youtube_summary { get { - return ResourceManager.GetString("yt_summary", resourceCulture); + return ResourceManager.GetString("youtube_summary", resourceCulture); } } /// /// Looks up a localized string similar to yt. /// - public static string yt_text { + public static string youtube_text { get { - return ResourceManager.GetString("yt_text", resourceCulture); + return ResourceManager.GetString("youtube_text", resourceCulture); } } } diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 10d9f8e2..e33eeace 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -2115,22 +2115,22 @@ `~memegen biw "gets iced coffee" "in the winter"` - + we - + Shows weather data for a specified city and a country. BOTH ARE REQUIRED. Use country abbrevations. - + `~we Moscow RF` - + yt - + Searches youtubes and shows the first result - + `~yt query` @@ -2349,13 +2349,13 @@ `~videocall "@SomeGuy"` - + av - + Shows a mentioned person's avatar. - + `~av "@SomeGuy"` diff --git a/src/NadekoBot/Services/Impl/BotCredentials.cs b/src/NadekoBot/Services/Impl/BotCredentials.cs index ed8492d8..2f4b5f6a 100644 --- a/src/NadekoBot/Services/Impl/BotCredentials.cs +++ b/src/NadekoBot/Services/Impl/BotCredentials.cs @@ -4,12 +4,15 @@ using System.Collections.Generic; using System.IO; using Discord; using System.Linq; +using NLog; namespace NadekoBot.Services.Impl { //todo load creds public class BotCredentials : IBotCredentials { + private Logger _log; + public string ClientId { get; } public string GoogleApiKey { get; } @@ -24,10 +27,16 @@ namespace NadekoBot.Services.Impl public BotCredentials() { - var cm = JsonConvert.DeserializeObject(File.ReadAllText("./credentials.json")); - Token = cm.Token; - OwnerIds = cm.OwnerIds; - LoLApiKey = cm.LoLApiKey; + _log = LogManager.GetCurrentClassLogger(); + if (File.Exists("./credentials.json")) + { + var cm = JsonConvert.DeserializeObject(File.ReadAllText("./credentials.json")); + Token = cm.Token; + OwnerIds = cm.OwnerIds; + LoLApiKey = cm.LoLApiKey; + } + else + _log.Fatal("credentials.json is missing. Failed to start."); } private class CredentialsModel { diff --git a/src/NadekoBot/_Modules/Permissions/Commands/FilterInvitesCommand.cs b/src/NadekoBot/_Modules/Permissions/Commands/FilterInvitesCommand.cs index bc3a5134..8109ca2b 100644 --- a/src/NadekoBot/_Modules/Permissions/Commands/FilterInvitesCommand.cs +++ b/src/NadekoBot/_Modules/Permissions/Commands/FilterInvitesCommand.cs @@ -5,7 +5,7 @@ using NadekoBot.Modules.Permissions.Classes; using System; using System.Text.RegularExpressions; -namespace NadekoBot.Modules.Permissions.Commands +namespace NadekoBot.Modules.Permissions { internal class FilterInvitesCommand : DiscordCommand { diff --git a/src/NadekoBot/_Modules/Permissions/Commands/FilterWordsCommand.cs b/src/NadekoBot/_Modules/Permissions/Commands/FilterWordsCommand.cs index 86882cd4..deb3920b 100644 --- a/src/NadekoBot/_Modules/Permissions/Commands/FilterWordsCommand.cs +++ b/src/NadekoBot/_Modules/Permissions/Commands/FilterWordsCommand.cs @@ -5,7 +5,7 @@ using NadekoBot.Modules.Permissions.Classes; using System; using System.Linq; -namespace NadekoBot.Modules.Permissions.Commands +namespace NadekoBot.Modules.Permissions { internal class FilterWords : DiscordCommand { diff --git a/src/NadekoBot/project.json b/src/NadekoBot/project.json index adb85ef6..7d3699e6 100644 --- a/src/NadekoBot/project.json +++ b/src/NadekoBot/project.json @@ -1,6 +1,6 @@ { "version": "1.0.0-*", - "description": "General purposee Discord bot written in C#.", + "description": "General purpose Discord bot written in C#.", "authors": [ "Kwoth" ], "copyright": "Kwoth", "buildOptions": {