Huge prettification pass

This commit is contained in:
Kwoth 2016-12-11 17:18:25 +01:00
parent 72ec76e73d
commit 05f91b08a0
21 changed files with 258 additions and 231 deletions

View File

@ -124,7 +124,7 @@ namespace NadekoBot.Modules.Administration
await uow.CompleteAsync(); await uow.CompleteAsync();
} }
await channel.SendMessageAsync($"{imsg.Author.Mention} 🆗 **Permissions for this server are reset.**"); await channel.SendConfirmAsync($"{imsg.Author.Mention} 🆗 **Permissions for this server are reset.**");
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -142,9 +142,9 @@ namespace NadekoBot.Modules.Administration
await uow.CompleteAsync(); await uow.CompleteAsync();
} }
if (enabled) if (enabled)
await channel.SendMessageAsync("✅ **Now automatically deleting successful command invokations.**").ConfigureAwait(false); await channel.SendConfirmAsync("✅ **Now automatically deleting successful command invokations.**").ConfigureAwait(false);
else else
await channel.SendMessageAsync("❗**Stopped automatic deletion of successful command invokations.**").ConfigureAwait(false); await channel.SendConfirmAsync("❗**Stopped automatic deletion of successful command invokations.**").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -156,11 +156,11 @@ namespace NadekoBot.Modules.Administration
try try
{ {
await usr.AddRolesAsync(role).ConfigureAwait(false); await usr.AddRolesAsync(role).ConfigureAwait(false);
await channel.SendMessageAsync($" Successfully added role **{role.Name}** to user **{usr.Username}**").ConfigureAwait(false); await channel.SendConfirmAsync($" Successfully added role **{role.Name}** to user **{usr.Username}**").ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
await channel.SendMessageAsync("⚠️ Failed to add role. **Bot has insufficient permissions.**\n").ConfigureAwait(false); await channel.SendErrorAsync("⚠️ Failed to add role. **Bot has insufficient permissions.**\n").ConfigureAwait(false);
Console.WriteLine(ex.ToString()); Console.WriteLine(ex.ToString());
} }
} }
@ -174,11 +174,11 @@ namespace NadekoBot.Modules.Administration
try try
{ {
await usr.RemoveRolesAsync(role).ConfigureAwait(false); await usr.RemoveRolesAsync(role).ConfigureAwait(false);
await channel.SendMessageAsync($" Successfully removed role **{role.Name}** from user **{usr.Username}**").ConfigureAwait(false); await channel.SendConfirmAsync($" Successfully removed role **{role.Name}** from user **{usr.Username}**").ConfigureAwait(false);
} }
catch catch
{ {
await channel.SendMessageAsync("⚠️ Failed to remove role. Most likely reason: **Insufficient permissions.**").ConfigureAwait(false); await channel.SendErrorAsync("⚠️ Failed to remove role. Most likely reason: **Insufficient permissions.**").ConfigureAwait(false);
} }
} }
@ -192,15 +192,15 @@ namespace NadekoBot.Modules.Administration
{ {
if (roleToEdit.Position > (await channel.Guild.GetCurrentUserAsync().ConfigureAwait(false)).Roles.Max(r => r.Position)) if (roleToEdit.Position > (await channel.Guild.GetCurrentUserAsync().ConfigureAwait(false)).Roles.Max(r => r.Position))
{ {
await channel.SendMessageAsync("🚫 You can't edit roles higher than your highest role.").ConfigureAwait(false); await channel.SendErrorAsync("🚫 You can't edit roles higher than your highest role.").ConfigureAwait(false);
return; return;
} }
await roleToEdit.ModifyAsync(g => g.Name = newname).ConfigureAwait(false); await roleToEdit.ModifyAsync(g => g.Name = newname).ConfigureAwait(false);
await channel.SendMessageAsync("✅ Role renamed.").ConfigureAwait(false); await channel.SendConfirmAsync("✅ Role renamed.").ConfigureAwait(false);
} }
catch (Exception) catch (Exception)
{ {
await channel.SendMessageAsync("⚠️ Failed to rename role. Probably **insufficient permissions.**").ConfigureAwait(false); await channel.SendErrorAsync("⚠️ Failed to rename role. Probably **insufficient permissions.**").ConfigureAwait(false);
} }
} }
@ -214,11 +214,11 @@ namespace NadekoBot.Modules.Administration
try try
{ {
await user.RemoveRolesAsync(user.Roles).ConfigureAwait(false); await user.RemoveRolesAsync(user.Roles).ConfigureAwait(false);
await channel.SendMessageAsync($"🗑 Successfully removed **all** roles from user **{user.Username}**").ConfigureAwait(false); await channel.SendConfirmAsync($"🗑 Successfully removed **all** roles from user **{user.Username}**").ConfigureAwait(false);
} }
catch catch
{ {
await channel.SendMessageAsync("⚠️ Failed to remove roles. Most likely reason: **Insufficient permissions.**").ConfigureAwait(false); await channel.SendErrorAsync("⚠️ Failed to remove roles. Most likely reason: **Insufficient permissions.**").ConfigureAwait(false);
} }
} }
@ -235,11 +235,11 @@ namespace NadekoBot.Modules.Administration
try try
{ {
var r = await channel.Guild.CreateRoleAsync(roleName).ConfigureAwait(false); var r = await channel.Guild.CreateRoleAsync(roleName).ConfigureAwait(false);
await channel.SendMessageAsync($"✅ Successfully created role **{r.Name}**.").ConfigureAwait(false); await channel.SendConfirmAsync($"✅ Successfully created role **{r.Name}**.").ConfigureAwait(false);
} }
catch (Exception) catch (Exception)
{ {
await channel.SendMessageAsync("⚠️ Unspecified error.").ConfigureAwait(false); await channel.SendErrorAsync("⚠️ Unspecified error.").ConfigureAwait(false);
} }
} }
@ -252,7 +252,7 @@ namespace NadekoBot.Modules.Administration
if (args.Count() != 2 && args.Count() != 4) if (args.Count() != 2 && args.Count() != 4)
{ {
await channel.SendMessageAsync("❌ The parameters specified are **invalid.**").ConfigureAwait(false); await channel.SendErrorAsync("❌ The parameters specified are **invalid.**").ConfigureAwait(false);
return; return;
} }
var roleName = args[0].ToUpperInvariant(); var roleName = args[0].ToUpperInvariant();
@ -260,7 +260,7 @@ namespace NadekoBot.Modules.Administration
if (role == null) if (role == null)
{ {
await channel.SendMessageAsync("🚫 That role **does not exist.**").ConfigureAwait(false); await channel.SendErrorAsync("🚫 That role **does not exist.**").ConfigureAwait(false);
return; return;
} }
try try
@ -273,11 +273,11 @@ namespace NadekoBot.Modules.Administration
var blue = Convert.ToByte(rgb ? int.Parse(args[3]) : Convert.ToInt32(arg1.Substring(4, 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 Discord.Color(red, green, blue).RawValue).ConfigureAwait(false); await role.ModifyAsync(r => r.Color = new Discord.Color(red, green, blue).RawValue).ConfigureAwait(false);
await channel.SendMessageAsync($"☑️ Role **{role.Name}'s** color has been changed.").ConfigureAwait(false); await channel.SendConfirmAsync($"☑️ Role **{role.Name}'s** color has been changed.").ConfigureAwait(false);
} }
catch (Exception) catch (Exception)
{ {
await channel.SendMessageAsync("⚠️ Error occured, most likely **invalid parameters** or **insufficient permissions.**").ConfigureAwait(false); await channel.SendErrorAsync("⚠️ Error occured, most likely **invalid parameters** or **insufficient permissions.**").ConfigureAwait(false);
} }
} }
@ -293,12 +293,12 @@ namespace NadekoBot.Modules.Administration
} }
if (umsg.Author.Id != user.Guild.OwnerId && user.Roles.Select(r=>r.Position).Max() >= ((IGuildUser)umsg.Author).Roles.Select(r => r.Position).Max()) if (umsg.Author.Id != user.Guild.OwnerId && user.Roles.Select(r=>r.Position).Max() >= ((IGuildUser)umsg.Author).Roles.Select(r => r.Position).Max())
{ {
await channel.SendMessageAsync("⚠️ You can't use this command on users with a role higher or equal to yours in the role hierarchy."); await channel.SendErrorAsync("⚠️ You can't use this command on users with a role higher or equal to yours in the role hierarchy.");
return; return;
} }
try try
{ {
await (await user.CreateDMChannelAsync()).SendMessageAsync($"⛔️ **You have been BANNED from `{channel.Guild.Name}` server.**\n" + await (await user.CreateDMChannelAsync()).SendErrorAsync($"⛔️ **You have been BANNED from `{channel.Guild.Name}` server.**\n" +
$"⚖ *Reason:* {msg}").ConfigureAwait(false); $"⚖ *Reason:* {msg}").ConfigureAwait(false);
await Task.Delay(2000).ConfigureAwait(false); await Task.Delay(2000).ConfigureAwait(false);
} }
@ -307,11 +307,11 @@ namespace NadekoBot.Modules.Administration
{ {
await channel.Guild.AddBanAsync(user, 7).ConfigureAwait(false); await channel.Guild.AddBanAsync(user, 7).ConfigureAwait(false);
await channel.SendMessageAsync("⛔️ **Banned** user **" + user.Username + "** ID: `" + user.Id + "`").ConfigureAwait(false); await channel.SendConfirmAsync("⛔️ **Banned** user **" + user.Username + "** ID: `" + user.Id + "`").ConfigureAwait(false);
} }
catch catch
{ {
await channel.SendMessageAsync("⚠️ **Error.** Most likely I don't have sufficient permissions.").ConfigureAwait(false); await channel.SendErrorAsync("⚠️ **Error.** Most likely I don't have sufficient permissions.").ConfigureAwait(false);
} }
} }
@ -328,12 +328,12 @@ namespace NadekoBot.Modules.Administration
} }
if (umsg.Author.Id != user.Guild.OwnerId && user.Roles.Select(r => r.Position).Max() >= ((IGuildUser)umsg.Author).Roles.Select(r => r.Position).Max()) if (umsg.Author.Id != user.Guild.OwnerId && user.Roles.Select(r => r.Position).Max() >= ((IGuildUser)umsg.Author).Roles.Select(r => r.Position).Max())
{ {
await channel.SendMessageAsync("⚠️ You can't use this command on users with a role higher or equal to yours in the role hierarchy."); await channel.SendErrorAsync("⚠️ You can't use this command on users with a role higher or equal to yours in the role hierarchy.");
return; return;
} }
try try
{ {
await user.SendMessageAsync($"☣ **You have been SOFT-BANNED from `{channel.Guild.Name}` server.**\n" + await user.SendErrorAsync($"☣ **You have been SOFT-BANNED from `{channel.Guild.Name}` server.**\n" +
$"⚖ *Reason:* {msg}").ConfigureAwait(false); $"⚖ *Reason:* {msg}").ConfigureAwait(false);
await Task.Delay(2000).ConfigureAwait(false); await Task.Delay(2000).ConfigureAwait(false);
} }
@ -344,11 +344,11 @@ namespace NadekoBot.Modules.Administration
try { await channel.Guild.RemoveBanAsync(user).ConfigureAwait(false); } try { await channel.Guild.RemoveBanAsync(user).ConfigureAwait(false); }
catch { await channel.Guild.RemoveBanAsync(user).ConfigureAwait(false); } catch { await channel.Guild.RemoveBanAsync(user).ConfigureAwait(false); }
await channel.SendMessageAsync("☣ **Soft-Banned** user **" + user.Username + "** ID: `" + user.Id + "`").ConfigureAwait(false); await channel.SendConfirmAsync("☣ **Soft-Banned** user **" + user.Username + "** ID: `" + user.Id + "`").ConfigureAwait(false);
} }
catch catch
{ {
await channel.SendMessageAsync("⚠️ Error. Most likely I don't have sufficient permissions.").ConfigureAwait(false); await channel.SendErrorAsync("⚠️ Error. Most likely I don't have sufficient permissions.").ConfigureAwait(false);
} }
} }
@ -361,20 +361,20 @@ namespace NadekoBot.Modules.Administration
if (user == null) if (user == null)
{ {
await channel.SendMessageAsync("❗User not found.").ConfigureAwait(false); await channel.SendErrorAsync("❗User not found.").ConfigureAwait(false);
return; return;
} }
if (umsg.Author.Id != user.Guild.OwnerId && user.Roles.Select(r => r.Position).Max() >= ((IGuildUser)umsg.Author).Roles.Select(r => r.Position).Max()) if (umsg.Author.Id != user.Guild.OwnerId && user.Roles.Select(r => r.Position).Max() >= ((IGuildUser)umsg.Author).Roles.Select(r => r.Position).Max())
{ {
await channel.SendMessageAsync("⚠️ You can't use this command on users with a role higher or equal to yours in the role hierarchy."); await 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)) if (!string.IsNullOrWhiteSpace(msg))
{ {
try try
{ {
await user.SendMessageAsync($"‼️**You have been KICKED from `{channel.Guild.Name}` server.**\n" + await user.SendErrorAsync($"‼️**You have been KICKED from `{channel.Guild.Name}` server.**\n" +
$"⚖ *Reason:* {msg}").ConfigureAwait(false); $"⚖ *Reason:* {msg}").ConfigureAwait(false);
await Task.Delay(2000).ConfigureAwait(false); await Task.Delay(2000).ConfigureAwait(false);
} }
@ -383,11 +383,11 @@ namespace NadekoBot.Modules.Administration
try try
{ {
await user.KickAsync().ConfigureAwait(false); await user.KickAsync().ConfigureAwait(false);
await channel.SendMessageAsync("‼️**Kicked** user **" + user.Username + "** ID: `" + user.Id + "`").ConfigureAwait(false); await channel.SendConfirmAsync("‼️**Kicked** user **" + user.Username + "** ID: `" + user.Id + "`").ConfigureAwait(false);
} }
catch catch
{ {
await channel.SendMessageAsync("⚠️ Error. Most likely I don't have sufficient permissions.").ConfigureAwait(false); await channel.SendErrorAsync("⚠️ Error. Most likely I don't have sufficient permissions.").ConfigureAwait(false);
} }
} }
@ -409,7 +409,7 @@ namespace NadekoBot.Modules.Administration
GuildMuteRoles.AddOrUpdate(channel.Guild.Id, name, (id, old) => name); GuildMuteRoles.AddOrUpdate(channel.Guild.Id, name, (id, old) => name);
await uow.CompleteAsync().ConfigureAwait(false); await uow.CompleteAsync().ConfigureAwait(false);
} }
await channel.SendMessageAsync("☑️ **New mute role set.**").ConfigureAwait(false); await channel.SendConfirmAsync("☑️ **New mute role set.**").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -431,11 +431,11 @@ namespace NadekoBot.Modules.Administration
{ {
await user.ModifyAsync(usr => usr.Mute = true).ConfigureAwait(false); await user.ModifyAsync(usr => usr.Mute = true).ConfigureAwait(false);
await user.AddRolesAsync(await GetMuteRole(channel.Guild).ConfigureAwait(false)).ConfigureAwait(false); await user.AddRolesAsync(await GetMuteRole(channel.Guild).ConfigureAwait(false)).ConfigureAwait(false);
await channel.SendMessageAsync($"🔇 **{user}** has been **muted** from text and voice chat successfully.").ConfigureAwait(false); await channel.SendConfirmAsync($"🔇 **{user}** has been **muted** from text and voice chat successfully.").ConfigureAwait(false);
} }
catch catch
{ {
await channel.SendMessageAsync("⚠️ I most likely don't have the permission necessary for that.").ConfigureAwait(false); await channel.SendErrorAsync("⚠️ I most likely don't have the permission necessary for that.").ConfigureAwait(false);
} }
} }
@ -451,11 +451,11 @@ namespace NadekoBot.Modules.Administration
{ {
await user.ModifyAsync(usr => usr.Mute = false).ConfigureAwait(false); await user.ModifyAsync(usr => usr.Mute = false).ConfigureAwait(false);
await user.RemoveRolesAsync(await GetMuteRole(channel.Guild).ConfigureAwait(false)).ConfigureAwait(false); await user.RemoveRolesAsync(await GetMuteRole(channel.Guild).ConfigureAwait(false)).ConfigureAwait(false);
await channel.SendMessageAsync($"🔉 **{user}** has been **unmuted** from text and voice chat successfully.").ConfigureAwait(false); await channel.SendConfirmAsync($"🔉 **{user}** has been **unmuted** from text and voice chat successfully.").ConfigureAwait(false);
} }
catch catch
{ {
await channel.SendMessageAsync("⚠️ I most likely don't have the permission necessary for that.").ConfigureAwait(false); await channel.SendErrorAsync("⚠️ I most likely don't have the permission necessary for that.").ConfigureAwait(false);
} }
} }
@ -469,11 +469,11 @@ namespace NadekoBot.Modules.Administration
try try
{ {
await user.AddRolesAsync(await GetMuteRole(channel.Guild).ConfigureAwait(false)).ConfigureAwait(false); await user.AddRolesAsync(await GetMuteRole(channel.Guild).ConfigureAwait(false)).ConfigureAwait(false);
await channel.SendMessageAsync($"✏️🚫 **{user}** has been **muted** from chatting successfully.").ConfigureAwait(false); await channel.SendConfirmAsync($"✏️🚫 **{user}** has been **muted** from chatting successfully.").ConfigureAwait(false);
} }
catch catch
{ {
await channel.SendMessageAsync("⚠️ I most likely don't have the permission necessary for that.").ConfigureAwait(false); await channel.SendErrorAsync("⚠️ I most likely don't have the permission necessary for that.").ConfigureAwait(false);
} }
} }
@ -487,11 +487,11 @@ namespace NadekoBot.Modules.Administration
try try
{ {
await user.RemoveRolesAsync(await GetMuteRole(channel.Guild).ConfigureAwait(false)).ConfigureAwait(false); await user.RemoveRolesAsync(await GetMuteRole(channel.Guild).ConfigureAwait(false)).ConfigureAwait(false);
await channel.SendMessageAsync($"✏️✅ **{user}** has been **unmuted** from chatting successfully.").ConfigureAwait(false); await channel.SendConfirmAsync($"✏️✅ **{user}** has been **unmuted** from chatting successfully.").ConfigureAwait(false);
} }
catch catch
{ {
await channel.SendMessageAsync("⚠️ I most likely don't have the permission necessary for that.").ConfigureAwait(false); await channel.SendErrorAsync("⚠️ I most likely don't have the permission necessary for that.").ConfigureAwait(false);
} }
} }
@ -505,11 +505,11 @@ namespace NadekoBot.Modules.Administration
try try
{ {
await user.ModifyAsync(usr => usr.Mute = true).ConfigureAwait(false); await user.ModifyAsync(usr => usr.Mute = true).ConfigureAwait(false);
await channel.SendMessageAsync($"🎙🚫 **{user}** has been **voice muted** successfully.").ConfigureAwait(false); await channel.SendConfirmAsync($"🎙🚫 **{user}** has been **voice muted** successfully.").ConfigureAwait(false);
} }
catch catch
{ {
await channel.SendMessageAsync("⚠️ I most likely don't have the permission necessary for that.").ConfigureAwait(false); await channel.SendErrorAsync("⚠️ I most likely don't have the permission necessary for that.").ConfigureAwait(false);
} }
} }
@ -522,11 +522,11 @@ namespace NadekoBot.Modules.Administration
try try
{ {
await user.ModifyAsync(usr => usr.Mute = false).ConfigureAwait(false); await user.ModifyAsync(usr => usr.Mute = false).ConfigureAwait(false);
await channel.SendMessageAsync($"🎙✅ **{user}** has been **voice unmuted** successfully.").ConfigureAwait(false); await channel.SendConfirmAsync($"🎙✅ **{user}** has been **voice unmuted** successfully.").ConfigureAwait(false);
} }
catch catch
{ {
await channel.SendMessageAsync("⚠️ I most likely don't have the permission necessary for that.").ConfigureAwait(false); await channel.SendErrorAsync("⚠️ I most likely don't have the permission necessary for that.").ConfigureAwait(false);
} }
} }
@ -545,11 +545,11 @@ namespace NadekoBot.Modules.Administration
{ {
await u.ModifyAsync(usr=>usr.Deaf = true).ConfigureAwait(false); await u.ModifyAsync(usr=>usr.Deaf = true).ConfigureAwait(false);
} }
await channel.SendMessageAsync("🔇 **Deafen** successful.").ConfigureAwait(false); await channel.SendConfirmAsync("🔇 **Deafen** successful.").ConfigureAwait(false);
} }
catch catch
{ {
await channel.SendMessageAsync("⚠️ I most likely don't have the permission necessary for that.").ConfigureAwait(false); await channel.SendErrorAsync("⚠️ I most likely don't have the permission necessary for that.").ConfigureAwait(false);
} }
} }
@ -568,11 +568,11 @@ namespace NadekoBot.Modules.Administration
{ {
await u.ModifyAsync(usr=> usr.Deaf = false).ConfigureAwait(false); await u.ModifyAsync(usr=> usr.Deaf = false).ConfigureAwait(false);
} }
await channel.SendMessageAsync("🔊 **Undeafen** successful.").ConfigureAwait(false); await channel.SendConfirmAsync("🔊 **Undeafen** successful.").ConfigureAwait(false);
} }
catch catch
{ {
await channel.SendMessageAsync("⚠️ I most likely don't have the permission necessary for that.").ConfigureAwait(false); await channel.SendErrorAsync("⚠️ I most likely don't have the permission necessary for that.").ConfigureAwait(false);
} }
} }
@ -582,7 +582,7 @@ namespace NadekoBot.Modules.Administration
public async Task DelVoiChanl(IUserMessage umsg, [Remainder] IVoiceChannel voiceChannel) public async Task DelVoiChanl(IUserMessage umsg, [Remainder] IVoiceChannel voiceChannel)
{ {
await voiceChannel.DeleteAsync().ConfigureAwait(false); await voiceChannel.DeleteAsync().ConfigureAwait(false);
await umsg.Channel.SendMessageAsync($"🗑 Removed voice channel **{voiceChannel.Name}** successfully.").ConfigureAwait(false); await umsg.Channel.SendConfirmAsync($"🗑 Removed voice channel **{voiceChannel.Name}** successfully.").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -592,7 +592,7 @@ namespace NadekoBot.Modules.Administration
{ {
var channel = (ITextChannel)umsg.Channel; var channel = (ITextChannel)umsg.Channel;
var ch = await channel.Guild.CreateVoiceChannelAsync(channelName).ConfigureAwait(false); var ch = await channel.Guild.CreateVoiceChannelAsync(channelName).ConfigureAwait(false);
await channel.SendMessageAsync($"✅ Created voice channel **{ch.Name}**. ID: `{ch.Id}`").ConfigureAwait(false); await channel.SendConfirmAsync($"✅ Created voice channel **{ch.Name}**. ID: `{ch.Id}`").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -601,7 +601,7 @@ namespace NadekoBot.Modules.Administration
public async Task DelTxtChanl(IUserMessage umsg, [Remainder] ITextChannel toDelete) public async Task DelTxtChanl(IUserMessage umsg, [Remainder] ITextChannel toDelete)
{ {
await toDelete.DeleteAsync().ConfigureAwait(false); await toDelete.DeleteAsync().ConfigureAwait(false);
await umsg.Channel.SendMessageAsync($"🗑 Removed text channel **{toDelete.Name}**. ID: `{toDelete.Id}`").ConfigureAwait(false); await umsg.Channel.SendConfirmAsync($"🗑 Removed text channel **{toDelete.Name}**. ID: `{toDelete.Id}`").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -611,7 +611,7 @@ namespace NadekoBot.Modules.Administration
{ {
var channel = (ITextChannel)umsg.Channel; var channel = (ITextChannel)umsg.Channel;
var txtCh = await channel.Guild.CreateTextChannelAsync(channelName).ConfigureAwait(false); var txtCh = await channel.Guild.CreateTextChannelAsync(channelName).ConfigureAwait(false);
await channel.SendMessageAsync($"✅ Added text channel **{txtCh.Name}**. ID: `{txtCh.Id}`").ConfigureAwait(false); await channel.SendConfirmAsync($"✅ Added text channel **{txtCh.Name}**. ID: `{txtCh.Id}`").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -622,7 +622,7 @@ namespace NadekoBot.Modules.Administration
var channel = (ITextChannel)umsg.Channel; var channel = (ITextChannel)umsg.Channel;
topic = topic ?? ""; topic = topic ?? "";
await channel.ModifyAsync(c => c.Topic = topic); await channel.ModifyAsync(c => c.Topic = topic);
await channel.SendMessageAsync("🆗 **New channel topic set.**").ConfigureAwait(false); await channel.SendConfirmAsync("🆗 **New channel topic set.**").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -633,7 +633,7 @@ namespace NadekoBot.Modules.Administration
var channel = (ITextChannel)umsg.Channel; var channel = (ITextChannel)umsg.Channel;
await channel.ModifyAsync(c => c.Name = name).ConfigureAwait(false); await channel.ModifyAsync(c => c.Name = name).ConfigureAwait(false);
await channel.SendMessageAsync("🆗 **New channel name set.**").ConfigureAwait(false); await channel.SendConfirmAsync("🆗 **New channel name set.**").ConfigureAwait(false);
} }
@ -680,7 +680,7 @@ namespace NadekoBot.Modules.Administration
[OwnerOnly] [OwnerOnly]
public async Task Die(IUserMessage umsg) public async Task Die(IUserMessage umsg)
{ {
try { await umsg.Channel.SendMessageAsync(" **Shutting down.**").ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); } try { await umsg.Channel.SendConfirmAsync(" **Shutting down.**").ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); }
await Task.Delay(2000).ConfigureAwait(false); await Task.Delay(2000).ConfigureAwait(false);
Environment.Exit(0); Environment.Exit(0);
} }
@ -694,7 +694,7 @@ namespace NadekoBot.Modules.Administration
await (await NadekoBot.Client.GetCurrentUserAsync()).ModifyAsync(u => u.Username = newName).ConfigureAwait(false); await (await NadekoBot.Client.GetCurrentUserAsync()).ModifyAsync(u => u.Username = newName).ConfigureAwait(false);
await umsg.Channel.SendMessageAsync($" Successfully changed name to **{newName}**").ConfigureAwait(false); await umsg.Channel.SendConfirmAsync($" Successfully changed name to **{newName}**").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -716,7 +716,7 @@ namespace NadekoBot.Modules.Administration
} }
} }
await umsg.Channel.SendMessageAsync("🆒 **New avatar set.**").ConfigureAwait(false); await umsg.Channel.SendConfirmAsync("🆒 **New avatar set.**").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -727,7 +727,7 @@ namespace NadekoBot.Modules.Administration
await NadekoBot.Client.SetGame(game).ConfigureAwait(false); await NadekoBot.Client.SetGame(game).ConfigureAwait(false);
await umsg.Channel.SendMessageAsync("👾 **New game set.**").ConfigureAwait(false); await umsg.Channel.SendConfirmAsync("👾 **New game set.**").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -738,7 +738,7 @@ namespace NadekoBot.Modules.Administration
await NadekoBot.Client.SetStream(name, url).ConfigureAwait(false); await NadekoBot.Client.SetStream(name, url).ConfigureAwait(false);
await umsg.Channel.SendMessageAsync(" **New stream set.**").ConfigureAwait(false); await umsg.Channel.SendConfirmAsync(" **New stream set.**").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -779,7 +779,7 @@ namespace NadekoBot.Modules.Administration
} }
else else
{ {
await umsg.Channel.SendMessageAsync("⚠️ Invalid format.").ConfigureAwait(false); await umsg.Channel.SendErrorAsync("⚠️ Invalid format.").ConfigureAwait(false);
} }
} }
@ -791,10 +791,10 @@ namespace NadekoBot.Modules.Administration
g.GetDefaultChannelAsync() g.GetDefaultChannelAsync()
)).ConfigureAwait(false); )).ConfigureAwait(false);
await Task.WhenAll(channels.Select(c => c.SendMessageAsync($"🆕 **Message from {umsg.Author} `(Bot Owner)`:** " + message))) await Task.WhenAll(channels.Select(c => c.SendConfirmAsync($"🆕 Message from {umsg.Author} `[Bot Owner]`:", message)))
.ConfigureAwait(false); .ConfigureAwait(false);
await umsg.Channel.SendMessageAsync("🆗").ConfigureAwait(false); await umsg.Channel.SendConfirmAsync("🆗").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -837,7 +837,7 @@ namespace NadekoBot.Modules.Administration
{ {
var channel = (ITextChannel)umsg.Channel; var channel = (ITextChannel)umsg.Channel;
string send = $"❕{umsg.Author.Mention} __`has invoked a mention on the following roles`__❕"; string send = $"❕{umsg.Author.Mention} has invoked a mention on the following roles ❕";
foreach (var role in roles) foreach (var role in roles)
{ {
send += $"\n**{role.Name}**\n"; send += $"\n**{role.Name}**\n";
@ -865,9 +865,7 @@ namespace NadekoBot.Modules.Administration
{ {
donatorsOrdered = uow.Donators.GetDonatorsOrdered(); donatorsOrdered = uow.Donators.GetDonatorsOrdered();
} }
await umsg.Channel.SendConfirmAsync("Thanks to the people listed below for making this project happen!", string.Join("⭐", donatorsOrdered.Select(d => d.Name))).ConfigureAwait(false);
string str = $"**Thanks to the people listed below for making this project happen!**\n";
await umsg.Channel.SendMessageAsync(str + string.Join("⭐", donatorsOrdered.Select(d => d.Name))).ConfigureAwait(false);
nadekoSupportServer = nadekoSupportServer ?? NadekoBot.Client.GetGuild(117523346618318850); nadekoSupportServer = nadekoSupportServer ?? NadekoBot.Client.GetGuild(117523346618318850);
@ -879,7 +877,7 @@ namespace NadekoBot.Modules.Administration
return; return;
var usrs = nadekoSupportServer.GetUsers().Where(u => u.Roles.Contains(patreonRole)); var usrs = nadekoSupportServer.GetUsers().Where(u => u.Roles.Contains(patreonRole));
await umsg.Channel.SendMessageAsync("\n`Patreon supporters:`\n" + string.Join("⭐", usrs.Select(d => d.Username))).ConfigureAwait(false); await umsg.Channel.SendConfirmAsync("Patreon supporters", string.Join("⭐", usrs.Select(d => d.Username))).ConfigureAwait(false);
} }
@ -894,7 +892,7 @@ namespace NadekoBot.Modules.Administration
await uow.CompleteAsync(); await uow.CompleteAsync();
} }
await umsg.Channel.SendMessageAsync($"Successfuly added a new donator. Total donated amount from this user: {don.Amount} 👑").ConfigureAwait(false); await umsg.Channel.SendConfirmAsync($"Successfuly added a new donator. Total donated amount from this user: {don.Amount} 👑").ConfigureAwait(false);
} }
} }
} }

