From 066fc00bc74f1cbc9f2f6d5a3271f96e83e4a98f Mon Sep 17 00:00:00 2001 From: Kwoth Date: Mon, 11 Jan 2016 20:35:49 +0100 Subject: [PATCH] stats collecting works now, optional - ParseKey and parse ID are now optional. If you don't enter them, logging will be disabled - GoogleAPI key is optional but you won't be able to queue music. - removed testq --- NadekoBot/Modules/Music.cs | 16 ---------------- NadekoBot/NadekoBot.cs | 28 ++++++++++++++++------------ NadekoBot/StatsCollector.cs | 1 - 3 files changed, 16 insertions(+), 29 deletions(-) diff --git a/NadekoBot/Modules/Music.cs b/NadekoBot/Modules/Music.cs index 6ba63884..4dd757e0 100644 --- a/NadekoBot/Modules/Music.cs +++ b/NadekoBot/Modules/Music.cs @@ -83,22 +83,6 @@ namespace NadekoBot.Modules { } }); - cgb.CreateCommand("testq") - .Description("Queue a song using a multi/single word name.\n**Usage**: `!m q Dream Of Venice`") - .Parameter("Query", ParameterType.Unparsed) - .Do(async e => { - var youtube = YouTube.Default; - var video = youtube.GetAllVideos(e.GetArg("Query")) - .Where(v => v.AdaptiveKind == AdaptiveKind.Audio) - .OrderByDescending(v => v.AudioBitrate).FirstOrDefault(); - - if (video?.Uri != "" && video.Uri != null) { - SongQueue.Add(video); - - await e.Send("**Queued** " + video.FullName+ video.Stream().Length); - } - }); - cgb.CreateCommand("q") .Alias("yq") .Description("Queue a song using a multi/single word name.\n**Usage**: `!m q Dream Of Venice`") diff --git a/NadekoBot/NadekoBot.cs b/NadekoBot/NadekoBot.cs index 1c72f15c..ccdcc96d 100644 --- a/NadekoBot/NadekoBot.cs +++ b/NadekoBot/NadekoBot.cs @@ -14,9 +14,9 @@ namespace NadekoBot class NadekoBot { public static DiscordClient client; - // public static StatsCollector stats_collector; + public static StatsCollector stats_collector; public static string botMention; - public static string GoogleAPIKey; + public static string GoogleAPIKey = null; public static ulong OwnerID; public static string password; @@ -28,7 +28,9 @@ namespace NadekoBot { c = JsonConvert.DeserializeObject(File.ReadAllText("credentials.json")); botMention = c.BotMention; - GoogleAPIKey = c.GoogleAPIKey; + if (c.GoogleAPIKey == null || c.GoogleAPIKey == "") { + Console.WriteLine("No google api key found. You will not be able to use music and links won't be shortened."); + } OwnerID = c.OwnerID; password = c.Password; } @@ -39,14 +41,8 @@ namespace NadekoBot return; } - client = new DiscordClient(); - - //init parse - if (c.ParseKey != null && c.ParseID != null) - ParseClient.Initialize(c.ParseID,c.ParseKey); - //create new discord client - + client = new DiscordClient(); //create a command service var commandService = new CommandService(new CommandServiceConfig @@ -55,8 +51,16 @@ namespace NadekoBot HelpMode = HelpMode.Disable }); - //monitor commands for logging - //stats_collector = new StatsCollector(commandService); + //init parse + if (c.ParseKey != null && c.ParseID != null && c.ParseID != "" && c.ParseKey != "") { + ParseClient.Initialize(c.ParseID, c.ParseKey); + + //monitor commands for logging + stats_collector = new StatsCollector(commandService); + } else { + Console.WriteLine("Parse key and/or ID not found. Bot will not log."); + } + //add command service var commands = client.Services.Add(commandService); diff --git a/NadekoBot/StatsCollector.cs b/NadekoBot/StatsCollector.cs index 37412afe..aa06b218 100644 --- a/NadekoBot/StatsCollector.cs +++ b/NadekoBot/StatsCollector.cs @@ -177,7 +177,6 @@ namespace NadekoBot private void StatsCollector_RanCommand(object sender, CommandEventArgs e) { - Console.WriteLine("command ran"); commandsRan++; var obj = new ParseObject("CommandsRan");