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

View File

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

View File

@ -47,7 +47,7 @@ namespace NadekoBot.Classes {
rq = new RestSharp.RestRequest("anime/" + smallObj["id"]);
rq.AddParameter("access_token", token);
return await Task.Run(() => JsonConvert.DeserializeObject<AnimeResult>(cl.Execute(rq).Content));
} catch (Exception) {
} catch {
return null;
}
}
@ -174,7 +174,7 @@ namespace NadekoBot.Classes {
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();
} catch (Exception) {
} catch {
return null;
}
}
@ -190,7 +190,7 @@ namespace NadekoBot.Classes {
//now extract the image from post page
var match = Regex.Match(webpage, "\"(?<url>http://simg4.gelbooru.com//images.*?)\"");
return match.Groups["url"].Value;
} catch (Exception) {
} catch {
return null;
}
}

View File

@ -58,7 +58,7 @@ namespace NadekoBot {
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.Channel.SendFile("dices.png", bitmap.ToStream(ImageFormat.Png));
} catch (Exception) {
} catch {
await e.Send("Please enter a number of dices to roll.");
return;
}

View File

@ -61,6 +61,11 @@ namespace NadekoBot
cgb.CreateCommand("-hgit")
.Description("Help command stylized for github readme")
.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)

View File

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

View File

@ -14,7 +14,7 @@ namespace NadekoBot.Commands {
var data = Classes.DBHandler.Instance.GetAllRows<Classes._DataModels.TypingArticle>();
try {
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`.";
}
}

View File

@ -81,7 +81,7 @@ namespace NadekoBot.Modules {
await usr.RemoveRoles(new Role[] { role });
await e.Send($"Successfully removed role **{role.Name}** from user **{usr.Name}**");
} catch (InvalidOperationException) {
} catch (Exception) {
} catch {
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 e.Send("Unbanned user " + usr.Name + " Id: " + usr.Id);
}
} catch (Exception) { }
} catch { }
});
cgb.CreateCommand(".k").Alias(".kick")
@ -212,7 +212,7 @@ namespace NadekoBot.Modules {
await e.Message.MentionedUsers.First().Kick();
await e.Send("Kicked user " + usr.Name + " Id: " + usr.Id);
}
} catch (Exception) {
} catch {
await e.Send("No sufficient permissions.");
}
});
@ -231,7 +231,7 @@ namespace NadekoBot.Modules {
await u.Edit(isMuted: true);
}
await e.Send("Mute successful");
} catch (Exception) {
} catch {
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 e.Send("Unmute successful");
} catch (Exception) {
} catch {
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 e.Send("Deafen successful");
} catch (Exception) {
} catch {
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 e.Send("Undeafen successful");
} catch (Exception) {
} catch {
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.Send($"Removed channel **{e.GetArg("channel_name")}**.");
}
} catch (Exception) {
} catch {
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.Send($"Created voice channel **{e.GetArg("channel_name")}**.");
}
} catch (Exception) {
} catch {
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.Send($"Removed text channel **{e.GetArg("channel_name")}**.");
}
} catch (Exception) {
} catch {
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.Send($"Added text channel **{e.GetArg("channel_name")}**.");
}
} catch (Exception) {
} catch {
await e.Send("No sufficient permissions.");
}
});
@ -361,7 +361,7 @@ namespace NadekoBot.Modules {
try {
if (e.User.ServerPermissions.ManageChannels)
await e.Channel.Edit(topic: e.GetArg("topic"));
} catch (Exception) { }
} catch { }
});
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**Invite:** " + inv.Url);
break;
} catch (Exception) { continue; }
} catch { continue; }
}
});
/*
@ -272,7 +272,7 @@ namespace NadekoBot.Modules {
try {
await (await client.GetInvite(e.Args[0])).Accept();
await e.Send("I got in!");
} catch (Exception) {
} catch {
await e.Send("Invalid code.");
}
});
@ -352,7 +352,7 @@ namespace NadekoBot.Modules {
var invite = await s.CreateInvite(0);
invites += invite.Url + "\n";
i++;
} catch (Exception) {
} catch {
j++;
continue;
}

View File

@ -79,7 +79,7 @@ namespace NadekoBot.Modules {
.GetResponse()
.GetResponseStream())
.ReadToEnd())["file"].ToString());
} catch (Exception) { }
} catch { }
});
cgb.CreateCommand("~i")
@ -176,7 +176,7 @@ namespace NadekoBot.Modules {
try {
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`");
} catch (Exception) { }
} catch { }
};
} catch {
await e.Channel.SendMessage("💢 Failed retrieving osu signature :\\");

View File

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