View File

@ -1,6 +1,7 @@
using Discord; using Discord;
using Discord.Commands; using Discord.Commands;
using NadekoBot.Attributes; using NadekoBot.Attributes;
using NadekoBot.Extensions;
using NLog; using NLog;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
@ -202,13 +203,13 @@ namespace NadekoBot.Modules.Administration
if (userThreshold < 2 || userThreshold > 30) if (userThreshold < 2 || userThreshold > 30)
{ {
await channel.SendMessageAsync("❗User threshold must be between **2** and **30**.").ConfigureAwait(false); await channel.SendErrorAsync("❗User threshold must be between **2** and **30**.").ConfigureAwait(false);
return; return;
} }
if (seconds < 2 || seconds > 300) if (seconds < 2 || seconds > 300)
{ {
await channel.SendMessageAsync("❗Time must be between **2** and **300** seconds.").ConfigureAwait(false); await channel.SendErrorAsync("❗Time must be between **2** and **300** seconds.").ConfigureAwait(false);
return; return;
} }
@ -218,7 +219,7 @@ namespace NadekoBot.Modules.Administration
} }
catch (Exception ex) catch (Exception ex)
{ {
await channel.SendMessageAsync("⚠️ Failed creating a mute role. Give me ManageRoles permission" + await channel.SendConfirmAsync("⚠️ Failed creating a mute role. Give me ManageRoles permission" +
"or create 'nadeko-mute' role with disabled SendMessages and try again.") "or create 'nadeko-mute' role with disabled SendMessages and try again.")
.ConfigureAwait(false); .ConfigureAwait(false);
_log.Warn(ex); _log.Warn(ex);
@ -233,7 +234,7 @@ namespace NadekoBot.Modules.Administration
}; };
antiRaidGuilds.AddOrUpdate(channel.Guild.Id, setting, (id, old) => setting); antiRaidGuilds.AddOrUpdate(channel.Guild.Id, setting, (id, old) => setting);
await channel.SendMessageAsync($" {imsg.Author.Mention} If **{userThreshold}** or more users join within **{seconds}** seconds, I will **{action}** them.") await channel.SendConfirmAsync($" {imsg.Author.Mention} If **{userThreshold}** or more users join within **{seconds}** seconds, I will **{action}** them.")
.ConfigureAwait(false); .ConfigureAwait(false);
} }
@ -250,7 +251,7 @@ namespace NadekoBot.Modules.Administration
AntiSpamSetting throwaway; AntiSpamSetting throwaway;
if (antiSpamGuilds.TryRemove(channel.Guild.Id, out throwaway)) if (antiSpamGuilds.TryRemove(channel.Guild.Id, out throwaway))
{ {
await channel.SendMessageAsync("🆗 **Anti-Spam feature** has been **disabled** on this server.").ConfigureAwait(false); await channel.SendConfirmAsync("🆗 **Anti-Spam feature** has been **disabled** on this server.").ConfigureAwait(false);
} }
else else
{ {
@ -260,7 +261,7 @@ namespace NadekoBot.Modules.Administration
} }
catch (Exception ex) catch (Exception ex)
{ {
await channel.SendMessageAsync("⚠️ Failed creating a mute role. Give me ManageRoles permission" + await channel.SendErrorAsync("⚠️ Failed creating a mute role. Give me ManageRoles permission" +
"or create 'nadeko-mute' role with disabled SendMessages and try again.") "or create 'nadeko-mute' role with disabled SendMessages and try again.")
.ConfigureAwait(false); .ConfigureAwait(false);
_log.Warn(ex); _log.Warn(ex);
@ -272,7 +273,7 @@ namespace NadekoBot.Modules.Administration
Action = action, Action = action,
MessageThreshold = messageCount, MessageThreshold = messageCount,
})) }))
await channel.SendMessageAsync("✅ **Anti-Spam feature** has been **enabled** on this server.").ConfigureAwait(false); await channel.SendConfirmAsync("✅ **Anti-Spam feature** has been **enabled** on this server.").ConfigureAwait(false);
} }
} }

