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,9 +75,14 @@ namespace NadekoBot {
CustomPrefixHandler = m => 0, CustomPrefixHandler = m => 0,
HelpMode = HelpMode.Disabled, HelpMode = HelpMode.Disabled,
ErrorHandler = async (s, e) => { ErrorHandler = async (s, e) => {
if (e.ErrorType != CommandErrorType.BadPermissions) try {
return; if (e.ErrorType != CommandErrorType.BadPermissions)
await e.Channel.SendMessage(e.Exception.Message); return;
if (string.IsNullOrWhiteSpace(e.Exception.Message))
return;
await e.Channel.SendMessage(e.Exception.Message);
}
catch { }
} }
}); });
@ -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,45 +165,48 @@ 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) {
if (e.Server != null || e.User.Id == client.CurrentUser.Id) return; try {
if (PollCommand.ActivePolls.SelectMany(kvp => kvp.Key.Users.Select(u => u.Id)).Contains(e.User.Id)) return; if (e.Server != null || e.User.Id == client.CurrentUser.Id) return;
// just ban this trash AutoModerator if (PollCommand.ActivePolls.SelectMany(kvp => kvp.Key.Users.Select(u => u.Id)).Contains(e.User.Id)) return;
// and cancer christmass spirit // just ban this trash AutoModerator
// and crappy shotaslave // and cancer christmass spirit
if (e.User.Id == 105309315895693312 || // and crappy shotaslave
e.User.Id == 119174277298782216 || if (e.User.Id == 105309315895693312 ||
e.User.Id == 143515953525817344) e.User.Id == 119174277298782216 ||
return; // FU e.User.Id == 143515953525817344)
return; // FU
if (!NadekoBot.creds.DontJoinServers) { if (!NadekoBot.creds.DontJoinServers) {
try { try {
await (await client.GetInvite(e.Message.Text)).Accept(); await (await client.GetInvite(e.Message.Text)).Accept();
await e.Channel.SendMessage("I got in!"); await e.Channel.SendMessage("I got in!");
return;
}
catch {
if (e.User.Id == 109338686889476096) { //carbonitex invite
await e.Channel.SendMessage("Failed to join the server.");
return; return;
} }
catch {
if (e.User.Id == 109338686889476096) { //carbonitex invite
await e.Channel.SendMessage("Failed to join the server.");
return;
}
}
}
if (ForwardMessages && OwnerPrivateChannel != null)
await OwnerPrivateChannel.SendMessage(e.User + ": ```\n" + e.Message.Text + "\n```");
if (!repliedRecently) {
repliedRecently = true;
await e.Channel.SendMessage("**FULL LIST OF COMMANDS**:\n❤ <https://gist.github.com/Kwoth/1ab3a38424f208802b74> ❤\n\n⚠**COMMANDS DO NOT WORK IN PERSONAL MESSAGES**\n\n\n**Bot Creator's server:** <https://discord.gg/0ehQwTK2RBjAxzEY>");
Timer t = new Timer();
t.Interval = 2000;
t.Start();
t.Elapsed += (s, ev) => {
repliedRecently = false;
t.Stop();
t.Dispose();
};
} }
} }
catch { }
if (ForwardMessages && OwnerPrivateChannel != null)
await OwnerPrivateChannel.SendMessage(e.User + ": ```\n" + e.Message.Text + "\n```");
if (!repliedRecently) {
repliedRecently = true;
await e.Channel.SendMessage("**FULL LIST OF COMMANDS**:\n❤ <https://gist.github.com/Kwoth/1ab3a38424f208802b74> ❤\n\n⚠**COMMANDS DO NOT WORK IN PERSONAL MESSAGES**\n\n\n**Bot Creator's server:** <https://discord.gg/0ehQwTK2RBjAxzEY>");
Timer t = new Timer();
t.Interval = 2000;
t.Start();
t.Elapsed += (s, ev) => {
repliedRecently = false;
t.Stop();
t.Dispose();
};
}
} }
} }
} }