removed (Exception) from catches, added -readme/-guide command

This commit is contained in:
Master Kwoth 2016-02-14 16:48:46 +01:00
parent ba34a84391
commit 23aee061cd
11 changed files with 34 additions and 29 deletions

View File

@ -192,7 +192,7 @@ namespace NadekoBot.Classes.Music {
try { try {
p.CancelOutputRead(); p.CancelOutputRead();
p.Close(); p.Close();
} catch (Exception) { } } catch { }
Console.WriteLine("Buffering canceled, stream is completed."); Console.WriteLine("Buffering canceled, stream is completed.");
return; return;
} }
@ -221,7 +221,7 @@ namespace NadekoBot.Classes.Music {
try { try {
p.CancelOutputRead(); p.CancelOutputRead();
p.Close(); p.Close();
} catch (Exception) { } } catch { }
Console.WriteLine($"Didn't read anything from the stream for {attempt} attempts. {buffer.Length/1.MB()}MB length"); Console.WriteLine($"Didn't read anything from the stream for {attempt} attempts. {buffer.Length/1.MB()}MB length");
return; return;

View File

@ -89,7 +89,7 @@ namespace NadekoBot
ConnectedServers = connectedServers, ConnectedServers = connectedServers,
DateAdded = DateTime.Now DateAdded = DateTime.Now
}); });
} catch (Exception) { } catch {
Console.WriteLine("DB Exception in stats collecting."); Console.WriteLine("DB Exception in stats collecting.");
break; break;
} }
@ -110,7 +110,7 @@ namespace NadekoBot
CommandName = e.Command.Text, CommandName = e.Command.Text,
DateAdded = DateTime.Now DateAdded = DateTime.Now
}); });
} catch (Exception) { } catch {
Console.WriteLine("Parse error in ran command."); Console.WriteLine("Parse error in ran command.");
} }
} }

View File

@ -47,7 +47,7 @@ namespace NadekoBot.Classes {
rq = new RestSharp.RestRequest("anime/" + smallObj["id"]); rq = new RestSharp.RestRequest("anime/" + smallObj["id"]);
rq.AddParameter("access_token", token); rq.AddParameter("access_token", token);
return await Task.Run(() => JsonConvert.DeserializeObject<AnimeResult>(cl.Execute(rq).Content)); return await Task.Run(() => JsonConvert.DeserializeObject<AnimeResult>(cl.Execute(rq).Content));
} catch (Exception) { } catch {
return null; return null;
} }
} }
@ -174,7 +174,7 @@ namespace NadekoBot.Classes {
var matches = Regex.Matches(webpage, "data-large-file-url=\"(?<id>.*?)\""); var matches = Regex.Matches(webpage, "data-large-file-url=\"(?<id>.*?)\"");
return await $"http://danbooru.donmai.us{ matches[rng.Next(0, matches.Count)].Groups["id"].Value }".ShortenUrl(); return await $"http://danbooru.donmai.us{ matches[rng.Next(0, matches.Count)].Groups["id"].Value }".ShortenUrl();
} catch (Exception) { } catch {
return null; return null;
} }
} }
@ -190,7 +190,7 @@ namespace NadekoBot.Classes {
//now extract the image from post page //now extract the image from post page
var match = Regex.Match(webpage, "\"(?<url>http://simg4.gelbooru.com//images.*?)\""); var match = Regex.Match(webpage, "\"(?<url>http://simg4.gelbooru.com//images.*?)\"");
return match.Groups["url"].Value; return match.Groups["url"].Value;
} catch (Exception) { } catch {
return null; return null;
} }
} }

View File