View File

@ -1,6 +1,7 @@
using Discord; using Discord;
using Discord.Commands; using Discord.Commands;
using NadekoBot.Attributes; using NadekoBot.Attributes;
using NadekoBot.Extensions;
using NadekoBot.Services; using NadekoBot.Services;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;
using NLog; using NLog;
@ -67,11 +68,11 @@ namespace NadekoBot.Modules.Administration
if (role == null) if (role == null)
{ {
await channel.SendMessageAsync("🆗 **Auto assign role** on user join is now **disabled**.").ConfigureAwait(false); await channel.SendConfirmAsync("🆗 **Auto assign role** on user join is now **disabled**.").ConfigureAwait(false);
return; return;
} }
await channel.SendMessageAsync("✅ **Auto assign role** on user join is now **enabled**.").ConfigureAwait(false); await channel.SendConfirmAsync("✅ **Auto assign role** on user join is now **enabled**.").ConfigureAwait(false);
} }
} }
} }

View File

@ -67,7 +67,7 @@ namespace NadekoBot.Modules.Administration
if (Subscribers.TryAdd(token, set)) if (Subscribers.TryAdd(token, set))
{ {
set.Add(channel); set.Add(channel);
await ((IGuildUser)msg.Author).SendMessageAsync("This is your CSC token:" + token.ToString()).ConfigureAwait(false); await ((IGuildUser)msg.Author).SendConfirmAsync("This is your CSC token", token.ToString()).ConfigureAwait(false);
} }
} }
@ -82,7 +82,7 @@ namespace NadekoBot.Modules.Administration
if (!Subscribers.TryGetValue(token, out set)) if (!Subscribers.TryGetValue(token, out set))
return; return;
set.Add(channel); set.Add(channel);
await channel.SendMessageAsync(":ok:").ConfigureAwait(false); await channel.SendConfirmAsync("Joined cross server channel.").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -96,7 +96,7 @@ namespace NadekoBot.Modules.Administration
{ {
subscriber.Value.TryRemove(channel); subscriber.Value.TryRemove(channel);
} }
await channel.SendMessageAsync(":ok:").ConfigureAwait(false); await channel.SendMessageAsync("Left cross server channel.").ConfigureAwait(false);
} }
} }
} }

View File

@ -1,6 +1,7 @@
using Discord; using Discord;
using Discord.Commands; using Discord.Commands;
using NadekoBot.Attributes; using NadekoBot.Attributes;
using NadekoBot.Extensions;
using NadekoBot.Services; using NadekoBot.Services;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -39,9 +40,9 @@ namespace NadekoBot.Modules.Administration
uow.Complete(); uow.Complete();
} }
if (ForwardDMs) if (ForwardDMs)
await channel.SendMessageAsync("✅ **I will forward DMs from now on.**").ConfigureAwait(false); await channel.SendConfirmAsync("✅ **I will forward DMs from now on.**").ConfigureAwait(false);
else else
await channel.SendMessageAsync("🆗 **I will stop forwarding DMs from now on.**").ConfigureAwait(false); await channel.SendConfirmAsync("🆗 **I will stop forwarding DMs from now on.**").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -57,9 +58,9 @@ namespace NadekoBot.Modules.Administration
uow.Complete(); uow.Complete();
} }
if (ForwardDMsToAllOwners) if (ForwardDMsToAllOwners)
await channel.SendMessageAsync(" **I will forward DMs to all owners.**").ConfigureAwait(false); await channel.SendConfirmAsync(" **I will forward DMs to all owners.**").ConfigureAwait(false);
else else
await channel.SendMessageAsync(" **I will forward DMs only to the first owner.**").ConfigureAwait(false); await channel.SendConfirmAsync(" **I will forward DMs only to the first owner.**").ConfigureAwait(false);
} }
@ -67,17 +68,17 @@ namespace NadekoBot.Modules.Administration
{ {
if (ForwardDMs && ownerChannels.Any()) if (ForwardDMs && ownerChannels.Any())
{ {
var toSend = $"```markdown\n I received a message from [{msg.Author}]({msg.Author.Id}): {msg.Content}```"; var title = $"DM from [{msg.Author}]({msg.Author.Id})";
if (ForwardDMsToAllOwners) if (ForwardDMsToAllOwners)
{ {
var msgs = await Task.WhenAll(ownerChannels.Where(ch => ch.Recipient.Id != msg.Author.Id) var msgs = await Task.WhenAll(ownerChannels.Where(ch => ch.Recipient.Id != msg.Author.Id)
.Select(ch => ch.SendMessageAsync(toSend))).ConfigureAwait(false); .Select(ch => ch.SendConfirmAsync(title, msg.Content))).ConfigureAwait(false);
} }
else else
{ {
var firstOwnerChannel = ownerChannels.First(); var firstOwnerChannel = ownerChannels.First();
if (firstOwnerChannel.Recipient.Id != msg.Author.Id) if (firstOwnerChannel.Recipient.Id != msg.Author.Id)
try { await firstOwnerChannel.SendMessageAsync(toSend).ConfigureAwait(false); } catch { } try { await firstOwnerChannel.SendConfirmAsync(title, msg.Content).ConfigureAwait(false); } catch { }
} }
} }
} }

View File

@ -2,6 +2,7 @@
using Discord.Commands; using Discord.Commands;
using Discord.WebSocket; using Discord.WebSocket;
using NadekoBot.Attributes; using NadekoBot.Attributes;
using NadekoBot.Extensions;
using NadekoBot.Services; using NadekoBot.Services;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;
using NLog; using NLog;
@ -88,11 +89,11 @@ namespace NadekoBot.Modules.Administration
RepeatRunner rep; RepeatRunner rep;
if (!repeaters.TryGetValue(channel.Id, out rep)) if (!repeaters.TryGetValue(channel.Id, out rep))
{ {
await channel.SendMessageAsync(" **No repeating message found on this server.**").ConfigureAwait(false); await channel.SendErrorAsync(" **No repeating message found on this server.**").ConfigureAwait(false);
return; return;
} }
rep.Reset(); rep.Reset();
await channel.SendMessageAsync("🔄 " + rep.Repeater.Message).ConfigureAwait(false); await channel.SendConfirmAsync("🔄 " + rep.Repeater.Message).ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -110,10 +111,10 @@ namespace NadekoBot.Modules.Administration
await uow.CompleteAsync(); await uow.CompleteAsync();
} }
rep.Stop(); rep.Stop();
await channel.SendMessageAsync("✅ **Stopped repeating a message.**").ConfigureAwait(false); await channel.SendConfirmAsync("✅ **Stopped repeating a message.**").ConfigureAwait(false);
} }
else else
await channel.SendMessageAsync(" **No message is repeating.**").ConfigureAwait(false); await channel.SendConfirmAsync(" **No message is repeating.**").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -159,7 +160,7 @@ namespace NadekoBot.Modules.Administration
return old; return old;
}); });
await channel.SendMessageAsync($"🔁 Repeating **\"{rep.Repeater.Message}\"** every `{rep.Repeater.Interval.Days} day(s), {rep.Repeater.Interval.Hours} hour(s) and {rep.Repeater.Interval.Minutes} minute(s)`.").ConfigureAwait(false); await channel.SendConfirmAsync($"🔁 Repeating **\"{rep.Repeater.Message}\"** every `{rep.Repeater.Interval.Days} day(s), {rep.Repeater.Interval.Hours} hour(s) and {rep.Repeater.Interval.Minutes} minute(s)`.").ConfigureAwait(false);
} }
} }
} }

