Repo builds, probably with a lot of bugs
This commit is contained in:
parent
470de71901
commit
af5d11d533
@ -69,7 +69,7 @@ Version: `{NadekoStats.Instance.BotVersion}`";
|
||||
}
|
||||
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");
|
||||
#if DEBUG
|
||||
File.WriteAllText("../../../commandlist.md", helpstr);
|
||||
@ -81,7 +81,7 @@ Version: `{NadekoStats.Instance.BotVersion}`";
|
||||
|
||||
public override void Init(CommandGroupBuilder cgb) {
|
||||
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' ")
|
||||
.Parameter("command", ParameterType.Unparsed)
|
||||
.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 + "`";
|
||||
foreach (var a in com.Aliases)
|
||||
str += ", `" + a + "`";
|
||||
str = com.Aliases.Aggregate(str, (current, a) => current + (", `" + a + "`"));
|
||||
str += " **Description:** " + com.Description + "\n";
|
||||
return str;
|
||||
}
|
||||
|
@ -482,7 +482,7 @@ namespace NadekoBot.Modules {
|
||||
.Description("Sets the bots game.")
|
||||
.Parameter("set_game", ParameterType.Unparsed)
|
||||
.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"));
|
||||
});
|
||||
|
@ -27,8 +27,7 @@ namespace NadekoBot.Modules {
|
||||
try {
|
||||
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");
|
||||
}
|
||||
catch { }
|
||||
} catch { }
|
||||
};
|
||||
|
||||
}
|
||||
@ -62,8 +61,7 @@ namespace NadekoBot.Modules {
|
||||
await Task.Delay(5000);
|
||||
try {
|
||||
await msg.Delete();
|
||||
}
|
||||
catch { }
|
||||
} catch { }
|
||||
});
|
||||
|
||||
cgb.CreateCommand("p")
|
||||
@ -212,9 +210,14 @@ namespace NadekoBot.Modules {
|
||||
}
|
||||
var ids = await SearchHelper.GetVideoIDs(await SearchHelper.GetPlaylistIdByKeyword(e.GetArg("playlist")));
|
||||
//todo TEMPORARY SOLUTION, USE RESOLVE QUEUE IN THE FUTURE
|
||||
var msg = await e.Channel.SendMessage($"🎵 `Attempting to queue {ids.Count} songs".SnPl(ids.Count) + "...`");
|
||||
foreach (var id in ids) {
|
||||
var idArray = ids as string[] ?? ids.ToArray();
|
||||
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);
|
||||
} catch { }
|
||||
}
|
||||
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 e.Channel.SendMessage("🎵 `Directory queue complete.`");
|
||||
}
|
||||
catch { }
|
||||
} catch { }
|
||||
});
|
||||
|
||||
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) {
|
||||
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.");
|
||||
throw new ArgumentNullException(nameof(VoiceCh));
|
||||
}
|
||||
@ -322,22 +324,20 @@ namespace NadekoBot.Modules {
|
||||
OnCompleted = async (song) => {
|
||||
try {
|
||||
await TextCh.SendMessage($"🎵`Finished`{song.PrettyName}");
|
||||
}
|
||||
catch { }
|
||||
} catch { }
|
||||
},
|
||||
OnStarted = async (song) => {
|
||||
try {
|
||||
var msgTxt = $"🎵`Playing`{song.PrettyName} `Vol: {(int)(musicPlayer.Volume * 100)}%`";
|
||||
await TextCh.SendMessage(msgTxt);
|
||||
}
|
||||
catch { }
|
||||
} catch { }
|
||||
},
|
||||
};
|
||||
musicPlayers.TryAdd(TextCh.Server, musicPlayer);
|
||||
}
|
||||
var resolvedSong = await Song.ResolveSong(query, musicType);
|
||||
resolvedSong.MusicPlayer = musicPlayer;
|
||||
if(!silent)
|
||||
if (!silent)
|
||||
await TextCh.Send($"🎵`Queued`{resolvedSong.PrettyName}");
|
||||
musicPlayer.AddSong(resolvedSong);
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ using Newtonsoft.Json.Linq;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Extensions;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using NadekoBot.Classes;
|
||||
using NadekoBot.Commands;
|
||||
|
||||
@ -30,12 +32,8 @@ namespace NadekoBot.Modules {
|
||||
.Do(async e => {
|
||||
if (!(await SearchHelper.ValidateQuery(e.Channel, e.GetArg("query")))) return;
|
||||
|
||||
var str = await SearchHelper.ShortenUrl(await SearchHelper.FindYoutubeUrlByKeywords(e.GetArg("query")));
|
||||
if (string.IsNullOrEmpty(str.Trim())) {
|
||||
await e.Channel.SendMessage("Query failed.");
|
||||
return;
|
||||
}
|
||||
await e.Channel.SendMessage(str);
|
||||
var shortUrl = await SearchHelper.ShortenUrl(await SearchHelper.FindYoutubeUrlByKeywords(e.GetArg("query")));
|
||||
await e.Channel.SendMessage(shortUrl);
|
||||
});
|
||||
|
||||
cgb.CreateCommand("~ani")
|
||||
@ -44,9 +42,10 @@ namespace NadekoBot.Modules {
|
||||
.Description("Queries anilist for an anime and shows the first result.")
|
||||
.Do(async e => {
|
||||
if (!(await SearchHelper.ValidateQuery(e.Channel, e.GetArg("query")))) return;
|
||||
|
||||
var result = await SearchHelper.GetAnimeQueryResultLink(e.GetArg("query"));
|
||||
if (result == null) {
|
||||
string result;
|
||||
try {
|
||||
result = (await SearchHelper.GetAnimeQueryResultLink(e.GetArg("query"))).ToString();
|
||||
} catch {
|
||||
await e.Channel.SendMessage("Failed to find that anime.");
|
||||
return;
|
||||
}
|
||||
@ -60,23 +59,21 @@ namespace NadekoBot.Modules {
|
||||
.Description("Queries anilist for a manga and shows the first result.")
|
||||
.Do(async e => {
|
||||
if (!(await SearchHelper.ValidateQuery(e.Channel, e.GetArg("query")))) return;
|
||||
|
||||
var result = await SearchHelper.GetMangaQueryResultLink(e.GetArg("query"));
|
||||
if (result == null) {
|
||||
await e.Channel.SendMessage("Failed to find that manga.");
|
||||
string result;
|
||||
try {
|
||||
result = (await SearchHelper.GetMangaQueryResultLink(e.GetArg("query"))).ToString();
|
||||
} catch {
|
||||
await e.Channel.SendMessage("Failed to find that anime.");
|
||||
return;
|
||||
}
|
||||
await e.Channel.SendMessage(result.ToString());
|
||||
await e.Channel.SendMessage(result);
|
||||
});
|
||||
|
||||
cgb.CreateCommand("~randomcat")
|
||||
.Description("Shows a random cat image.")
|
||||
.Do(async e => {
|
||||
try {
|
||||
await e.Channel.SendMessage(JObject.Parse(
|
||||
await SearchHelper.GetResponseStringAsync("http://www.random.cat/meow"))["file"].ToString());
|
||||
}
|
||||
catch {}
|
||||
});
|
||||
|
||||
cgb.CreateCommand("~i")
|
||||
@ -127,22 +124,18 @@ namespace NadekoBot.Modules {
|
||||
return;
|
||||
}
|
||||
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);
|
||||
try {
|
||||
var items = JArray.Parse(res);
|
||||
List<System.Drawing.Image> images = new List<System.Drawing.Image>();
|
||||
var items = JArray.Parse(res) as JArray;
|
||||
var images = new List<System.Drawing.Image>();
|
||||
if (items == null)
|
||||
throw new KeyNotFoundException("Cannot find a card by that name");
|
||||
int cnt = 0;
|
||||
var cnt = 0;
|
||||
items.Shuffle();
|
||||
foreach (var item in items) {
|
||||
if (cnt >= 4)
|
||||
break;
|
||||
if (!item.HasValues || item["img"] == null)
|
||||
continue;
|
||||
cnt++;
|
||||
images.Add(System.Drawing.Bitmap.FromStream(await SearchHelper.GetResponseStreamAsync(item["img"].ToString())));
|
||||
foreach (var item in items.TakeWhile(item => cnt++ < 4).Where(item => item.HasValues && item["img"] != null)) {
|
||||
images.Add(
|
||||
Image.FromStream(await SearchHelper.GetResponseStreamAsync(item["img"].ToString())));
|
||||
}
|
||||
if (items.Count > 4) {
|
||||
await e.Channel.SendMessage("⚠ Found over 4 images. Showing random 4.");
|
||||
@ -187,8 +180,7 @@ namespace NadekoBot.Modules {
|
||||
return;
|
||||
}
|
||||
await e.Channel.SendIsTyping();
|
||||
var headers = new WebHeaderCollection();
|
||||
headers.Add("X-Mashape-Key", NadekoBot.Creds.MashapeKey);
|
||||
var headers = new Dictionary<string, string> { { "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);
|
||||
try {
|
||||
var items = JObject.Parse(res);
|
||||
@ -212,8 +204,7 @@ namespace NadekoBot.Modules {
|
||||
return;
|
||||
}
|
||||
await e.Channel.SendIsTyping();
|
||||
var headers = new WebHeaderCollection();
|
||||
headers.Add("X-Mashape-Key", NadekoBot.Creds.MashapeKey);
|
||||
var headers = new Dictionary<string, string> { { "X-Mashape-Key", NadekoBot.Creds.MashapeKey } };
|
||||
var res = await SearchHelper.GetResponseStringAsync($"https://tagdef.p.mashape.com/one.{Uri.EscapeUriString(arg)}.json", headers);
|
||||
try {
|
||||
var items = JObject.Parse(res);
|
||||
|
@ -18,7 +18,7 @@ namespace NadekoBot.Modules {
|
||||
TrelloConfiguration.Deserializer = serializer;
|
||||
TrelloConfiguration.JsonFactory = new ManateeFactory();
|
||||
TrelloConfiguration.RestClientProvider = new Manatee.Trello.WebApi.WebApiClientProvider();
|
||||
TrelloAuthorization.Default.AppKey = NadekoBot.TrelloAppKey;
|
||||
TrelloAuthorization.Default.AppKey = NadekoBot.Creds.TrelloAppKey;
|
||||
//TrelloAuthorization.Default.UserToken = "[your user token]";
|
||||
|
||||
Discord.Channel bound = null;
|
||||
|
Loading…
Reference in New Issue
Block a user