Repo builds, probably with a lot of bugs
This commit is contained in:
		| @@ -69,7 +69,7 @@ Version: `{NadekoStats.Instance.BotVersion}`"; | |||||||
|                 } |                 } | ||||||
|                 helpstr += PrintCommandHelp(com); |                 helpstr += PrintCommandHelp(com); | ||||||
|             } |             } | ||||||
|             helpstr = helpstr.Replace(NadekoBot.botMention, "@BotName"); |             helpstr = helpstr.Replace(NadekoBot.BotMention, "@BotName"); | ||||||
|             helpstr = helpstr.Replace("\n**Usage**:", " | ").Replace("**Usage**:", " | ").Replace("**Description:**", " | ").Replace("\n|", " |  \n"); |             helpstr = helpstr.Replace("\n**Usage**:", " | ").Replace("**Usage**:", " | ").Replace("**Description:**", " | ").Replace("\n|", " |  \n"); | ||||||
| #if DEBUG | #if DEBUG | ||||||
|             File.WriteAllText("../../../commandlist.md", helpstr); |             File.WriteAllText("../../../commandlist.md", helpstr); | ||||||
| @@ -81,7 +81,7 @@ Version: `{NadekoStats.Instance.BotVersion}`"; | |||||||
|  |  | ||||||
|         public override void Init(CommandGroupBuilder cgb) { |         public override void Init(CommandGroupBuilder cgb) { | ||||||
|             cgb.CreateCommand("-h") |             cgb.CreateCommand("-h") | ||||||
|                 .Alias(new string[] { "-help", NadekoBot.botMention + " help", NadekoBot.botMention + " h", "~h" }) |                 .Alias(new string[] { "-help", NadekoBot.BotMention + " help", NadekoBot.BotMention + " h", "~h" }) | ||||||
|                 .Description("Either shows a help for a single command, or PMs you help link if no arguments are specified.\n**Usage**: '-h !m q' or just '-h' ") |                 .Description("Either shows a help for a single command, or PMs you help link if no arguments are specified.\n**Usage**: '-h !m q' or just '-h' ") | ||||||
|                 .Parameter("command", ParameterType.Unparsed) |                 .Parameter("command", ParameterType.Unparsed) | ||||||
|                 .Do(DoFunc()); |                 .Do(DoFunc()); | ||||||
| @@ -114,10 +114,9 @@ You can join nadekobot server by simply private messaging NadekoBot, and you wil | |||||||
|                 }); |                 }); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private string PrintCommandHelp(Command com) { |         private static string PrintCommandHelp(Command com) { | ||||||
|             var str = "`" + com.Text + "`"; |             var str = "`" + com.Text + "`"; | ||||||
|             foreach (var a in com.Aliases) |             str = com.Aliases.Aggregate(str, (current, a) => current + (", `" + a + "`")); | ||||||
|                 str += ", `" + a + "`"; |  | ||||||
|             str += " **Description:** " + com.Description + "\n"; |             str += " **Description:** " + com.Description + "\n"; | ||||||
|             return str; |             return str; | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -482,7 +482,7 @@ namespace NadekoBot.Modules { | |||||||
|                   .Description("Sets the bots game.") |                   .Description("Sets the bots game.") | ||||||
|                   .Parameter("set_game", ParameterType.Unparsed) |                   .Parameter("set_game", ParameterType.Unparsed) | ||||||
|                   .Do(e => { |                   .Do(e => { | ||||||
|                       if (e.User.Id != NadekoBot.Creds.OwnerID || e.GetArg("set_game") == null) return; |                       if (!NadekoBot.IsOwner(e.User.Id) || e.GetArg("set_game") == null) return; | ||||||
|  |  | ||||||
|                       client.SetGame(e.GetArg("set_game")); |                       client.SetGame(e.GetArg("set_game")); | ||||||
|                   }); |                   }); | ||||||
|   | |||||||
| @@ -27,8 +27,7 @@ namespace NadekoBot.Modules { | |||||||
|                 try { |                 try { | ||||||
|                     int num = musicPlayers.Where(kvp => kvp.Value.CurrentSong != null).Count(); |                     int num = musicPlayers.Where(kvp => kvp.Value.CurrentSong != null).Count(); | ||||||
|                     NadekoBot.Client.SetGame($"{num} songs".SnPl(num) + $", {musicPlayers.Sum(kvp => kvp.Value.Playlist.Count())} queued"); |                     NadekoBot.Client.SetGame($"{num} songs".SnPl(num) + $", {musicPlayers.Sum(kvp => kvp.Value.Playlist.Count())} queued"); | ||||||
|                 } |                 } catch { } | ||||||
|                 catch { } |  | ||||||
|             }; |             }; | ||||||
|  |  | ||||||
|         } |         } | ||||||
| @@ -62,8 +61,7 @@ namespace NadekoBot.Modules { | |||||||
|                         await Task.Delay(5000); |                         await Task.Delay(5000); | ||||||
|                         try { |                         try { | ||||||
|                             await msg.Delete(); |                             await msg.Delete(); | ||||||
|                         } |                         } catch { } | ||||||
|                         catch { } |  | ||||||
|                     }); |                     }); | ||||||
|  |  | ||||||
|                 cgb.CreateCommand("p") |                 cgb.CreateCommand("p") | ||||||
| @@ -212,9 +210,14 @@ namespace NadekoBot.Modules { | |||||||
|                         } |                         } | ||||||
|                         var ids = await SearchHelper.GetVideoIDs(await SearchHelper.GetPlaylistIdByKeyword(e.GetArg("playlist"))); |                         var ids = await SearchHelper.GetVideoIDs(await SearchHelper.GetPlaylistIdByKeyword(e.GetArg("playlist"))); | ||||||
|                         //todo TEMPORARY SOLUTION, USE RESOLVE QUEUE IN THE FUTURE |                         //todo TEMPORARY SOLUTION, USE RESOLVE QUEUE IN THE FUTURE | ||||||
|                         var msg = await e.Channel.SendMessage($"🎵 `Attempting to queue {ids.Count} songs".SnPl(ids.Count) + "...`"); |                         var idArray = ids as string[] ?? ids.ToArray(); | ||||||
|                         foreach (var id in ids) { |                         var count = idArray.Count(); | ||||||
|  |                         var msg = | ||||||
|  |                             await e.Channel.SendMessage($"🎵 `Attempting to queue {count} songs".SnPl(count) + "...`"); | ||||||
|  |                         foreach (var id in idArray) { | ||||||
|  |                             try { | ||||||
|                                 await QueueSong(e.Channel, e.User.VoiceChannel, id, true); |                                 await QueueSong(e.Channel, e.User.VoiceChannel, id, true); | ||||||
|  |                             } catch { } | ||||||
|                         } |                         } | ||||||
|                         await msg.Edit("🎵 `Playlist queue complete.`"); |                         await msg.Edit("🎵 `Playlist queue complete.`"); | ||||||
|                     }); |                     }); | ||||||
| @@ -233,8 +236,7 @@ namespace NadekoBot.Modules { | |||||||
|                                 await QueueSong(e.Channel, e.User.VoiceChannel, file, true, MusicType.Local); |                                 await QueueSong(e.Channel, e.User.VoiceChannel, file, true, MusicType.Local); | ||||||
|                             } |                             } | ||||||
|                             await e.Channel.SendMessage("🎵 `Directory queue complete.`"); |                             await e.Channel.SendMessage("🎵 `Directory queue complete.`"); | ||||||
|                         } |                         } catch { } | ||||||
|                         catch { } |  | ||||||
|                     }); |                     }); | ||||||
|  |  | ||||||
|                 cgb.CreateCommand("radio").Alias("ra") |                 cgb.CreateCommand("radio").Alias("ra") | ||||||
| @@ -306,7 +308,7 @@ namespace NadekoBot.Modules { | |||||||
|  |  | ||||||
|         private async Task QueueSong(Channel TextCh, Channel VoiceCh, string query, bool silent = false, MusicType musicType = MusicType.Normal) { |         private async Task QueueSong(Channel TextCh, Channel VoiceCh, string query, bool silent = false, MusicType musicType = MusicType.Normal) { | ||||||
|             if (VoiceCh == null || VoiceCh.Server != TextCh.Server) { |             if (VoiceCh == null || VoiceCh.Server != TextCh.Server) { | ||||||
|                 if(!silent) |                 if (!silent) | ||||||
|                     await TextCh.SendMessage("💢 You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining."); |                     await TextCh.SendMessage("💢 You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining."); | ||||||
|                 throw new ArgumentNullException(nameof(VoiceCh)); |                 throw new ArgumentNullException(nameof(VoiceCh)); | ||||||
|             } |             } | ||||||
| @@ -322,22 +324,20 @@ namespace NadekoBot.Modules { | |||||||
|                     OnCompleted = async (song) => { |                     OnCompleted = async (song) => { | ||||||
|                         try { |                         try { | ||||||
|                             await TextCh.SendMessage($"🎵`Finished`{song.PrettyName}"); |                             await TextCh.SendMessage($"🎵`Finished`{song.PrettyName}"); | ||||||
|                         } |                         } catch { } | ||||||
|                         catch { } |  | ||||||
|                     }, |                     }, | ||||||
|                     OnStarted = async (song) => { |                     OnStarted = async (song) => { | ||||||
|                         try { |                         try { | ||||||
|                             var msgTxt = $"🎵`Playing`{song.PrettyName} `Vol: {(int)(musicPlayer.Volume * 100)}%`"; |                             var msgTxt = $"🎵`Playing`{song.PrettyName} `Vol: {(int)(musicPlayer.Volume * 100)}%`"; | ||||||
|                             await TextCh.SendMessage(msgTxt); |                             await TextCh.SendMessage(msgTxt); | ||||||
|                         } |                         } catch { } | ||||||
|                         catch { } |  | ||||||
|                     }, |                     }, | ||||||
|                 }; |                 }; | ||||||
|                 musicPlayers.TryAdd(TextCh.Server, musicPlayer); |                 musicPlayers.TryAdd(TextCh.Server, musicPlayer); | ||||||
|             } |             } | ||||||
|             var resolvedSong = await Song.ResolveSong(query, musicType); |             var resolvedSong = await Song.ResolveSong(query, musicType); | ||||||
|             resolvedSong.MusicPlayer = musicPlayer; |             resolvedSong.MusicPlayer = musicPlayer; | ||||||
|             if(!silent) |             if (!silent) | ||||||
|                 await TextCh.Send($"🎵`Queued`{resolvedSong.PrettyName}"); |                 await TextCh.Send($"🎵`Queued`{resolvedSong.PrettyName}"); | ||||||
|             musicPlayer.AddSong(resolvedSong); |             musicPlayer.AddSong(resolvedSong); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -6,6 +6,8 @@ using Newtonsoft.Json.Linq; | |||||||
| using Discord.Commands; | using Discord.Commands; | ||||||
| using NadekoBot.Extensions; | using NadekoBot.Extensions; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
|  | using System.Drawing; | ||||||
|  | using System.Linq; | ||||||
| using NadekoBot.Classes; | using NadekoBot.Classes; | ||||||
| using NadekoBot.Commands; | using NadekoBot.Commands; | ||||||
|  |  | ||||||
| @@ -30,12 +32,8 @@ namespace NadekoBot.Modules { | |||||||
|                     .Do(async e => { |                     .Do(async e => { | ||||||
|                         if (!(await SearchHelper.ValidateQuery(e.Channel, e.GetArg("query")))) return; |                         if (!(await SearchHelper.ValidateQuery(e.Channel, e.GetArg("query")))) return; | ||||||
|  |  | ||||||
|                         var str = await SearchHelper.ShortenUrl(await SearchHelper.FindYoutubeUrlByKeywords(e.GetArg("query"))); |                         var shortUrl = await SearchHelper.ShortenUrl(await SearchHelper.FindYoutubeUrlByKeywords(e.GetArg("query"))); | ||||||
|                         if (string.IsNullOrEmpty(str.Trim())) { |                         await e.Channel.SendMessage(shortUrl); | ||||||
|                             await e.Channel.SendMessage("Query failed."); |  | ||||||
|                             return; |  | ||||||
|                         } |  | ||||||
|                         await e.Channel.SendMessage(str); |  | ||||||
|                     }); |                     }); | ||||||
|  |  | ||||||
|                 cgb.CreateCommand("~ani") |                 cgb.CreateCommand("~ani") | ||||||
| @@ -44,9 +42,10 @@ namespace NadekoBot.Modules { | |||||||
|                     .Description("Queries anilist for an anime and shows the first result.") |                     .Description("Queries anilist for an anime and shows the first result.") | ||||||
|                     .Do(async e => { |                     .Do(async e => { | ||||||
|                         if (!(await SearchHelper.ValidateQuery(e.Channel, e.GetArg("query")))) return; |                         if (!(await SearchHelper.ValidateQuery(e.Channel, e.GetArg("query")))) return; | ||||||
|  |                         string result; | ||||||
|                         var result = await SearchHelper.GetAnimeQueryResultLink(e.GetArg("query")); |                         try { | ||||||
|                         if (result == null) { |                             result = (await SearchHelper.GetAnimeQueryResultLink(e.GetArg("query"))).ToString(); | ||||||
|  |                         } catch { | ||||||
|                             await e.Channel.SendMessage("Failed to find that anime."); |                             await e.Channel.SendMessage("Failed to find that anime."); | ||||||
|                             return; |                             return; | ||||||
|                         } |                         } | ||||||
| @@ -60,23 +59,21 @@ namespace NadekoBot.Modules { | |||||||
|                     .Description("Queries anilist for a manga and shows the first result.") |                     .Description("Queries anilist for a manga and shows the first result.") | ||||||
|                     .Do(async e => { |                     .Do(async e => { | ||||||
|                         if (!(await SearchHelper.ValidateQuery(e.Channel, e.GetArg("query")))) return; |                         if (!(await SearchHelper.ValidateQuery(e.Channel, e.GetArg("query")))) return; | ||||||
|  |                         string result; | ||||||
|                         var result = await SearchHelper.GetMangaQueryResultLink(e.GetArg("query")); |                         try { | ||||||
|                         if (result == null) { |                             result = (await SearchHelper.GetMangaQueryResultLink(e.GetArg("query"))).ToString(); | ||||||
|                             await e.Channel.SendMessage("Failed to find that manga."); |                         } catch { | ||||||
|  |                             await e.Channel.SendMessage("Failed to find that anime."); | ||||||
|                             return; |                             return; | ||||||
|                         } |                         } | ||||||
|                         await e.Channel.SendMessage(result.ToString()); |                         await e.Channel.SendMessage(result); | ||||||
|                     }); |                     }); | ||||||
|  |  | ||||||
|                 cgb.CreateCommand("~randomcat") |                 cgb.CreateCommand("~randomcat") | ||||||
|                     .Description("Shows a random cat image.") |                     .Description("Shows a random cat image.") | ||||||
|                     .Do(async e => { |                     .Do(async e => { | ||||||
|                         try { |  | ||||||
|                         await e.Channel.SendMessage(JObject.Parse( |                         await e.Channel.SendMessage(JObject.Parse( | ||||||
|                             await SearchHelper.GetResponseStringAsync("http://www.random.cat/meow"))["file"].ToString()); |                             await SearchHelper.GetResponseStringAsync("http://www.random.cat/meow"))["file"].ToString()); | ||||||
|                         } |  | ||||||
|                         catch {} |  | ||||||
|                     }); |                     }); | ||||||
|  |  | ||||||
|                 cgb.CreateCommand("~i") |                 cgb.CreateCommand("~i") | ||||||
| @@ -127,22 +124,18 @@ namespace NadekoBot.Modules { | |||||||
|                           return; |                           return; | ||||||
|                       } |                       } | ||||||
|                       await e.Channel.SendIsTyping(); |                       await e.Channel.SendIsTyping(); | ||||||
|                       var headers = new WebHeaderCollection {{"X-Mashape-Key", NadekoBot.Creds.MashapeKey}}; |                       var headers = new Dictionary<string, string> { { "X-Mashape-Key", NadekoBot.Creds.MashapeKey } }; | ||||||
|                       var res = await SearchHelper.GetResponseStringAsync($"https://omgvamp-hearthstone-v1.p.mashape.com/cards/search/{Uri.EscapeUriString(arg)}", headers); |                       var res = await SearchHelper.GetResponseStringAsync($"https://omgvamp-hearthstone-v1.p.mashape.com/cards/search/{Uri.EscapeUriString(arg)}", headers); | ||||||
|                       try { |                       try { | ||||||
|                           var items = JArray.Parse(res); |                           var items = JArray.Parse(res) as JArray; | ||||||
|                           List<System.Drawing.Image> images = new List<System.Drawing.Image>(); |                           var images = new List<System.Drawing.Image>(); | ||||||
|                           if (items == null) |                           if (items == null) | ||||||
|                               throw new KeyNotFoundException("Cannot find a card by that name"); |                               throw new KeyNotFoundException("Cannot find a card by that name"); | ||||||
|                           int cnt = 0; |                           var cnt = 0; | ||||||
|                           items.Shuffle(); |                           items.Shuffle(); | ||||||
|                           foreach (var item in items) { |                           foreach (var item in items.TakeWhile(item => cnt++ < 4).Where(item => item.HasValues && item["img"] != null)) { | ||||||
|                               if (cnt >= 4) |                               images.Add( | ||||||
|                                   break; |                                   Image.FromStream(await SearchHelper.GetResponseStreamAsync(item["img"].ToString()))); | ||||||
|                               if (!item.HasValues || item["img"] == null) |  | ||||||
|                                   continue; |  | ||||||
|                               cnt++; |  | ||||||
|                               images.Add(System.Drawing.Bitmap.FromStream(await SearchHelper.GetResponseStreamAsync(item["img"].ToString()))); |  | ||||||
|                           } |                           } | ||||||
|                           if (items.Count > 4) { |                           if (items.Count > 4) { | ||||||
|                               await e.Channel.SendMessage("⚠ Found over 4 images. Showing random 4."); |                               await e.Channel.SendMessage("⚠ Found over 4 images. Showing random 4."); | ||||||
| @@ -187,8 +180,7 @@ namespace NadekoBot.Modules { | |||||||
|                           return; |                           return; | ||||||
|                       } |                       } | ||||||
|                       await e.Channel.SendIsTyping(); |                       await e.Channel.SendIsTyping(); | ||||||
|                       var headers = new WebHeaderCollection(); |                       var headers = new Dictionary<string, string> { { "X-Mashape-Key", NadekoBot.Creds.MashapeKey } }; | ||||||
|                       headers.Add("X-Mashape-Key", NadekoBot.Creds.MashapeKey); |  | ||||||
|                       var res = await SearchHelper.GetResponseStringAsync($"https://mashape-community-urban-dictionary.p.mashape.com/define?term={Uri.EscapeUriString(arg)}", headers); |                       var res = await SearchHelper.GetResponseStringAsync($"https://mashape-community-urban-dictionary.p.mashape.com/define?term={Uri.EscapeUriString(arg)}", headers); | ||||||
|                       try { |                       try { | ||||||
|                           var items = JObject.Parse(res); |                           var items = JObject.Parse(res); | ||||||
| @@ -212,8 +204,7 @@ namespace NadekoBot.Modules { | |||||||
|                           return; |                           return; | ||||||
|                       } |                       } | ||||||
|                       await e.Channel.SendIsTyping(); |                       await e.Channel.SendIsTyping(); | ||||||
|                       var headers = new WebHeaderCollection(); |                       var headers = new Dictionary<string, string> { { "X-Mashape-Key", NadekoBot.Creds.MashapeKey } }; | ||||||
|                       headers.Add("X-Mashape-Key", NadekoBot.Creds.MashapeKey); |  | ||||||
|                       var res = await SearchHelper.GetResponseStringAsync($"https://tagdef.p.mashape.com/one.{Uri.EscapeUriString(arg)}.json", headers); |                       var res = await SearchHelper.GetResponseStringAsync($"https://tagdef.p.mashape.com/one.{Uri.EscapeUriString(arg)}.json", headers); | ||||||
|                       try { |                       try { | ||||||
|                           var items = JObject.Parse(res); |                           var items = JObject.Parse(res); | ||||||
|   | |||||||
| @@ -18,7 +18,7 @@ namespace NadekoBot.Modules { | |||||||
|             TrelloConfiguration.Deserializer = serializer; |             TrelloConfiguration.Deserializer = serializer; | ||||||
|             TrelloConfiguration.JsonFactory = new ManateeFactory(); |             TrelloConfiguration.JsonFactory = new ManateeFactory(); | ||||||
|             TrelloConfiguration.RestClientProvider = new Manatee.Trello.WebApi.WebApiClientProvider(); |             TrelloConfiguration.RestClientProvider = new Manatee.Trello.WebApi.WebApiClientProvider(); | ||||||
|             TrelloAuthorization.Default.AppKey = NadekoBot.TrelloAppKey; |             TrelloAuthorization.Default.AppKey = NadekoBot.Creds.TrelloAppKey; | ||||||
|             //TrelloAuthorization.Default.UserToken = "[your user token]"; |             //TrelloAuthorization.Default.UserToken = "[your user token]"; | ||||||
|  |  | ||||||
|             Discord.Channel bound = null; |             Discord.Channel bound = null; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user