View File

@ -98,9 +98,9 @@ namespace NadekoBot.Modules.Administration
await uow.CompleteAsync(); await uow.CompleteAsync();
} }
if (RotatingStatuses) if (RotatingStatuses)
await umsg.Channel.SendMessageAsync("🆗 **Rotating playing status enabled.**").ConfigureAwait(false); await umsg.Channel.SendConfirmAsync("🆗 **Rotating playing status enabled.**").ConfigureAwait(false);
else else
await umsg.Channel.SendMessageAsync(" **Rotating playing status disabled.**").ConfigureAwait(false); await umsg.Channel.SendConfirmAsync(" **Rotating playing status disabled.**").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -116,7 +116,7 @@ namespace NadekoBot.Modules.Administration
await uow.CompleteAsync(); await uow.CompleteAsync();
} }
await umsg.Channel.SendMessageAsync("✅ **Added.**").ConfigureAwait(false); await umsg.Channel.SendConfirmAsync("✅ **Added.**").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -124,11 +124,11 @@ namespace NadekoBot.Modules.Administration
public async Task ListPlaying(IUserMessage umsg) public async Task ListPlaying(IUserMessage umsg)
{ {
if (!RotatingStatusMessages.Any()) if (!RotatingStatusMessages.Any())
await umsg.Channel.SendMessageAsync("❎ **No rotating playing statuses set.**"); await umsg.Channel.SendErrorAsync("❎ **No rotating playing statuses set.**");
else else
{ {
var i = 1; var i = 1;
await umsg.Channel.SendMessageAsync($" {umsg.Author.Mention} `Here is a list of rotating statuses:`\n\n\t" + string.Join("\n\t", RotatingStatusMessages.Select(rs => $"`{i++}.` {rs.Status}"))); await umsg.Channel.SendConfirmAsync($" {umsg.Author.Mention} `Here is a list of rotating statuses:`\n\n\t" + string.Join("\n\t", RotatingStatusMessages.Select(rs => $"`{i++}.` {rs.Status}")));
} }
} }
@ -151,7 +151,7 @@ namespace NadekoBot.Modules.Administration
RotatingStatusMessages.RemoveAt(index); RotatingStatusMessages.RemoveAt(index);
await uow.CompleteAsync(); await uow.CompleteAsync();
} }
await umsg.Channel.SendMessageAsync($"🗑 **Removed the the playing message:** {msg}").ConfigureAwait(false); await umsg.Channel.SendConfirmAsync($"🗑 **Removed the the playing message:** {msg}").ConfigureAwait(false);
} }
} }
} }

View File

@ -94,7 +94,7 @@ namespace NadekoBot.Modules.Administration
if (RatelimitingChannels.TryRemove(channel.Id, out throwaway)) if (RatelimitingChannels.TryRemove(channel.Id, out throwaway))
{ {
throwaway.cancelSource.Cancel(); throwaway.cancelSource.Cancel();
await channel.SendMessageAsync(" **Slow mode disabled.**").ConfigureAwait(false); await channel.SendConfirmAsync(" Slow mode disabled.").ConfigureAwait(false);
return; return;
} }
} }
@ -109,7 +109,7 @@ namespace NadekoBot.Modules.Administration
if (msg < 1 || perSec < 1 || msg > 100 || perSec > 3600) if (msg < 1 || perSec < 1 || msg > 100 || perSec > 3600)
{ {
await channel.SendMessageAsync("⚠️ `Invalid parameters.`"); await channel.SendErrorAsync("⚠️ Invalid parameters.");
return; return;
} }
var toAdd = new Ratelimiter() var toAdd = new Ratelimiter()
@ -120,8 +120,8 @@ namespace NadekoBot.Modules.Administration
}; };
if(RatelimitingChannels.TryAdd(channel.Id, toAdd)) if(RatelimitingChannels.TryAdd(channel.Id, toAdd))
{ {
await channel.SendMessageAsync("✅ **Slow mode initiated: " + await channel.SendConfirmAsync("Slow mode initiated",
$"Users can't send more than `{toAdd.MaxMessages} message(s)` every `{toAdd.PerSeconds} second(s)`.**") $"Users can't send more than `{toAdd.MaxMessages} message(s)` every `{toAdd.PerSeconds} second(s)`.")
.ConfigureAwait(false); .ConfigureAwait(false);
} }
} }

View File

@ -1,6 +1,7 @@
using Discord; using Discord;
using Discord.Commands; using Discord.Commands;
using NadekoBot.Attributes; using NadekoBot.Attributes;
using NadekoBot.Extensions;
using NadekoBot.Services; using NadekoBot.Services;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;
using System; using System;
@ -32,7 +33,7 @@ namespace NadekoBot.Modules.Administration
await uow.CompleteAsync().ConfigureAwait(false); await uow.CompleteAsync().ConfigureAwait(false);
} }
await channel.SendMessageAsync($" Automatic deleting of `iam` and `iamn` confirmations has been {(newval ? "**enabled**" : "**disabled**")}.") await channel.SendConfirmAsync($" Automatic deleting of `iam` and `iamn` confirmations has been {(newval ? "**enabled**" : "**disabled**")}.")
.ConfigureAwait(false); .ConfigureAwait(false);
} }
@ -51,7 +52,8 @@ namespace NadekoBot.Modules.Administration
roles = uow.SelfAssignedRoles.GetFromGuild(channel.Guild.Id); roles = uow.SelfAssignedRoles.GetFromGuild(channel.Guild.Id);
if (roles.Any(s => s.RoleId == role.Id && s.GuildId == role.GuildId)) if (roles.Any(s => s.RoleId == role.Id && s.GuildId == role.GuildId))
{ {
msg = $"💢 Role **{role.Name}** is already in the list."; await channel.SendMessageAsync($"💢 Role **{role.Name}** is already in the list.").ConfigureAwait(false);
return;
} }
else else
{ {
@ -63,7 +65,7 @@ namespace NadekoBot.Modules.Administration
msg = $"🆗 Role **{role.Name}** added to the list."; msg = $"🆗 Role **{role.Name}** added to the list.";
} }
} }
await channel.SendMessageAsync(msg.ToString()).ConfigureAwait(false); await channel.SendConfirmAsync(msg.ToString()).ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -81,10 +83,10 @@ namespace NadekoBot.Modules.Administration
} }
if (!success) if (!success)
{ {
await channel.SendMessageAsync("❎ That role is not self-assignable.").ConfigureAwait(false); await channel.SendErrorAsync("❎ That role is not self-assignable.").ConfigureAwait(false);
return; return;
} }
await channel.SendMessageAsync($"🗑 **{role.Name}** has been removed from the list of self-assignable roles.").ConfigureAwait(false); await channel.SendConfirmAsync($"🗑 **{role.Name}** has been removed from the list of self-assignable roles.").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -96,10 +98,12 @@ namespace NadekoBot.Modules.Administration
var toRemove = new ConcurrentHashSet<SelfAssignedRole>(); var toRemove = new ConcurrentHashSet<SelfAssignedRole>();
var removeMsg = new StringBuilder(); var removeMsg = new StringBuilder();
var msg = new StringBuilder(); var msg = new StringBuilder();
var roleCnt = 0;
using (var uow = DbHandler.UnitOfWork()) using (var uow = DbHandler.UnitOfWork())
{ {
var roleModels = uow.SelfAssignedRoles.GetFromGuild(channel.Guild.Id); var roleModels = uow.SelfAssignedRoles.GetFromGuild(channel.Guild.Id).ToList();
msg.AppendLine($" There are `{roleModels.Count()}` self assignable roles:"); roleCnt = roleModels.Count;
msg.AppendLine();
foreach (var roleModel in roleModels) foreach (var roleModel in roleModels)
{ {
@ -119,7 +123,7 @@ namespace NadekoBot.Modules.Administration
} }
await uow.CompleteAsync(); await uow.CompleteAsync();
} }
await channel.SendMessageAsync(msg.ToString() + "\n\n" + removeMsg.ToString()).ConfigureAwait(false); await channel.SendConfirmAsync($" There are `{roleCnt}` self assignable roles:", msg.ToString() + "\n\n" + removeMsg.ToString()).ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -138,7 +142,7 @@ namespace NadekoBot.Modules.Administration
await uow.CompleteAsync(); await uow.CompleteAsync();
} }
string exl = areExclusive ? "**exclusive**." : "**not exclusive**."; string exl = areExclusive ? "**exclusive**." : "**not exclusive**.";
await channel.SendMessageAsync(" Self assigned roles are now " + exl); await channel.SendConfirmAsync(" Self assigned roles are now " + exl);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -159,12 +163,12 @@ namespace NadekoBot.Modules.Administration
SelfAssignedRole roleModel; SelfAssignedRole roleModel;
if ((roleModel = roles.FirstOrDefault(r=>r.RoleId == role.Id)) == null) if ((roleModel = roles.FirstOrDefault(r=>r.RoleId == role.Id)) == null)
{ {
await channel.SendMessageAsync("💢 That role is not self-assignable.").ConfigureAwait(false); await channel.SendErrorAsync("That role is not self-assignable.").ConfigureAwait(false);
return; return;
} }
if (guildUser.Roles.Contains(role)) if (guildUser.Roles.Contains(role))
{ {
await channel.SendMessageAsync($"❎ You already have **{role.Name}** role.").ConfigureAwait(false); await channel.SendErrorAsync($"You already have **{role.Name}** role.").ConfigureAwait(false);
return; return;
} }
@ -173,7 +177,7 @@ namespace NadekoBot.Modules.Administration
var sameRoles = guildUser.Roles.Where(r => roles.Any(rm => rm.RoleId == r.Id)); var sameRoles = guildUser.Roles.Where(r => roles.Any(rm => rm.RoleId == r.Id));
if (sameRoles.Any()) if (sameRoles.Any())
{ {
await channel.SendMessageAsync($"❎ You already have **{sameRoles.FirstOrDefault().Name}** `exclusive self-assigned` role.").ConfigureAwait(false); await channel.SendErrorAsync($"You already have **{sameRoles.FirstOrDefault().Name}** `exclusive self-assigned` role.").ConfigureAwait(false);
return; return;
} }
} }
@ -183,11 +187,11 @@ namespace NadekoBot.Modules.Administration
} }
catch (Exception ex) catch (Exception ex)
{ {
await channel.SendMessageAsync($"⚠️ I am unable to add that role to you. `I can't add roles to owners or other roles higher than my role in the role hierarchy.`").ConfigureAwait(false); await channel.SendErrorAsync($"⚠️ I am unable to add that role to you. `I can't add roles to owners or other roles higher than my role in the role hierarchy.`").ConfigureAwait(false);
Console.WriteLine(ex); Console.WriteLine(ex);
return; return;
} }
var msg = await channel.SendMessageAsync($"🆗 You now have **{role.Name}** role.").ConfigureAwait(false); var msg = await channel.SendConfirmAsync($"🆗 You now have **{role.Name}** role.").ConfigureAwait(false);
if (conf.AutoDeleteSelfAssignedRoleMessages) if (conf.AutoDeleteSelfAssignedRoleMessages)
{ {
@ -217,12 +221,12 @@ namespace NadekoBot.Modules.Administration
SelfAssignedRole roleModel; SelfAssignedRole roleModel;
if ((roleModel = roles.FirstOrDefault(r => r.RoleId == role.Id)) == null) if ((roleModel = roles.FirstOrDefault(r => r.RoleId == role.Id)) == null)
{ {
await channel.SendMessageAsync("💢 That role is not self-assignable.").ConfigureAwait(false); await channel.SendErrorAsync("💢 That role is not self-assignable.").ConfigureAwait(false);
return; return;
} }
if (!guildUser.Roles.Contains(role)) if (!guildUser.Roles.Contains(role))
{ {
await channel.SendMessageAsync($"❎ You don't have **{role.Name}** role.").ConfigureAwait(false); await channel.SendErrorAsync($"❎ You don't have **{role.Name}** role.").ConfigureAwait(false);
return; return;
} }
try try
@ -231,10 +235,10 @@ namespace NadekoBot.Modules.Administration
} }
catch (Exception) catch (Exception)
{ {
await channel.SendMessageAsync($"⚠️ I am unable to add that role to you. `I can't remove roles to owners or other roles higher than my role in the role hierarchy.`").ConfigureAwait(false); await channel.SendErrorAsync($"⚠️ I am unable to add that role to you. `I can't remove roles to owners or other roles higher than my role in the role hierarchy.`").ConfigureAwait(false);
return; return;
} }
var msg = await channel.SendMessageAsync($"🆗 You no longer have **{role.Name}** role.").ConfigureAwait(false); var msg = await channel.SendConfirmAsync($"🆗 You no longer have **{role.Name}** role.").ConfigureAwait(false);
if (autoDeleteSelfAssignedRoleMessages) if (autoDeleteSelfAssignedRoleMessages)
{ {

View File

@ -1,6 +1,7 @@
using Discord; using Discord;
using Discord.Commands; using Discord.Commands;
using NadekoBot.Attributes; using NadekoBot.Attributes;
using NadekoBot.Extensions;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -31,18 +32,18 @@ namespace NadekoBot.Modules.Administration
if (server == null) if (server == null)
{ {
await channel.SendMessageAsync("⚠️ Cannot find that server").ConfigureAwait(false); await channel.SendErrorAsync("⚠️ Cannot find that server").ConfigureAwait(false);
return; return;
} }
if (server.OwnerId != _client.GetCurrentUser().Id) if (server.OwnerId != _client.GetCurrentUser().Id)
{ {
await server.LeaveAsync().ConfigureAwait(false); await server.LeaveAsync().ConfigureAwait(false);
await channel.SendMessageAsync("✅ Left server " + server.Name).ConfigureAwait(false); await channel.SendConfirmAsync("✅ Left server " + server.Name).ConfigureAwait(false);
} }
else else
{ {
await server.DeleteAsync().ConfigureAwait(false); await server.DeleteAsync().ConfigureAwait(false);
await channel.SendMessageAsync("Deleted server " + server.Name).ConfigureAwait(false); await channel.SendConfirmAsync("Deleted server " + server.Name).ConfigureAwait(false);
} }
} }
} }

