.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

@ -35,7 +35,7 @@ namespace NadekoBot.Modules.Administration
NadekoBot.CommandHandler.CommandExecuted += DelMsgOnCmd_Handler;
DeleteMessagesOnCommand = new ConcurrentHashSet<ulong>(NadekoBot.AllGuildConfigs.Where(g => g.DeleteMessageOnCommand).Select(g => g.GuildId));
}
private static async Task DelMsgOnCmd_Handler(SocketUserMessage msg, CommandInfo cmd)
@ -202,7 +202,7 @@ namespace NadekoBot.Modules.Administration
return;
}
var roleName = args[0].ToUpperInvariant();
var role = Context.Guild.Roles.Where(r=>r.Name.ToUpperInvariant() == roleName).FirstOrDefault();
var role = Context.Guild.Roles.Where(r => r.Name.ToUpperInvariant() == roleName).FirstOrDefault();
if (role == null)
{
@ -217,7 +217,7 @@ namespace NadekoBot.Modules.Administration
var red = Convert.ToByte(rgb ? int.Parse(arg1) : Convert.ToInt32(arg1.Substring(0, 2), 16));
var green = Convert.ToByte(rgb ? int.Parse(args[2]) : Convert.ToInt32(arg1.Substring(2, 2), 16));
var blue = Convert.ToByte(rgb ? int.Parse(args[3]) : Convert.ToInt32(arg1.Substring(4, 2), 16));
await role.ModifyAsync(r => r.Color = new Color(red, green, blue)).ConfigureAwait(false);
await Context.Channel.SendConfirmAsync($"☑️ Role **{role.Name}'s** color has been changed.").ConfigureAwait(false);
}
@ -236,18 +236,22 @@ namespace NadekoBot.Modules.Administration
{
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);
return;
}
try
if (!string.IsNullOrWhiteSpace(msg))
{
await (await user.CreateDMChannelAsync()).SendErrorAsync($"⛔️ **You have been BANNED from `{Context.Guild.Name}` server.**\n" +
$"⚖ *Reason:* {msg}").ConfigureAwait(false);
await Task.Delay(2000).ConfigureAwait(false);
try
{
await (await user.CreateDMChannelAsync()).SendErrorAsync($"⛔️ **You have been BANNED from `{Context.Guild.Name}` server.**\n" +
$"⚖ *Reason:* {msg}").ConfigureAwait(false);
await Task.Delay(2000).ConfigureAwait(false);
}
catch { }
}
catch { }
try
{
await Context.Guild.AddBanAsync(user, 7).ConfigureAwait(false);
@ -275,13 +279,18 @@ 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.");
return;
}
try
if (!string.IsNullOrWhiteSpace(msg))
{
await user.SendErrorAsync($"☣ **You have been SOFT-BANNED from `{Context.Guild.Name}` server.**\n" +
$"⚖ *Reason:* {msg}").ConfigureAwait(false);
await Task.Delay(2000).ConfigureAwait(false);
try
{
await user.SendErrorAsync($"☣ **You have been SOFT-BANNED from `{Context.Guild.Name}` server.**\n" +
$"⚖ *Reason:* {msg}").ConfigureAwait(false);
await Task.Delay(2000).ConfigureAwait(false);
}
catch { }
}
catch { }
try
{
await Context.Guild.AddBanAsync(user, 7).ConfigureAwait(false);
@ -439,7 +448,7 @@ namespace NadekoBot.Modules.Administration
public async Task Prune()
{
var user = await Context.Guild.GetCurrentUserAsync().ConfigureAwait(false);
var enumerable = (await Context.Channel.GetMessagesAsync().Flatten()).AsEnumerable();
enumerable = enumerable.Where(x => x.Author.Id == user.Id);
await Context.Channel.DeleteMessagesAsync(enumerable).ConfigureAwait(false);
@ -511,7 +520,7 @@ title, title).ConfigureAwait(false);
foreach (var role in roles)
{
send += $"\n**{role.Name}**\n";
send += string.Join(", ", (await Context.Guild.GetUsersAsync()).Where(u => u.GetRoles().Contains(role)).Distinct().Select(u=>u.Mention));
send += string.Join(", ", (await Context.Guild.GetUsersAsync()).Where(u => u.GetRoles().Contains(role)).Distinct().Select(u => u.Mention));
}
while (send.Length > 2000)
@ -536,7 +545,7 @@ title, title).ConfigureAwait(false);
donatorsOrdered = uow.Donators.GetDonatorsOrdered();
}
await Context.Channel.SendConfirmAsync("Thanks to the people listed below for making this project happen!", string.Join("⭐", donatorsOrdered.Select(d => d.Name))).ConfigureAwait(false);
nadekoSupportServer = nadekoSupportServer ?? NadekoBot.Client.GetGuild(117523346618318850);
if (nadekoSupportServer == null)