.b fix, no logner waits 2 secs if no reason is specified

This commit is contained in:
Kwoth 2017-01-04 13:35:54 +01:00
parent f730026744
commit 3a2ce9d352

View File

@ -236,18 +236,22 @@ namespace NadekoBot.Modules.Administration
{ {
msg = "❗No reason provided."; msg = "❗No reason provided.";
} }
if (Context.User.Id != user.Guild.OwnerId && ((IGuildUser)Context.User).GetRoles().Select(r=>r.Position).Max() >= ((IGuildUser)Context.User).GetRoles().Select(r => r.Position).Max()) if (Context.User.Id != user.Guild.OwnerId && (user.GetRoles().Select(r => r.Position).Max() >= ((IGuildUser)Context.User).GetRoles().Select(r => r.Position).Max()))
{ {
await Context.Channel.SendErrorAsync("⚠️ You can't use this command on users with a role higher or equal to yours in the role hierarchy.").ConfigureAwait(false); await Context.Channel.SendErrorAsync("⚠️ You can't use this command on users with a role higher or equal to yours in the role hierarchy.").ConfigureAwait(false);
return; return;
} }
if (!string.IsNullOrWhiteSpace(msg))
{
try try
{ {
await (await user.CreateDMChannelAsync()).SendErrorAsync($"⛔️ **You have been BANNED from `{Context.Guild.Name}` server.**\n" + await (await user.CreateDMChannelAsync()).SendErrorAsync($"⛔️ **You have been BANNED from `{Context.Guild.Name}` server.**\n" +
$"⚖ *Reason:* {msg}").ConfigureAwait(false); $"⚖ *Reason:* {msg}").ConfigureAwait(false);
await Task.Delay(2000).ConfigureAwait(false); await Task.Delay(2000).ConfigureAwait(false);
} }
catch { } catch { }
}
try try
{ {
await Context.Guild.AddBanAsync(user, 7).ConfigureAwait(false); await Context.Guild.AddBanAsync(user, 7).ConfigureAwait(false);
@ -275,6 +279,9 @@ namespace NadekoBot.Modules.Administration
await Context.Channel.SendErrorAsync("⚠️ You can't use this command on users with a role higher or equal to yours in the role hierarchy."); await Context.Channel.SendErrorAsync("⚠️ You can't use this command on users with a role higher or equal to yours in the role hierarchy.");
return; return;
} }
if (!string.IsNullOrWhiteSpace(msg))
{
try try
{ {
await user.SendErrorAsync($"☣ **You have been SOFT-BANNED from `{Context.Guild.Name}` server.**\n" + await user.SendErrorAsync($"☣ **You have been SOFT-BANNED from `{Context.Guild.Name}` server.**\n" +
@ -282,6 +289,8 @@ namespace NadekoBot.Modules.Administration
await Task.Delay(2000).ConfigureAwait(false); await Task.Delay(2000).ConfigureAwait(false);
} }
catch { } catch { }
}
try try
{ {
await Context.Guild.AddBanAsync(user, 7).ConfigureAwait(false); await Context.Guild.AddBanAsync(user, 7).ConfigureAwait(false);