View File

@ -112,7 +112,7 @@ namespace NadekoBot.Modules.Administration
var msg = conf.DmGreetMessageText.Replace("%user%", user.Username).Replace("%server%", user.Guild.Name); var msg = conf.DmGreetMessageText.Replace("%user%", user.Username).Replace("%server%", user.Guild.Name);
if (!string.IsNullOrWhiteSpace(msg)) if (!string.IsNullOrWhiteSpace(msg))
{ {
await channel.SendMessageAsync(msg).ConfigureAwait(false); await channel.SendConfirmAsync(msg).ConfigureAwait(false);
} }
} }
} }
@ -134,9 +134,9 @@ namespace NadekoBot.Modules.Administration
await ServerGreetCommands.SetGreetDel(channel.Guild.Id, timer).ConfigureAwait(false); await ServerGreetCommands.SetGreetDel(channel.Guild.Id, timer).ConfigureAwait(false);
if (timer > 0) if (timer > 0)
await channel.SendMessageAsync($"🆗 Greet messages **will be deleted** after `{timer} seconds`.").ConfigureAwait(false); await channel.SendConfirmAsync($"🆗 Greet messages **will be deleted** after `{timer} seconds`.").ConfigureAwait(false);
else else
await channel.SendMessageAsync(" Automatic deletion of greet messages has been **disabled**.").ConfigureAwait(false); await channel.SendConfirmAsync(" Automatic deletion of greet messages has been **disabled**.").ConfigureAwait(false);
} }
private static async Task SetGreetDel(ulong id, int timer) private static async Task SetGreetDel(ulong id, int timer)
@ -163,9 +163,9 @@ namespace NadekoBot.Modules.Administration
var enabled = await ServerGreetCommands.SetGreet(channel.Guild.Id, channel.Id).ConfigureAwait(false); var enabled = await ServerGreetCommands.SetGreet(channel.Guild.Id, channel.Id).ConfigureAwait(false);
if (enabled) if (enabled)
await channel.SendMessageAsync("✅ Greeting messages **enabled** on this channel.").ConfigureAwait(false); await channel.SendConfirmAsync("✅ Greeting messages **enabled** on this channel.").ConfigureAwait(false);
else else
await channel.SendMessageAsync(" Greeting messages **disabled**.").ConfigureAwait(false); await channel.SendConfirmAsync(" Greeting messages **disabled**.").ConfigureAwait(false);
} }
private static async Task<bool> SetGreet(ulong guildId, ulong channelId, bool? value = null) private static async Task<bool> SetGreet(ulong guildId, ulong channelId, bool? value = null)
@ -196,15 +196,15 @@ namespace NadekoBot.Modules.Administration
{ {
channelGreetMessageText = uow.GuildConfigs.For(channel.Guild.Id, set => set).ChannelGreetMessageText; channelGreetMessageText = uow.GuildConfigs.For(channel.Guild.Id, set => set).ChannelGreetMessageText;
} }
await channel.SendMessageAsync(" Current **greet** message: `" + channelGreetMessageText?.SanitizeMentions() + "`"); await channel.SendConfirmAsync("Current greet message: ", channelGreetMessageText?.SanitizeMentions());
return; return;
} }
var sendGreetEnabled = ServerGreetCommands.SetGreetMessage(channel.Guild.Id, ref text); var sendGreetEnabled = ServerGreetCommands.SetGreetMessage(channel.Guild.Id, ref text);
await channel.SendMessageAsync("🆗 New greet message **set**.").ConfigureAwait(false); await channel.SendConfirmAsync("🆗 New greet message **set**.").ConfigureAwait(false);
if (!sendGreetEnabled) if (!sendGreetEnabled)
await channel.SendMessageAsync(" Enable greet messsages by typing `.greet`").ConfigureAwait(false); await channel.SendConfirmAsync(" Enable greet messsages by typing `.greet`").ConfigureAwait(false);
} }
public static bool SetGreetMessage(ulong guildId, ref string message) public static bool SetGreetMessage(ulong guildId, ref string message)
@ -236,9 +236,9 @@ namespace NadekoBot.Modules.Administration
var enabled = await ServerGreetCommands.SetGreetDm(channel.Guild.Id).ConfigureAwait(false); var enabled = await ServerGreetCommands.SetGreetDm(channel.Guild.Id).ConfigureAwait(false);
if (enabled) if (enabled)
await channel.SendMessageAsync("🆗 DM Greet announcements **enabled**.").ConfigureAwait(false); await channel.SendConfirmAsync("🆗 DM Greet announcements **enabled**.").ConfigureAwait(false);
else else
await channel.SendMessageAsync(" Greet announcements **disabled**.").ConfigureAwait(false); await channel.SendConfirmAsync(" Greet announcements **disabled**.").ConfigureAwait(false);
} }
private static async Task<bool> SetGreetDm(ulong guildId, bool? value = null) private static async Task<bool> SetGreetDm(ulong guildId, bool? value = null)
@ -268,15 +268,15 @@ namespace NadekoBot.Modules.Administration
{ {
config = uow.GuildConfigs.For(channel.Guild.Id); config = uow.GuildConfigs.For(channel.Guild.Id);
} }
await channel.SendMessageAsync(" Current **DM greet** message: `" + config.DmGreetMessageText?.SanitizeMentions() + "`"); await channel.SendConfirmAsync(" Current **DM greet** message: `" + config.DmGreetMessageText?.SanitizeMentions() + "`");
return; return;
} }
var sendGreetEnabled = ServerGreetCommands.SetGreetDmMessage(channel.Guild.Id, ref text); var sendGreetEnabled = ServerGreetCommands.SetGreetDmMessage(channel.Guild.Id, ref text);
await channel.SendMessageAsync("🆗 New DM greet message **set**.").ConfigureAwait(false); await channel.SendConfirmAsync("🆗 New DM greet message **set**.").ConfigureAwait(false);
if (!sendGreetEnabled) if (!sendGreetEnabled)
await channel.SendMessageAsync($" Enable DM greet messsages by typing `{NadekoBot.ModulePrefixes[typeof(Administration).Name]}greetdm`").ConfigureAwait(false); await channel.SendConfirmAsync($" Enable DM greet messsages by typing `{NadekoBot.ModulePrefixes[typeof(Administration).Name]}greetdm`").ConfigureAwait(false);
} }
public static bool SetGreetDmMessage(ulong guildId, ref string message) public static bool SetGreetDmMessage(ulong guildId, ref string message)
@ -308,9 +308,9 @@ namespace NadekoBot.Modules.Administration
var enabled = await ServerGreetCommands.SetBye(channel.Guild.Id, channel.Id).ConfigureAwait(false); var enabled = await ServerGreetCommands.SetBye(channel.Guild.Id, channel.Id).ConfigureAwait(false);
if (enabled) if (enabled)
await channel.SendMessageAsync("✅ Bye announcements **enabled** on this channel.").ConfigureAwait(false); await channel.SendConfirmAsync("✅ Bye announcements **enabled** on this channel.").ConfigureAwait(false);
else else
await channel.SendMessageAsync(" Bye announcements **disabled**.").ConfigureAwait(false); await channel.SendConfirmAsync(" Bye announcements **disabled**.").ConfigureAwait(false);
} }
private static async Task<bool> SetBye(ulong guildId, ulong channelId, bool? value = null) private static async Task<bool> SetBye(ulong guildId, ulong channelId, bool? value = null)
@ -341,15 +341,15 @@ namespace NadekoBot.Modules.Administration
{ {
byeMessageText = uow.GuildConfigs.For(channel.Guild.Id, set => set).ChannelByeMessageText; byeMessageText = uow.GuildConfigs.For(channel.Guild.Id, set => set).ChannelByeMessageText;
} }
await channel.SendMessageAsync(" Current **bye** message: `" + byeMessageText?.SanitizeMentions() + "`"); await channel.SendConfirmAsync(" Current **bye** message: `" + byeMessageText?.SanitizeMentions() + "`");
return; return;
} }
var sendByeEnabled = ServerGreetCommands.SetByeMessage(channel.Guild.Id, ref text); var sendByeEnabled = ServerGreetCommands.SetByeMessage(channel.Guild.Id, ref text);
await channel.SendMessageAsync("🆗 New bye message **set**.").ConfigureAwait(false); await channel.SendConfirmAsync("🆗 New bye message **set**.").ConfigureAwait(false);
if (!sendByeEnabled) if (!sendByeEnabled)
await channel.SendMessageAsync($" Enable bye messsages by typing `{NadekoBot.ModulePrefixes[typeof(Administration).Name]}bye`").ConfigureAwait(false); await channel.SendConfirmAsync($" Enable bye messsages by typing `{NadekoBot.ModulePrefixes[typeof(Administration).Name]}bye`").ConfigureAwait(false);
} }
public static bool SetByeMessage(ulong guildId, ref string message) public static bool SetByeMessage(ulong guildId, ref string message)
@ -381,9 +381,9 @@ namespace NadekoBot.Modules.Administration
await ServerGreetCommands.SetByeDel(channel.Guild.Id, timer).ConfigureAwait(false); await ServerGreetCommands.SetByeDel(channel.Guild.Id, timer).ConfigureAwait(false);
if (timer > 0) if (timer > 0)
await channel.SendMessageAsync($"🆗 Bye messages **will be deleted** after `{timer} seconds`.").ConfigureAwait(false); await channel.SendConfirmAsync($"🆗 Bye messages **will be deleted** after `{timer} seconds`.").ConfigureAwait(false);
else else
await channel.SendMessageAsync(" Automatic deletion of bye messages has been **disabled**.").ConfigureAwait(false); await channel.SendConfirmAsync(" Automatic deletion of bye messages has been **disabled**.").ConfigureAwait(false);
} }
private static async Task SetByeDel(ulong id, int timer) private static async Task SetByeDel(ulong id, int timer)

View File

@ -51,7 +51,7 @@ namespace NadekoBot.Modules.Administration
{ {
try try
{ {
await (await guild.GetOwnerAsync()).SendMessageAsync( await (await guild.GetOwnerAsync()).SendErrorAsync(
"⚠️ I don't have **manage server** and/or **manage channels** permission," + "⚠️ I don't have **manage server** and/or **manage channels** permission," +
$" so I cannot run `voice+text` on **{guild.Name}** server.").ConfigureAwait(false); $" so I cannot run `voice+text` on **{guild.Name}** server.").ConfigureAwait(false);
} }
@ -116,7 +116,7 @@ namespace NadekoBot.Modules.Administration
var botUser = await guild.GetCurrentUserAsync().ConfigureAwait(false); var botUser = await guild.GetCurrentUserAsync().ConfigureAwait(false);
if (!botUser.GuildPermissions.ManageRoles || !botUser.GuildPermissions.ManageChannels) if (!botUser.GuildPermissions.ManageRoles || !botUser.GuildPermissions.ManageChannels)
{ {
await channel.SendMessageAsync("💢 I require atleast **manage roles** and **manage channels permissions** to enable this feature. `(preffered Administration permission)`"); await channel.SendErrorAsync("I require atleast **manage roles** and **manage channels permissions** to enable this feature. `(preffered Administration permission)`");
return; return;
} }
@ -124,7 +124,7 @@ namespace NadekoBot.Modules.Administration
{ {
try try
{ {
await channel.SendMessageAsync("⚠️ You are enabling this feature and **I do not have ADMINISTRATOR permissions**. " + await channel.SendErrorAsync("⚠️ You are enabling this feature and **I do not have ADMINISTRATOR permissions**. " +
"`This may cause some issues, and you will have to clean up text channels yourself afterwards.`"); "`This may cause some issues, and you will have to clean up text channels yourself afterwards.`");
} }
catch { } catch { }
@ -145,16 +145,16 @@ namespace NadekoBot.Modules.Administration
{ {
try { await textChannel.DeleteAsync().ConfigureAwait(false); } catch { } try { await textChannel.DeleteAsync().ConfigureAwait(false); } catch { }
} }
await channel.SendMessageAsync(" Successfuly **removed** voice + text feature.").ConfigureAwait(false); await channel.SendConfirmAsync(" Successfuly **removed** voice + text feature.").ConfigureAwait(false);
return; return;
} }
voicePlusTextCache.Add(guild.Id); voicePlusTextCache.Add(guild.Id);
await channel.SendMessageAsync("🆗 Successfuly **enabled** voice + text feature.").ConfigureAwait(false); await channel.SendConfirmAsync("🆗 Successfuly **enabled** voice + text feature.").ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
await channel.SendMessageAsync(ex.ToString()).ConfigureAwait(false); await channel.SendErrorAsync(ex.ToString()).ConfigureAwait(false);
} }
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -168,7 +168,7 @@ namespace NadekoBot.Modules.Administration
var botUser = await guild.GetCurrentUserAsync().ConfigureAwait(false); var botUser = await guild.GetCurrentUserAsync().ConfigureAwait(false);
if (!botUser.GuildPermissions.Administrator) if (!botUser.GuildPermissions.Administrator)
{ {
await channel.SendMessageAsync("⚠️ I need **Administrator permission** to do that.").ConfigureAwait(false); await channel.SendErrorAsync("I need **Administrator permission** to do that.").ConfigureAwait(false);
return; return;
} }
@ -183,7 +183,7 @@ namespace NadekoBot.Modules.Administration
await Task.Delay(500); await Task.Delay(500);
} }
await channel.SendMessageAsync("✅ Done.").ConfigureAwait(false); await channel.SendConfirmAsync("Cleaned v+t.").ConfigureAwait(false);
} }
} }
} }

View File