@ -58,7 +58,7 @@ namespace NadekoBot {
Bitmap bitmap = dices.Merge(); Bitmap bitmap = dices.Merge();
await e.Send(values.Count + " Dies rolled. Total: **" + values.Sum() + "** Average: **" + (values.Sum() / (1.0f * values.Count)).ToString("N2") + "**"); await e.Send(values.Count + " Dies rolled. Total: **" + values.Sum() + "** Average: **" + (values.Sum() / (1.0f * values.Count)).ToString("N2") + "**");
await e.Channel.SendFile("dices.png", bitmap.ToStream(ImageFormat.Png)); await e.Channel.SendFile("dices.png", bitmap.ToStream(ImageFormat.Png));
} catch (Exception) { } catch {
await e.Send("Please enter a number of dices to roll."); await e.Send("Please enter a number of dices to roll.");
return; return;
} }

View File

@ -61,6 +61,11 @@ namespace NadekoBot
cgb.CreateCommand("-hgit") cgb.CreateCommand("-hgit")
.Description("Help command stylized for github readme") .Description("Help command stylized for github readme")
.Do(DoGitFunc()); .Do(DoGitFunc());
cgb.CreateCommand("-readme")
.Alias("-guide")
.Description("Sends a readme and a guide links to the channel.")
.Do(async e =>
await e.Send("**FULL README**: <https://github.com/Kwoth/NadekoBot/blob/master/readme.md>\n\n**GUIDE ONLY**: <https://github.com/Kwoth/NadekoBot/blob/master/ComprehensiveGuide.md>"));
} }
private string PrintCommandHelp(Command com) private string PrintCommandHelp(Command com)

View File

@ -52,7 +52,7 @@ namespace NadekoBot.Commands {
try { try {
SaveRequest(e, str); SaveRequest(e, str);
} catch (Exception) { } catch {
await e.Send("Something went wrong."); await e.Send("Something went wrong.");
return; return;
} }

View File

@ -14,7 +14,7 @@ namespace NadekoBot.Commands {
var data = Classes.DBHandler.Instance.GetAllRows<Classes._DataModels.TypingArticle>(); var data = Classes.DBHandler.Instance.GetAllRows<Classes._DataModels.TypingArticle>();
try { try {
return data.ToList()[new Random().Next(0, data.Count())].Text; return data.ToList()[new Random().Next(0, data.Count())].Text;
} catch (Exception) { } catch {
return "Failed retrieving data from parse. Owner didn't add any articles to type using `typeadd`."; return "Failed retrieving data from parse. Owner didn't add any articles to type using `typeadd`.";
} }
} }

View File

