fixed 2 crashes - thx to gakiloroth, closes #66 closes #65

This commit is contained in:
Master Kwoth 2016-02-25 22:29:58 +01:00
parent e83c35027d
commit 2ee56c615f
2 changed files with 56 additions and 37 deletions

View File

@ -206,6 +206,7 @@ namespace NadekoBot.Modules {
cgb.CreateCommand("lopl") cgb.CreateCommand("lopl")
.Description("Queues up to 50 songs from a directory.") .Description("Queues up to 50 songs from a directory.")
.Parameter("directory", ParameterType.Unparsed) .Parameter("directory", ParameterType.Unparsed)
.AddCheck(Classes.Permissions.SimpleCheckers.OwnerOnly())
.Do(async e => { .Do(async e => {
var arg = e.GetArg("directory"); var arg = e.GetArg("directory");
if(string.IsNullOrWhiteSpace(e.GetArg("directory"))) if(string.IsNullOrWhiteSpace(e.GetArg("directory")))
@ -234,6 +235,7 @@ namespace NadekoBot.Modules {
cgb.CreateCommand("lo") cgb.CreateCommand("lo")
.Description("Queues a local file by specifying a full path. BOT OWNER ONLY.") .Description("Queues a local file by specifying a full path. BOT OWNER ONLY.")
.Parameter("path", ParameterType.Unparsed) .Parameter("path", ParameterType.Unparsed)
.AddCheck(Classes.Permissions.SimpleCheckers.OwnerOnly())
.Do(async e => { .Do(async e => {
var arg = e.GetArg("path"); var arg = e.GetArg("path");
if (string.IsNullOrWhiteSpace(arg)) if (string.IsNullOrWhiteSpace(arg))

View File

@ -75,10 +75,15 @@ namespace NadekoBot {
CustomPrefixHandler = m => 0, CustomPrefixHandler = m => 0,
HelpMode = HelpMode.Disabled, HelpMode = HelpMode.Disabled,
ErrorHandler = async (s, e) => { ErrorHandler = async (s, e) => {
try {
if (e.ErrorType != CommandErrorType.BadPermissions) if (e.ErrorType != CommandErrorType.BadPermissions)
return; return;
if (string.IsNullOrWhiteSpace(e.Exception.Message))
return;
await e.Channel.SendMessage(e.Exception.Message); await e.Channel.SendMessage(e.Exception.Message);
} }
catch { }
}
}); });
//reply to personal messages and forward if enabled. //reply to personal messages and forward if enabled.
@ -141,9 +146,18 @@ namespace NadekoBot {
if (request != null) { if (request != null) {
if (string.IsNullOrWhiteSpace(request.Content)) if (string.IsNullOrWhiteSpace(request.Content))
e.Cancel = true; e.Cancel = true;
//else
// Console.WriteLine("Sending request.");
request.Content = request.Content.Replace("@everyone", "@everyοne"); request.Content = request.Content.Replace("@everyone", "@everyοne");
} }
}; };
//client.ClientAPI.SentRequest += (s, e) => {
// var request = e.Request as Discord.API.Client.Rest.SendMessageRequest;
// if (request != null) {
// Console.WriteLine("Sent.");
// }
//};
}); });
Console.WriteLine("Exiting..."); Console.WriteLine("Exiting...");
Console.ReadKey(); Console.ReadKey();
@ -151,6 +165,7 @@ namespace NadekoBot {
static bool repliedRecently = false; static bool repliedRecently = false;
private static async void Client_MessageReceived(object sender, MessageEventArgs e) { private static async void Client_MessageReceived(object sender, MessageEventArgs e) {
try {
if (e.Server != null || e.User.Id == client.CurrentUser.Id) return; if (e.Server != null || e.User.Id == client.CurrentUser.Id) return;
if (PollCommand.ActivePolls.SelectMany(kvp => kvp.Key.Users.Select(u => u.Id)).Contains(e.User.Id)) return; if (PollCommand.ActivePolls.SelectMany(kvp => kvp.Key.Users.Select(u => u.Id)).Contains(e.User.Id)) return;
// just ban this trash AutoModerator // just ban this trash AutoModerator
@ -191,6 +206,8 @@ namespace NadekoBot {
}; };
} }
} }
catch { }
}
} }
} }