@ -10,6 +10,7 @@ using NadekoBot.Attributes;
using Discord.WebSocket; using Discord.WebSocket;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;
using System.Linq; using System.Linq;
using NadekoBot.Extensions;
namespace NadekoBot.Modules.ClashOfClans namespace NadekoBot.Modules.ClashOfClans
{ {
@ -49,7 +50,7 @@ namespace NadekoBot.Modules.ClashOfClans
if (!Bases[i].BaseDestroyed && DateTime.UtcNow - Bases[i].TimeAdded >= callExpire) if (!Bases[i].BaseDestroyed && DateTime.UtcNow - Bases[i].TimeAdded >= callExpire)
{ {
Bases[i] = null; Bases[i] = null;
try { await war.Channel.SendMessageAsync($"❗🔰**Claim from @{Bases[i].CallUser} for a war against {war.ShortPrint()} has expired.**").ConfigureAwait(false); } catch { } try { await war.Channel.SendErrorAsync($"❗🔰**Claim from @{Bases[i].CallUser} for a war against {war.ShortPrint()} has expired.**").ConfigureAwait(false); } catch { }
} }
} }
} }
@ -68,7 +69,7 @@ namespace NadekoBot.Modules.ClashOfClans
if (size < 10 || size > 50 || size % 5 != 0) if (size < 10 || size > 50 || size % 5 != 0)
{ {
await channel.SendMessageAsync("💢🔰 Not a Valid war size").ConfigureAwait(false); await channel.SendErrorAsync("🔰 Not a Valid war size").ConfigureAwait(false);
return; return;
} }
List<ClashWar> wars; List<ClashWar> wars;
@ -83,7 +84,7 @@ namespace NadekoBot.Modules.ClashOfClans
var cw = await CreateWar(enemyClan, size, channel.Guild.Id, umsg.Channel.Id); var cw = await CreateWar(enemyClan, size, channel.Guild.Id, umsg.Channel.Id);
wars.Add(cw); wars.Add(cw);
await channel.SendMessageAsync($"❗🔰**CREATED CLAN WAR AGAINST {cw.ShortPrint()}**").ConfigureAwait(false); await channel.SendConfirmAsync($"❗🔰**CREATED CLAN WAR AGAINST {cw.ShortPrint()}**").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -98,18 +99,18 @@ namespace NadekoBot.Modules.ClashOfClans
var warsInfo = GetWarInfo(umsg, num); var warsInfo = GetWarInfo(umsg, num);
if (warsInfo == null) if (warsInfo == null)
{ {
await channel.SendMessageAsync("💢🔰 **That war does not exist.**").ConfigureAwait(false); await channel.SendErrorAsync("🔰 **That war does not exist.**").ConfigureAwait(false);
return; return;
} }
var war = warsInfo.Item1[warsInfo.Item2]; var war = warsInfo.Item1[warsInfo.Item2];
try try
{ {
war.Start(); war.Start();
await channel.SendMessageAsync($"🔰**STARTED WAR AGAINST {war.ShortPrint()}**").ConfigureAwait(false); await channel.SendConfirmAsync($"🔰**STARTED WAR AGAINST {war.ShortPrint()}**").ConfigureAwait(false);
} }
catch catch
{ {
await channel.SendMessageAsync($"🔰**WAR AGAINST {war.ShortPrint()} HAS ALREADY STARTED**").ConfigureAwait(false); await channel.SendErrorAsync($"🔰**WAR AGAINST {war.ShortPrint()} HAS ALREADY STARTED**").ConfigureAwait(false);
} }
SaveWar(war); SaveWar(war);
} }
@ -128,7 +129,7 @@ namespace NadekoBot.Modules.ClashOfClans
ClashWars.TryGetValue(channel.Guild.Id, out wars); ClashWars.TryGetValue(channel.Guild.Id, out wars);
if (wars == null || wars.Count == 0) if (wars == null || wars.Count == 0)
{ {
await channel.SendMessageAsync("🔰 **No active wars.**").ConfigureAwait(false); await channel.SendErrorAsync("🔰 **No active wars.**").ConfigureAwait(false);
return; return;
} }
@ -141,7 +142,7 @@ namespace NadekoBot.Modules.ClashOfClans
sb.AppendLine($"\t\t`Size:` **{wars[i].Size} v {wars[i].Size}**"); sb.AppendLine($"\t\t`Size:` **{wars[i].Size} v {wars[i].Size}**");
sb.AppendLine("**-------------------------**"); sb.AppendLine("**-------------------------**");
} }
await channel.SendMessageAsync(sb.ToString()).ConfigureAwait(false); await channel.SendConfirmAsync(sb.ToString()).ConfigureAwait(false);
return; return;
} }
@ -151,10 +152,10 @@ namespace NadekoBot.Modules.ClashOfClans
var warsInfo = GetWarInfo(umsg, num); var warsInfo = GetWarInfo(umsg, num);
if (warsInfo == null) if (warsInfo == null)
{ {
await channel.SendMessageAsync("💢🔰 **That war does not exist.**").ConfigureAwait(false); await channel.SendErrorAsync("🔰 **That war does not exist.**").ConfigureAwait(false);
return; return;
} }
await channel.SendMessageAsync(warsInfo.Item1[warsInfo.Item2].ToPrettyString()).ConfigureAwait(false); await channel.SendConfirmAsync(warsInfo.Item1[warsInfo.Item2].ToPrettyString()).ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -165,7 +166,7 @@ namespace NadekoBot.Modules.ClashOfClans
var warsInfo = GetWarInfo(umsg, number); var warsInfo = GetWarInfo(umsg, number);
if (warsInfo == null || warsInfo.Item1.Count == 0) if (warsInfo == null || warsInfo.Item1.Count == 0)
{ {
await channel.SendMessageAsync("💢🔰 **That war does not exist.**").ConfigureAwait(false); await channel.SendErrorAsync("🔰 **That war does not exist.**").ConfigureAwait(false);
return; return;
} }
var usr = var usr =
@ -177,11 +178,11 @@ namespace NadekoBot.Modules.ClashOfClans
var war = warsInfo.Item1[warsInfo.Item2]; var war = warsInfo.Item1[warsInfo.Item2];
war.Call(usr, baseNumber - 1); war.Call(usr, baseNumber - 1);
SaveWar(war); SaveWar(war);
await channel.SendMessageAsync($"🔰**{usr}** claimed a base #{baseNumber} for a war against {war.ShortPrint()}").ConfigureAwait(false); await channel.SendConfirmAsync($"🔰**{usr}** claimed a base #{baseNumber} for a war against {war.ShortPrint()}").ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
await channel.SendMessageAsync($"💢🔰 {ex.Message}").ConfigureAwait(false); await channel.SendErrorAsync($"🔰 {ex.Message}").ConfigureAwait(false);
} }
} }
@ -218,13 +219,13 @@ namespace NadekoBot.Modules.ClashOfClans
var warsInfo = GetWarInfo(umsg,number); var warsInfo = GetWarInfo(umsg,number);
if (warsInfo == null) if (warsInfo == null)
{ {
await channel.SendMessageAsync("💢🔰 That war does not exist.").ConfigureAwait(false); await channel.SendErrorAsync("🔰 That war does not exist.").ConfigureAwait(false);
return; return;
} }
var war = warsInfo.Item1[warsInfo.Item2]; var war = warsInfo.Item1[warsInfo.Item2];
war.End(); war.End();
SaveWar(war); SaveWar(war);
await channel.SendMessageAsync($"❗🔰**War against {warsInfo.Item1[warsInfo.Item2].ShortPrint()} ended.**").ConfigureAwait(false); await channel.SendConfirmAsync($"❗🔰**War against {warsInfo.Item1[warsInfo.Item2].ShortPrint()} ended.**").ConfigureAwait(false);
var size = warsInfo.Item1[warsInfo.Item2].Size; var size = warsInfo.Item1[warsInfo.Item2].Size;
warsInfo.Item1.RemoveAt(warsInfo.Item2); warsInfo.Item1.RemoveAt(warsInfo.Item2);
@ -239,7 +240,7 @@ namespace NadekoBot.Modules.ClashOfClans
var warsInfo = GetWarInfo(umsg, number); var warsInfo = GetWarInfo(umsg, number);
if (warsInfo == null || warsInfo.Item1.Count == 0) if (warsInfo == null || warsInfo.Item1.Count == 0)
{ {
await channel.SendMessageAsync("💢🔰 **That war does not exist.**").ConfigureAwait(false); await channel.SendErrorAsync("🔰 **That war does not exist.**").ConfigureAwait(false);
return; return;
} }
var usr = var usr =
@ -251,11 +252,11 @@ namespace NadekoBot.Modules.ClashOfClans
var war = warsInfo.Item1[warsInfo.Item2]; var war = warsInfo.Item1[warsInfo.Item2];
var baseNumber = war.Uncall(usr); var baseNumber = war.Uncall(usr);
SaveWar(war); SaveWar(war);
await channel.SendMessageAsync($"🔰 @{usr} has **UNCLAIMED** a base #{baseNumber + 1} from a war against {war.ShortPrint()}").ConfigureAwait(false); await channel.SendConfirmAsync($"🔰 @{usr} has **UNCLAIMED** a base #{baseNumber + 1} from a war against {war.ShortPrint()}").ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
await channel.SendMessageAsync($"💢🔰 {ex.Message}").ConfigureAwait(false); await channel.SendErrorAsync($"🔰 {ex.Message}").ConfigureAwait(false);
} }
} }
@ -265,7 +266,7 @@ namespace NadekoBot.Modules.ClashOfClans
var warInfo = GetWarInfo(umsg, number); var warInfo = GetWarInfo(umsg, number);
if (warInfo == null || warInfo.Item1.Count == 0) if (warInfo == null || warInfo.Item1.Count == 0)
{ {
await channel.SendMessageAsync("💢🔰 **That war does not exist.**").ConfigureAwait(false); await channel.SendErrorAsync("🔰 **That war does not exist.**").ConfigureAwait(false);
return; return;
} }
var war = warInfo.Item1[warInfo.Item2]; var war = warInfo.Item1[warInfo.Item2];
@ -280,11 +281,11 @@ namespace NadekoBot.Modules.ClashOfClans
{ {
war.FinishClaim(baseNumber, stars); war.FinishClaim(baseNumber, stars);
} }
await channel.SendMessageAsync($"❗🔰{umsg.Author.Mention} **DESTROYED** a base #{baseNumber + 1} in a war against {war.ShortPrint()}").ConfigureAwait(false); await channel.SendConfirmAsync($"❗🔰{umsg.Author.Mention} **DESTROYED** a base #{baseNumber + 1} in a war against {war.ShortPrint()}").ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
await channel.SendMessageAsync($"💢🔰 {ex.Message}").ConfigureAwait(false); await channel.SendErrorAsync($"🔰 {ex.Message}").ConfigureAwait(false);
} }
} }

View File

@ -77,7 +77,7 @@ namespace NadekoBot.Modules.CustomReactions
if ((channel == null && !NadekoBot.Credentials.IsOwner(imsg.Author)) || (channel != null && !((IGuildUser)imsg.Author).GuildPermissions.Administrator)) if ((channel == null && !NadekoBot.Credentials.IsOwner(imsg.Author)) || (channel != null && !((IGuildUser)imsg.Author).GuildPermissions.Administrator))
{ {
try { await imsg.Channel.SendMessageAsync("Insufficient permissions. Requires Bot ownership for global custom reactions, and Administrator for guild custom reactions."); } catch { } try { await imsg.Channel.SendErrorAsync("Insufficient permissions. Requires Bot ownership for global custom reactions, and Administrator for guild custom reactions."); } catch { }
return; return;
} }
@ -106,7 +106,12 @@ namespace NadekoBot.Modules.CustomReactions
reactions.Add(cr); reactions.Add(cr);
} }
await imsg.Channel.SendMessageAsync($"`Added new custom reaction {cr.Id}:`\n\t`Trigger:` {key}\n\t`Response:` {message}").ConfigureAwait(false); await imsg.Channel.EmbedAsync(new EmbedBuilder().WithColor(NadekoBot.OkColor)
.WithTitle("New Custom Reaction")
.WithDescription($"#{cr.Id}")
.AddField(efb => efb.WithName("Trigger").WithValue(key))
.AddField(efb => efb.WithName("Response").WithValue(message))
.Build()).ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -124,12 +129,11 @@ namespace NadekoBot.Modules.CustomReactions
customReactions = GuildReactions.GetOrAdd(channel.Guild.Id, new ConcurrentHashSet<CustomReaction>()); customReactions = GuildReactions.GetOrAdd(channel.Guild.Id, new ConcurrentHashSet<CustomReaction>());
if (customReactions == null || !customReactions.Any()) if (customReactions == null || !customReactions.Any())
await imsg.Channel.SendMessageAsync("`No custom reactions found`").ConfigureAwait(false); await imsg.Channel.SendErrorAsync("No custom reactions found").ConfigureAwait(false);
else else
await imsg.Channel.SendMessageAsync( await imsg.Channel.SendConfirmAsync(
$"`Page {page} of custom reactions:`\n" + $"Page {page} of custom reactions:",
string.Join("\n", customReactions string.Join("\n", customReactions.OrderBy(cr => cr.Trigger)
.OrderBy(cr => cr.Trigger)
.Skip((page - 1) * 20) .Skip((page - 1) * 20)
.Take(20) .Take(20)
.Select(cr => $"`#{cr.Id}` `Trigger:` {cr.Trigger}"))) .Select(cr => $"`#{cr.Id}` `Trigger:` {cr.Trigger}")))
@ -154,7 +158,7 @@ namespace NadekoBot.Modules.CustomReactions
customReactions = GuildReactions.GetOrAdd(channel.Guild.Id, new ConcurrentHashSet<CustomReaction>()); customReactions = GuildReactions.GetOrAdd(channel.Guild.Id, new ConcurrentHashSet<CustomReaction>());
if (customReactions == null || !customReactions.Any()) if (customReactions == null || !customReactions.Any())
await imsg.Channel.SendMessageAsync("`No custom reactions found`").ConfigureAwait(false); await imsg.Channel.SendErrorAsync("No custom reactions found").ConfigureAwait(false);
else else
{ {
var txtStream = await customReactions.GroupBy(cr => cr.Trigger) var txtStream = await customReactions.GroupBy(cr => cr.Trigger)
@ -183,9 +187,9 @@ namespace NadekoBot.Modules.CustomReactions
customReactions = GuildReactions.GetOrAdd(channel.Guild.Id, new ConcurrentHashSet<CustomReaction>()); customReactions = GuildReactions.GetOrAdd(channel.Guild.Id, new ConcurrentHashSet<CustomReaction>());
if (customReactions == null || !customReactions.Any()) if (customReactions == null || !customReactions.Any())
await imsg.Channel.SendMessageAsync("`No custom reactions found`").ConfigureAwait(false); await imsg.Channel.SendErrorAsync("No custom reactions found").ConfigureAwait(false);
else else
await imsg.Channel.SendMessageAsync($"{imsg.Author.Mention}\n`Page {page} of custom reactions (grouped):`\n" + await imsg.Channel.SendConfirmAsync($"Page {page} of custom reactions (grouped):",
string.Join("\r\n", customReactions string.Join("\r\n", customReactions
.GroupBy(cr=>cr.Trigger) .GroupBy(cr=>cr.Trigger)
.OrderBy(cr => cr.Key) .OrderBy(cr => cr.Key)
@ -209,11 +213,14 @@ namespace NadekoBot.Modules.CustomReactions
var found = customReactions.FirstOrDefault(cr => cr.Id == id); var found = customReactions.FirstOrDefault(cr => cr.Id == id);
if (found == null) if (found == null)
await imsg.Channel.SendMessageAsync("`No custom reaction found with that id.`").ConfigureAwait(false); await imsg.Channel.SendErrorAsync("No custom reaction found with that id.").ConfigureAwait(false);
else else
{ {
await imsg.Channel.SendMessageAsync($"`Custom reaction #{id}`\n`Trigger:` {found.Trigger}\n`Response:` {found.Response} ```css\n{found.Response}```") await imsg.Channel.EmbedAsync(new EmbedBuilder().WithColor(NadekoBot.OkColor)
.ConfigureAwait(false); .WithDescription($"#{id}")
.AddField(efb => efb.WithName("Trigger").WithValue(found.Trigger))
.AddField(efb => efb.WithName("Response").WithValue(found.Response + "\n```css\n" + found.Response + "```" ))
.Build()).ConfigureAwait(false);
} }
} }
@ -224,7 +231,7 @@ namespace NadekoBot.Modules.CustomReactions
if ((channel == null && !NadekoBot.Credentials.IsOwner(imsg.Author)) || (channel != null && !((IGuildUser)imsg.Author).GuildPermissions.Administrator)) if ((channel == null && !NadekoBot.Credentials.IsOwner(imsg.Author)) || (channel != null && !((IGuildUser)imsg.Author).GuildPermissions.Administrator))
{ {
try { await imsg.Channel.SendMessageAsync("Insufficient permissions. Requires Bot ownership for global custom reactions, and Administrator for guild custom reactions."); } catch { } try { await imsg.Channel.SendErrorAsync("Insufficient permissions. Requires Bot ownership for global custom reactions, and Administrator for guild custom reactions."); } catch { }
return; return;
} }
@ -253,9 +260,9 @@ namespace NadekoBot.Modules.CustomReactions
} }
if (success) if (success)
await imsg.Channel.SendMessageAsync("**Successfully deleted custom reaction** " + toDelete.ToString()).ConfigureAwait(false); await imsg.Channel.SendConfirmAsync("Deleted custom reaction", toDelete.ToString()).ConfigureAwait(false);
else else
await imsg.Channel.SendMessageAsync("`Failed to find that custom reaction.`").ConfigureAwait(false); await imsg.Channel.SendErrorAsync("Failed to find that custom reaction.").ConfigureAwait(false);
} }
} }
} }