@ -81,7 +81,7 @@ namespace NadekoBot.Modules {
await usr.RemoveRoles(new Role[] { role }); await usr.RemoveRoles(new Role[] { role });
await e.Send($"Successfully removed role **{role.Name}** from user **{usr.Name}**"); await e.Send($"Successfully removed role **{role.Name}** from user **{usr.Name}**");
} catch (InvalidOperationException) { } catch (InvalidOperationException) {
} catch (Exception) { } catch {
await e.Send("Failed to remove roles. Most likely reason: Insufficient permissions."); await e.Send("Failed to remove roles. Most likely reason: Insufficient permissions.");
} }
}); });
@ -199,7 +199,7 @@ namespace NadekoBot.Modules {
await usr.Server.Unban(usr); await usr.Server.Unban(usr);
await e.Send("Unbanned user " + usr.Name + " Id: " + usr.Id); await e.Send("Unbanned user " + usr.Name + " Id: " + usr.Id);
} }
} catch (Exception) { } } catch { }
}); });
cgb.CreateCommand(".k").Alias(".kick") cgb.CreateCommand(".k").Alias(".kick")
@ -212,7 +212,7 @@ namespace NadekoBot.Modules {
await e.Message.MentionedUsers.First().Kick(); await e.Message.MentionedUsers.First().Kick();
await e.Send("Kicked user " + usr.Name + " Id: " + usr.Id); await e.Send("Kicked user " + usr.Name + " Id: " + usr.Id);
} }
} catch (Exception) { } catch {
await e.Send("No sufficient permissions."); await e.Send("No sufficient permissions.");
} }
}); });
@ -231,7 +231,7 @@ namespace NadekoBot.Modules {
await u.Edit(isMuted: true); await u.Edit(isMuted: true);
} }
await e.Send("Mute successful"); await e.Send("Mute successful");
} catch (Exception) { } catch {
await e.Send("I do not have permission to do that most likely."); await e.Send("I do not have permission to do that most likely.");
} }
}); });
@ -251,7 +251,7 @@ namespace NadekoBot.Modules {
await u.Edit(isMuted: false); await u.Edit(isMuted: false);
} }
await e.Send("Unmute successful"); await e.Send("Unmute successful");
} catch (Exception) { } catch {
await e.Send("I do not have permission to do that most likely."); await e.Send("I do not have permission to do that most likely.");
} }
}); });
@ -272,7 +272,7 @@ namespace NadekoBot.Modules {
await u.Edit(isDeafened: true); await u.Edit(isDeafened: true);
} }
await e.Send("Deafen successful"); await e.Send("Deafen successful");
} catch (Exception) { } catch {
await e.Send("I do not have permission to do that most likely."); await e.Send("I do not have permission to do that most likely.");
} }
}); });
@ -293,7 +293,7 @@ namespace NadekoBot.Modules {
await u.Edit(isDeafened: false); await u.Edit(isDeafened: false);
} }
await e.Send("Undeafen successful"); await e.Send("Undeafen successful");
} catch (Exception) { } catch {
await e.Send("I do not have permission to do that most likely."); await e.Send("I do not have permission to do that most likely.");
} }
}); });
@ -307,7 +307,7 @@ namespace NadekoBot.Modules {
await e.Server.FindChannels(e.GetArg("channel_name"), ChannelType.Voice).FirstOrDefault()?.Delete(); await e.Server.FindChannels(e.GetArg("channel_name"), ChannelType.Voice).FirstOrDefault()?.Delete();
await e.Send($"Removed channel **{e.GetArg("channel_name")}**."); await e.Send($"Removed channel **{e.GetArg("channel_name")}**.");
} }
} catch (Exception) { } catch {
await e.Send("No sufficient permissions."); await e.Send("No sufficient permissions.");
} }
}); });
@ -321,7 +321,7 @@ namespace NadekoBot.Modules {
await e.Server.CreateChannel(e.GetArg("channel_name"), ChannelType.Voice); await e.Server.CreateChannel(e.GetArg("channel_name"), ChannelType.Voice);
await e.Send($"Created voice channel **{e.GetArg("channel_name")}**."); await e.Send($"Created voice channel **{e.GetArg("channel_name")}**.");
} }
} catch (Exception) { } catch {
await e.Send("No sufficient permissions."); await e.Send("No sufficient permissions.");
} }
}); });
@ -335,7 +335,7 @@ namespace NadekoBot.Modules {
await e.Server.FindChannels(e.GetArg("channel_name"), ChannelType.Text).FirstOrDefault()?.Delete(); await e.Server.FindChannels(e.GetArg("channel_name"), ChannelType.Text).FirstOrDefault()?.Delete();
await e.Send($"Removed text channel **{e.GetArg("channel_name")}**."); await e.Send($"Removed text channel **{e.GetArg("channel_name")}**.");
} }
} catch (Exception) { } catch {
await e.Send("No sufficient permissions."); await e.Send("No sufficient permissions.");
} }
}); });
@ -349,7 +349,7 @@ namespace NadekoBot.Modules {
await e.Server.CreateChannel(e.GetArg("channel_name"), ChannelType.Text); await e.Server.CreateChannel(e.GetArg("channel_name"), ChannelType.Text);
await e.Send($"Added text channel **{e.GetArg("channel_name")}**."); await e.Send($"Added text channel **{e.GetArg("channel_name")}**.");
} }
} catch (Exception) { } catch {
await e.Send("No sufficient permissions."); await e.Send("No sufficient permissions.");
} }
}); });
@ -361,7 +361,7 @@ namespace NadekoBot.Modules {
try { try {
if (e.User.ServerPermissions.ManageChannels) if (e.User.ServerPermissions.ManageChannels)
await e.Channel.Edit(topic: e.GetArg("topic")); await e.Channel.Edit(topic: e.GetArg("topic"));
} catch (Exception) { } } catch { }
}); });
cgb.CreateCommand(".uid").Alias(".userid") cgb.CreateCommand(".uid").Alias(".userid")