View File

@ -29,7 +29,7 @@ namespace NadekoBot.Modules.Gambling
var ar = new AnimalRace(channel.Guild.Id, channel); var ar = new AnimalRace(channel.Guild.Id, channel);
if (ar.Fail) if (ar.Fail)
await channel.SendMessageAsync("🏁 `Failed starting a race. Another race is probably running.`"); await channel.SendErrorAsync("🏁 `Failed starting a race. Another race is probably running.`");
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -45,7 +45,7 @@ namespace NadekoBot.Modules.Gambling
AnimalRace ar; AnimalRace ar;
if (!AnimalRaces.TryGetValue(channel.Guild.Id, out ar)) if (!AnimalRaces.TryGetValue(channel.Guild.Id, out ar))
{ {
await channel.SendMessageAsync("No race exists on this server"); await channel.SendErrorAsync("No race exists on this server");
return; return;
} }
await ar.JoinRace(umsg.Author as IGuildUser, amount); await ar.JoinRace(umsg.Author as IGuildUser, amount);
@ -90,21 +90,21 @@ namespace NadekoBot.Modules.Gambling
{ {
try try
{ {
try { await raceChannel.SendMessageAsync($"🏁`Race is starting in 20 seconds or when the room is full. Type {NadekoBot.ModulePrefixes[typeof(Gambling).Name]}jr to join the race.`"); } catch (Exception ex) { _log.Warn(ex); } try { await raceChannel.SendConfirmAsync($"🏁`Race is starting in 20 seconds or when the room is full. Type {NadekoBot.ModulePrefixes[typeof(Gambling).Name]}jr to join the race.`"); } catch (Exception ex) { _log.Warn(ex); }
var t = await Task.WhenAny(Task.Delay(20000, token), fullgame); var t = await Task.WhenAny(Task.Delay(20000, token), fullgame);
Started = true; Started = true;
cancelSource.Cancel(); cancelSource.Cancel();
if (t == fullgame) if (t == fullgame)
{ {
try { await raceChannel.SendMessageAsync("🏁`Race full, starting right now!`"); } catch (Exception ex) { _log.Warn(ex); } try { await raceChannel.SendConfirmAsync("🏁`Race full, starting right now!`"); } catch (Exception ex) { _log.Warn(ex); }
} }
else if (participants.Count > 1) else if (participants.Count > 1)
{ {
try { await raceChannel.SendMessageAsync("🏁`Game starting with " + participants.Count + " participants.`"); } catch (Exception ex) { _log.Warn(ex); } try { await raceChannel.SendConfirmAsync("🏁`Game starting with " + participants.Count + " participants.`"); } catch (Exception ex) { _log.Warn(ex); }
} }
else else
{ {
try { await raceChannel.SendMessageAsync("🏁`Race failed to start since there was not enough participants.`"); } catch (Exception ex) { _log.Warn(ex); } try { await raceChannel.SendErrorAsync("🏁`Race failed to start since there was not enough participants.`"); } catch (Exception ex) { _log.Warn(ex); }
var p = participants.FirstOrDefault(); var p = participants.FirstOrDefault();
if (p != null && p.AmountBet > 0) if (p != null && p.AmountBet > 0)
@ -185,11 +185,11 @@ namespace NadekoBot.Modules.Gambling
var wonAmount = winner.AmountBet * (participants.Count - 1); var wonAmount = winner.AmountBet * (participants.Count - 1);
await CurrencyHandler.AddCurrencyAsync(winner.User, "Won a Race", wonAmount, false).ConfigureAwait(false); await CurrencyHandler.AddCurrencyAsync(winner.User, "Won a Race", wonAmount, false).ConfigureAwait(false);
await raceChannel.SendMessageAsync($"🏁 {winner.User.Mention} as {winner.Animal} **Won the race and {wonAmount}{CurrencySign}!**").ConfigureAwait(false); await raceChannel.SendConfirmAsync($"🏁 {winner.User.Mention} as {winner.Animal} **Won the race and {wonAmount}{CurrencySign}!**").ConfigureAwait(false);
} }
else else
{ {
await raceChannel.SendMessageAsync($"🏁 {winner.User.Mention} as {winner.Animal} **Won the race!**"); await raceChannel.SendConfirmAsync($"🏁 {winner.User.Mention} as {winner.Animal} **Won the race!**");
} }
} }
@ -218,28 +218,28 @@ namespace NadekoBot.Modules.Gambling
var animal = ""; var animal = "";
if (!animals.TryDequeue(out animal)) if (!animals.TryDequeue(out animal))
{ {
await raceChannel.SendMessageAsync($"{u.Mention} `There is no running race on this server.`"); await raceChannel.SendErrorAsync($"{u.Mention} `There is no running race on this server.`");
return; return;
} }
var p = new Participant(u, animal, amount); var p = new Participant(u, animal, amount);
if (participants.Contains(p)) if (participants.Contains(p))
{ {
await raceChannel.SendMessageAsync($"{u.Mention} `You already joined this race.`"); await raceChannel.SendErrorAsync($"{u.Mention} `You already joined this race.`");
return; return;
} }
if (Started) if (Started)
{ {
await raceChannel.SendMessageAsync($"{u.Mention} `Race is already started`"); await raceChannel.SendErrorAsync($"{u.Mention} `Race is already started`");
return; return;
} }
if (amount > 0) if (amount > 0)
if (!await CurrencyHandler.RemoveCurrencyAsync((IGuildUser)u, "BetRace", amount, true).ConfigureAwait(false)) if (!await CurrencyHandler.RemoveCurrencyAsync((IGuildUser)u, "BetRace", amount, true).ConfigureAwait(false))
{ {
try { await raceChannel.SendMessageAsync($"{u.Mention} You don't have enough {Gambling.CurrencyName}s.").ConfigureAwait(false); } catch { } try { await raceChannel.SendErrorAsync($"{u.Mention} You don't have enough {Gambling.CurrencyName}s.").ConfigureAwait(false); } catch { }
return; return;
} }
participants.Add(p); participants.Add(p);
await raceChannel.SendMessageAsync($"{u.Mention} **joined the race as a {p.Animal}" + (amount > 0 ? $" and bet {amount} {CurrencySign}!**" : "**")); await raceChannel.SendConfirmAsync($"{u.Mention} **joined the race as a {p.Animal}" + (amount > 0 ? $" and bet {amount} {CurrencySign}!**" : "**"));
} }
} }

View File

@ -78,7 +78,7 @@ namespace NadekoBot.Modules.Gambling
arr[i] = rng.Next(1, n2 + 1) + add - sub; arr[i] = rng.Next(1, n2 + 1) + add - sub;
} }
var elemCnt = 0; var elemCnt = 0;
await channel.SendMessageAsync($"{umsg.Author.Mention} rolled {n1} {(n1 == 1 ? "die" : "dice")} `1 to {n2}` +`{add}` -`{sub}`.\n`Result:` " + string.Join(", ", (ordered ? arr.OrderBy(x => x).AsEnumerable() : arr).Select(x => elemCnt++ % 2 == 0 ? $"**{x}**" : x.ToString()))).ConfigureAwait(false); await channel.SendConfirmAsync($"{umsg.Author.Mention} rolled {n1} {(n1 == 1 ? "die" : "dice")} `1 to {n2}` +`{add}` -`{sub}`.\n`Result:` " + string.Join(", ", (ordered ? arr.OrderBy(x => x).AsEnumerable() : arr).Select(x => elemCnt++ % 2 == 0 ? $"**{x}**" : x.ToString()))).ConfigureAwait(false);
} }
} }
} }
@ -96,7 +96,7 @@ namespace NadekoBot.Modules.Gambling
if (num < 1 || num > 30) if (num < 1 || num > 30)
{ {
await channel.SendMessageAsync("Invalid number specified. You can roll up to 1-30 dice at a time.").ConfigureAwait(false); await channel.SendErrorAsync("Invalid number specified. You can roll up to 1-30 dice at a time.").ConfigureAwait(false);
return; return;
} }
@ -167,7 +167,7 @@ namespace NadekoBot.Modules.Gambling
arr[i] = rng.Next(1, n2 + 1) + add - sub; arr[i] = rng.Next(1, n2 + 1) + add - sub;
} }
var elemCnt = 0; var elemCnt = 0;
await channel.SendMessageAsync($"{umsg.Author.Mention} rolled {n1} {(n1 == 1 ? "die" : "dice")} `1 to {n2}` +`{add}` -`{sub}`.\n`Result:` " + string.Join(", ", (ordered ? arr.OrderBy(x => x).AsEnumerable() : arr).Select(x => elemCnt++ % 2 == 0 ? $"**{x}**" : x.ToString()))).ConfigureAwait(false); await channel.SendConfirmAsync($"{umsg.Author.Mention} rolled {n1} {(n1 == 1 ? "die" : "dice")} `1 to {n2}` +`{add}` -`{sub}`.\n`Result:` " + string.Join(", ", (ordered ? arr.OrderBy(x => x).AsEnumerable() : arr).Select(x => elemCnt++ % 2 == 0 ? $"**{x}**" : x.ToString()))).ConfigureAwait(false);
} }
} }
} }
@ -184,7 +184,7 @@ namespace NadekoBot.Modules.Gambling
if (num < 1 || num > 30) if (num < 1 || num > 30)
{ {
await channel.SendMessageAsync("Invalid number specified. You can roll up to 1-30 dice at a time.").ConfigureAwait(false); await channel.SendErrorAsync("Invalid number specified. You can roll up to 1-30 dice at a time.").ConfigureAwait(false);
return; return;
} }
@ -249,11 +249,11 @@ namespace NadekoBot.Modules.Gambling
rolled = new NadekoRandom().Next(0, int.Parse(range) + 1); rolled = new NadekoRandom().Next(0, int.Parse(range) + 1);
} }
await channel.SendMessageAsync($"{umsg.Author.Mention} rolled **{rolled}**.").ConfigureAwait(false); await channel.SendConfirmAsync($"{umsg.Author.Mention} rolled **{rolled}**.").ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
await channel.SendMessageAsync($":anger: {ex.Message}").ConfigureAwait(false); await channel.SendErrorAsync($":anger: {ex.Message}").ConfigureAwait(false);
} }
} }

View File

@ -42,7 +42,7 @@ namespace NadekoBot.Modules.Gambling
{ {
if (cards.CardPool.Count == 0 && i != 0) if (cards.CardPool.Count == 0 && i != 0)
{ {
try { await channel.SendMessageAsync("No more cards in a deck.").ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); } try { await channel.SendErrorAsync("No more cards in a deck.").ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); }
break; break;
} }
var currentCard = cards.DrawACard(); var currentCard = cards.DrawACard();
@ -75,7 +75,7 @@ namespace NadekoBot.Modules.Gambling
return c; return c;
}); });
await channel.SendMessageAsync("`Deck reshuffled.`").ConfigureAwait(false); await channel.SendConfirmAsync("Deck reshuffled.").ConfigureAwait(false);
} }
} }
} }

View File

@ -34,7 +34,7 @@ namespace NadekoBot.Modules.Gambling
} }
if (count > 10 || count < 1) if (count > 10 || count < 1)
{ {
await channel.SendMessageAsync("`Invalid number specified. You can flip 1 to 10 coins.`"); await channel.SendErrorAsync("`Invalid number specified. You can flip 1 to 10 coins.`");
return; return;
} }
var imgs = new Image[count]; var imgs = new Image[count];
@ -59,7 +59,7 @@ namespace NadekoBot.Modules.Gambling
if (amount < 3) if (amount < 3)
{ {
await channel.SendMessageAsync($"You can't bet less than 3{Gambling.CurrencySign}.") await channel.SendErrorAsync($"You can't bet less than 3{Gambling.CurrencySign}.")
.ConfigureAwait(false); .ConfigureAwait(false);
return; return;
} }
@ -72,7 +72,7 @@ namespace NadekoBot.Modules.Gambling
if (userFlowers < amount) if (userFlowers < amount)
{ {
await channel.SendMessageAsync($"{umsg.Author.Mention} You don't have enough {Gambling.CurrencyPluralName}. You only have {userFlowers}{Gambling.CurrencySign}.").ConfigureAwait(false); await channel.SendErrorAsync($"{umsg.Author.Mention} You don't have enough {Gambling.CurrencyPluralName}. You only have {userFlowers}{Gambling.CurrencySign}.").ConfigureAwait(false);
return; return;
} }

View File

@ -51,7 +51,7 @@ namespace NadekoBot.Modules.Gambling
var members = role.Members().Where(u => u.Status != UserStatus.Offline && u.Status != UserStatus.Unknown); var members = role.Members().Where(u => u.Status != UserStatus.Offline && u.Status != UserStatus.Unknown);
var membersArray = members as IUser[] ?? members.ToArray(); var membersArray = members as IUser[] ?? members.ToArray();
var usr = membersArray[new NadekoRandom().Next(0, membersArray.Length)]; var usr = membersArray[new NadekoRandom().Next(0, membersArray.Length)];
await channel.SendMessageAsync($"🎟 Raffled user: **{usr.Username}#{usr.Discriminator}** ID: `{usr.Id}`").ConfigureAwait(false); await channel.SendConfirmAsync("🎟 Raffled user", $"**{usr.Username}#{usr.Discriminator}** ID: `{usr.Id}`").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -62,7 +62,7 @@ namespace NadekoBot.Modules.Gambling
user = user ?? umsg.Author; user = user ?? umsg.Author;
await channel.SendMessageAsync($"{user.Username} has {GetCurrency(user.Id)} {CurrencySign}").ConfigureAwait(false); await channel.SendConfirmAsync($"{user.Username} has {GetCurrency(user.Id)} {CurrencySign}").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -71,7 +71,7 @@ namespace NadekoBot.Modules.Gambling
{ {
var channel = umsg.Channel; var channel = umsg.Channel;
await channel.SendMessageAsync($"`{userId}` has {GetCurrency(userId)} {CurrencySign}").ConfigureAwait(false); await channel.SendConfirmAsync($"`{userId}` has {GetCurrency(userId)} {CurrencySign}").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -84,11 +84,11 @@ namespace NadekoBot.Modules.Gambling
var success = await CurrencyHandler.RemoveCurrencyAsync((IGuildUser)umsg.Author, $"Gift to {receiver.Username} ({receiver.Id}).", amount, true).ConfigureAwait(false); var success = await CurrencyHandler.RemoveCurrencyAsync((IGuildUser)umsg.Author, $"Gift to {receiver.Username} ({receiver.Id}).", amount, true).ConfigureAwait(false);
if (!success) if (!success)
{ {
await channel.SendMessageAsync($"{umsg.Author.Mention} You don't have enough {Gambling.CurrencyPluralName}.").ConfigureAwait(false); await channel.SendErrorAsync($"{umsg.Author.Mention} You don't have enough {Gambling.CurrencyPluralName}.").ConfigureAwait(false);
return; return;
} }
await CurrencyHandler.AddCurrencyAsync(receiver, $"Gift from {umsg.Author.Username} ({umsg.Author.Id}).", amount, true).ConfigureAwait(false); await CurrencyHandler.AddCurrencyAsync(receiver, $"Gift from {umsg.Author.Username} ({umsg.Author.Id}).", amount, true).ConfigureAwait(false);
await channel.SendMessageAsync($"{umsg.Author.Mention} successfully sent {amount} {(amount == 1 ? Gambling.CurrencyName : Gambling.CurrencyPluralName)} to {receiver.Mention}!").ConfigureAwait(false); await channel.SendConfirmAsync($"{umsg.Author.Mention} successfully sent {amount} {(amount == 1 ? Gambling.CurrencyName : Gambling.CurrencyPluralName)} to {receiver.Mention}!").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -111,7 +111,7 @@ namespace NadekoBot.Modules.Gambling
await CurrencyHandler.AddCurrencyAsync(usrId, $"Awarded by bot owner. ({umsg.Author.Username}/{umsg.Author.Id})", amount).ConfigureAwait(false); await CurrencyHandler.AddCurrencyAsync(usrId, $"Awarded by bot owner. ({umsg.Author.Username}/{umsg.Author.Id})", amount).ConfigureAwait(false);
await channel.SendMessageAsync($"{umsg.Author.Mention} successfully awarded {amount} {(amount == 1 ? Gambling.CurrencyName : Gambling.CurrencyPluralName)} to <@{usrId}>!").ConfigureAwait(false); await channel.SendConfirmAsync($"{umsg.Author.Mention} successfully awarded {amount} {(amount == 1 ? Gambling.CurrencyName : Gambling.CurrencyPluralName)} to <@{usrId}>!").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -129,7 +129,7 @@ namespace NadekoBot.Modules.Gambling
amount))) amount)))
.ConfigureAwait(false); .ConfigureAwait(false);
await channel.SendMessageAsync($"Awarded `{amount}` {Gambling.CurrencyPluralName} to `{users.Count}` users from `{role.Name}` role.") await channel.SendConfirmAsync($"Awarded `{amount}` {Gambling.CurrencyPluralName} to `{users.Count}` users from `{role.Name}` role.")
.ConfigureAwait(false); .ConfigureAwait(false);
} }
@ -144,9 +144,9 @@ namespace NadekoBot.Modules.Gambling
return; return;
if(await CurrencyHandler.RemoveCurrencyAsync(user, $"Taken by bot owner.({umsg.Author.Username}/{umsg.Author.Id})", amount, true).ConfigureAwait(false)) if(await CurrencyHandler.RemoveCurrencyAsync(user, $"Taken by bot owner.({umsg.Author.Username}/{umsg.Author.Id})", amount, true).ConfigureAwait(false))
await channel.SendMessageAsync($"{umsg.Author.Mention} successfully took {amount} {(amount == 1? Gambling.CurrencyName : Gambling.CurrencyPluralName)} from {user}!").ConfigureAwait(false); await channel.SendConfirmAsync($"{umsg.Author.Mention} successfully took {amount} {(amount == 1? Gambling.CurrencyName : Gambling.CurrencyPluralName)} from {user}!").ConfigureAwait(false);
else else
await channel.SendMessageAsync($"{umsg.Author.Mention} was unable to take {amount} {(amount == 1 ? Gambling.CurrencyName : Gambling.CurrencyPluralName)} from {user} because the user doesn't have that much {Gambling.CurrencyPluralName}!").ConfigureAwait(false); await channel.SendErrorAsync($"{umsg.Author.Mention} was unable to take {amount} {(amount == 1 ? Gambling.CurrencyName : Gambling.CurrencyPluralName)} from {user} because the user doesn't have that much {Gambling.CurrencyPluralName}!").ConfigureAwait(false);
} }
@ -160,9 +160,9 @@ namespace NadekoBot.Modules.Gambling
return; return;
if(await CurrencyHandler.RemoveCurrencyAsync(usrId, $"Taken by bot owner.({umsg.Author.Username}/{umsg.Author.Id})", amount).ConfigureAwait(false)) if(await CurrencyHandler.RemoveCurrencyAsync(usrId, $"Taken by bot owner.({umsg.Author.Username}/{umsg.Author.Id})", amount).ConfigureAwait(false))
await channel.SendMessageAsync($"{umsg.Author.Mention} successfully took {amount} {(amount == 1 ? Gambling.CurrencyName : Gambling.CurrencyPluralName)} from <@{usrId}>!").ConfigureAwait(false); await channel.SendConfirmAsync($"{umsg.Author.Mention} successfully took {amount} {(amount == 1 ? Gambling.CurrencyName : Gambling.CurrencyPluralName)} from <@{usrId}>!").ConfigureAwait(false);
else else
await channel.SendMessageAsync($"{umsg.Author.Mention} was unable to take {amount} {(amount == 1 ? Gambling.CurrencyName : Gambling.CurrencyPluralName)} from `{usrId}` because the user doesn't have that much {Gambling.CurrencyPluralName}!").ConfigureAwait(false); await channel.SendErrorAsync($"{umsg.Author.Mention} was unable to take {amount} {(amount == 1 ? Gambling.CurrencyName : Gambling.CurrencyPluralName)} from `{usrId}` because the user doesn't have that much {Gambling.CurrencyPluralName}!").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -184,7 +184,7 @@ namespace NadekoBot.Modules.Gambling
if (userFlowers < amount) if (userFlowers < amount)
{ {
await channel.SendMessageAsync($"{guildUser.Mention} You don't have enough {Gambling.CurrencyPluralName}. You only have {userFlowers}{Gambling.CurrencySign}.").ConfigureAwait(false); await channel.SendErrorAsync($"{guildUser.Mention} You don't have enough {Gambling.CurrencyPluralName}. You only have {userFlowers}{Gambling.CurrencySign}.").ConfigureAwait(false);
return; return;
} }
@ -212,7 +212,7 @@ namespace NadekoBot.Modules.Gambling
await CurrencyHandler.AddCurrencyAsync(guildUser, "Betroll Gamble", amount * 10, false).ConfigureAwait(false); await CurrencyHandler.AddCurrencyAsync(guildUser, "Betroll Gamble", amount * 10, false).ConfigureAwait(false);
} }
await channel.SendMessageAsync(str).ConfigureAwait(false); await channel.SendConfirmAsync(str).ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]

View File

@ -14,7 +14,7 @@ namespace NadekoBot.Services
var success = await RemoveCurrencyAsync(author.Id, reason, amount); var success = await RemoveCurrencyAsync(author.Id, reason, amount);
if (success && sendMessage) if (success && sendMessage)
try { await author.SendMessageAsync($"`You lost:` {amount} {Gambling.CurrencySign}\n`Reason:` {reason}").ConfigureAwait(false); } catch { } try { await author.SendErrorAsync($"`You lost:` {amount} {Gambling.CurrencySign}\n`Reason:` {reason}").ConfigureAwait(false); } catch { }
return success; return success;
} }
@ -47,7 +47,7 @@ namespace NadekoBot.Services
await AddCurrencyAsync(author.Id, reason, amount); await AddCurrencyAsync(author.Id, reason, amount);
if (sendMessage) if (sendMessage)
try { await author.SendMessageAsync($"`You received:` {amount} {Gambling.CurrencySign}\n`Reason:` {reason}").ConfigureAwait(false); } catch { } try { await author.SendConfirmAsync($"`You received:` {amount} {Gambling.CurrencySign}\n`Reason:` {reason}").ConfigureAwait(false); } catch { }
} }
public static async Task AddCurrencyAsync(ulong receiverId, string reason, long amount) public static async Task AddCurrencyAsync(ulong receiverId, string reason, long amount)

View File

@ -68,6 +68,18 @@ namespace NadekoBot.Extensions
public static async Task<IUserMessage> SendMessageAsync(this IGuildUser user, string message, bool isTTS = false) => public static async Task<IUserMessage> SendMessageAsync(this IGuildUser user, string message, bool isTTS = false) =>
await (await user.CreateDMChannelAsync().ConfigureAwait(false)).SendMessageAsync(message, isTTS).ConfigureAwait(false); await (await user.CreateDMChannelAsync().ConfigureAwait(false)).SendMessageAsync(message, isTTS).ConfigureAwait(false);
public static async Task<IUserMessage> SendConfirmAsync(this IGuildUser user, string text)
=> await (await user.CreateDMChannelAsync()).SendMessageAsync("", embed: new Embed() { Description = text, Color = NadekoBot.OkColor });
public static async Task<IUserMessage> SendConfirmAsync(this IGuildUser user, string title, string text, string url = null)
=> await(await user.CreateDMChannelAsync()).SendMessageAsync("", embed: new Embed() { Description = text, Title = title, Url = url, Color = NadekoBot.OkColor });
public static async Task<IUserMessage> SendErrorAsync(this IGuildUser user, string title, string error, string url = null)
=> await (await user.CreateDMChannelAsync()).SendMessageAsync("", embed: new Embed() { Description = error, Title = title, Url = url, Color = NadekoBot.ErrorColor });
public static async Task<IUserMessage> SendErrorAsync(this IGuildUser user, string error)
=> await (await user.CreateDMChannelAsync()).SendMessageAsync("", embed: new Embed() { Description = error, Color = NadekoBot.ErrorColor });
public static async Task<IUserMessage> SendFileAsync(this IGuildUser user, string filePath, string caption = null, bool isTTS = false) => public static async Task<IUserMessage> SendFileAsync(this IGuildUser user, string filePath, string caption = null, bool isTTS = false) =>
await (await user.CreateDMChannelAsync().ConfigureAwait(false)).SendFileAsync(filePath, caption, isTTS).ConfigureAwait(false); await (await user.CreateDMChannelAsync().ConfigureAwait(false)).SendFileAsync(filePath, caption, isTTS).ConfigureAwait(false);