View File

@ -101,7 +101,7 @@ namespace NadekoBot.Modules {
"\n**Online Members:** " + server.Users.Where(u => u.Status == UserStatus.Online).Count() + "\n**Online Members:** " + server.Users.Where(u => u.Status == UserStatus.Online).Count() +
"\n**Invite:** " + inv.Url); "\n**Invite:** " + inv.Url);
break; break;
} catch (Exception) { continue; } } catch { continue; }
} }
}); });
/* /*
@ -272,7 +272,7 @@ namespace NadekoBot.Modules {
try { try {
await (await client.GetInvite(e.Args[0])).Accept(); await (await client.GetInvite(e.Args[0])).Accept();
await e.Send("I got in!"); await e.Send("I got in!");
} catch (Exception) { } catch {
await e.Send("Invalid code."); await e.Send("Invalid code.");
} }
}); });
@ -352,7 +352,7 @@ namespace NadekoBot.Modules {
var invite = await s.CreateInvite(0); var invite = await s.CreateInvite(0);
invites += invite.Url + "\n"; invites += invite.Url + "\n";
i++; i++;
} catch (Exception) { } catch {
j++; j++;
continue; continue;
} }

View File

@ -79,7 +79,7 @@ namespace NadekoBot.Modules {
.GetResponse() .GetResponse()
.GetResponseStream()) .GetResponseStream())
.ReadToEnd())["file"].ToString()); .ReadToEnd())["file"].ToString());
} catch (Exception) { } } catch { }
}); });
cgb.CreateCommand("~i") cgb.CreateCommand("~i")
@ -176,7 +176,7 @@ namespace NadekoBot.Modules {
try { try {
await e.Channel.SendFile($"{e.GetArg("usr")}.png", new MemoryStream(cle.Result)); await e.Channel.SendFile($"{e.GetArg("usr")}.png", new MemoryStream(cle.Result));
await e.Send($"`Profile Link:`https://osu.ppy.sh/u/{Uri.EscapeDataString(e.GetArg("usr"))}\n`Image provided by https://lemmmy.pw/osusig`"); await e.Send($"`Profile Link:`https://osu.ppy.sh/u/{Uri.EscapeDataString(e.GetArg("usr"))}\n`Image provided by https://lemmmy.pw/osusig`");
} catch (Exception) { } } catch { }
}; };
} catch { } catch {
await e.Channel.SendMessage("💢 Failed retrieving osu signature :\\"); await e.Channel.SendMessage("💢 Failed retrieving osu signature :\\");

View File

@ -110,7 +110,7 @@ namespace NadekoBot {
try { try {
OwnerPrivateChannel = await client.CreatePrivateChannel(OwnerID); OwnerPrivateChannel = await client.CreatePrivateChannel(OwnerID);
} catch (Exception) { } catch {
Console.WriteLine("Failed creating private channel with the owner"); Console.WriteLine("Failed creating private channel with the owner");
} }
@ -146,7 +146,7 @@ namespace NadekoBot {
await (await client.GetInvite(e.Message.Text)).Accept(); await (await client.GetInvite(e.Message.Text)).Accept();
await e.Send("I got in!"); await e.Send("I got in!");
return; return;
} catch (Exception) { } catch {
if (e.User.Id == 109338686889476096) { //carbonitex invite if (e.User.Id == 109338686889476096) { //carbonitex invite
await e.Send("Failed to join the server."); await e.Send("Failed to join the server.");
return; return;