From 68454a7b2f66503ad87fa6080c872a36c395da0c Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sat, 20 Aug 2016 16:33:18 +0200 Subject: [PATCH] Simplified sending, more gambling done but commented out (needs DB) --- .../Administration/AdministrationModule.cs | 92 ++--- .../Administration/Commands/AutoAssignRole.cs | 4 +- .../Commands/CrossServerTextChannel.cs | 4 +- .../Administration/Commands/LogCommand.cs | 26 +- .../Commands/MessageRepeater.cs | 8 +- .../Administration/Commands/PlayingRotate.cs | 10 +- .../Commands/RatelimitCommand.cs | 4 +- .../Commands/SelfAssignedRolesCommand.cs | 32 +- .../Administration/Commands/SelfCommands.cs | 2 +- .../Commands/ServerGreetCommand.cs | 36 +- .../Commands/VoicePlusTextCommand.cs | 12 +- .../Modules/ClashOfClans/ClashOfClans.cs | 40 +-- .../Gambling/Commands/DiceRollCommand.cs | 12 +- .../Modules/Gambling/Commands/DrawCommand.cs | 6 +- src/NadekoBot/Modules/Gambling/Gambling.cs | 314 +++++++++--------- .../Modules/Games/Commands/LeetCommands.cs | 2 +- .../Games/Commands/PlantAndPickCommands.cs | 16 +- .../Modules/Games/Commands/PollCommands.cs | 6 +- .../Games/Commands/SpeedTypingCommands.cs | 8 +- .../Modules/Games/Commands/TriviaCommands.cs | 10 +- src/NadekoBot/Modules/Games/Games.cs | 8 +- src/NadekoBot/Modules/Help/Help.cs | 16 +- src/NadekoBot/Modules/NSFW/NSFW.cs | 30 +- .../Searches/Commands/AnimeSearchCommands.cs | 8 +- .../Searches/Commands/ConverterCommands.cs | 8 +- .../Modules/Searches/Commands/EvalCommand.cs | 4 +- .../Modules/Searches/Commands/JokeCommands.cs | 10 +- .../Modules/Searches/Commands/LoLCommands.cs | 8 +- .../Searches/Commands/MemegenCommands.cs | 4 +- .../Modules/Searches/Commands/OsuCommands.cs | 18 +- .../Commands/PokemonSearchCommands.cs | 8 +- .../Commands/StreamNotificationCommands.cs | 26 +- src/NadekoBot/Modules/Searches/Searches.cs | 72 ++-- .../Modules/Translator/Translator.cs | 6 +- src/NadekoBot/Modules/Trello/Trello.cs | 10 +- .../Modules/Utility/Commands/Remind.cs | 10 +- src/NadekoBot/Modules/Utility/Utility.cs | 10 +- .../CustomReactions/CustomReactions.cs | 2 +- src/NadekoBot/_Modules/Music/MusicModule.cs | 72 ++-- .../Commands/FilterInvitesCommand.cs | 10 +- .../Commands/FilterWordsCommand.cs | 22 +- .../_Modules/Permissions/PermissionsModule.cs | 170 +++++----- 42 files changed, 588 insertions(+), 588 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/AdministrationModule.cs b/src/NadekoBot/Modules/Administration/AdministrationModule.cs index 62102450..2108bb69 100644 --- a/src/NadekoBot/Modules/Administration/AdministrationModule.cs +++ b/src/NadekoBot/Modules/Administration/AdministrationModule.cs @@ -30,7 +30,7 @@ namespace NadekoBot.Modules.Administration //{ // var channel = imsg.Channel as ITextChannel; - // await imsg.Channel.SendMessageAsync("`Restarting in 2 seconds...`"); + // await channel.SendMessageAsync("`Restarting in 2 seconds...`"); // await Task.Delay(2000); // System.Diagnostics.Process.Start(System.Reflection.Assembly.GetEntryAssembly().Location); // Environment.Exit(0); @@ -48,9 +48,9 @@ namespace NadekoBot.Modules.Administration // conf.AutoDeleteMessagesOnCommand = !conf.AutoDeleteMessagesOnCommand; // await Classes.JSONModels.ConfigHandler.SaveConfig().ConfigureAwait(false); // if (conf.AutoDeleteMessagesOnCommand) - // await imsg.Channel.SendMessageAsync("❗`Now automatically deleting successfull command invokations.`"); + // await channel.SendMessageAsync("❗`Now automatically deleting successfull command invokations.`"); // else - // await imsg.Channel.SendMessageAsync("❗`Stopped automatic deletion of successfull command invokations.`"); + // await channel.SendMessageAsync("❗`Stopped automatic deletion of successfull command invokations.`"); //} [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -62,11 +62,11 @@ namespace NadekoBot.Modules.Administration try { await usr.AddRolesAsync(role).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Successfully added role **{role.Name}** to user **{usr.Username}**").ConfigureAwait(false); + await channel.SendMessageAsync($"Successfully added role **{role.Name}** to user **{usr.Username}**").ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync("Failed to add roles. Bot has insufficient permissions.\n").ConfigureAwait(false); + await channel.SendMessageAsync("Failed to add roles. Bot has insufficient permissions.\n").ConfigureAwait(false); Console.WriteLine(ex.ToString()); } } @@ -79,11 +79,11 @@ namespace NadekoBot.Modules.Administration try { await usr.RemoveRolesAsync(role).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Successfully removed role **{role.Name}** from user **{usr.Username}**").ConfigureAwait(false); + await channel.SendMessageAsync($"Successfully removed role **{role.Name}** from user **{usr.Username}**").ConfigureAwait(false); } catch { - await imsg.Channel.SendMessageAsync("Failed to remove roles. Most likely reason: Insufficient permissions.").ConfigureAwait(false); + await channel.SendMessageAsync("Failed to remove roles. Most likely reason: Insufficient permissions.").ConfigureAwait(false); } } @@ -97,15 +97,15 @@ namespace NadekoBot.Modules.Administration { if (roleToEdit.Position > (await channel.Guild.GetCurrentUserAsync().ConfigureAwait(false)).Roles.Max(r => r.Position)) { - await imsg.Channel.SendMessageAsync("You can't edit roles higher than your highest role.").ConfigureAwait(false); + await channel.SendMessageAsync("You can't edit roles higher than your highest role.").ConfigureAwait(false); return; } await roleToEdit.ModifyAsync(g => g.Name = newname).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync("Role renamed.").ConfigureAwait(false); + await channel.SendMessageAsync("Role renamed.").ConfigureAwait(false); } catch (Exception) { - await imsg.Channel.SendMessageAsync("Failed to rename role. Probably insufficient permissions.").ConfigureAwait(false); + await channel.SendMessageAsync("Failed to rename role. Probably insufficient permissions.").ConfigureAwait(false); } } @@ -119,11 +119,11 @@ namespace NadekoBot.Modules.Administration try { await user.RemoveRolesAsync(user.Roles).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Successfully removed **all** roles from user **{user.Username}**").ConfigureAwait(false); + await channel.SendMessageAsync($"Successfully removed **all** roles from user **{user.Username}**").ConfigureAwait(false); } catch { - await imsg.Channel.SendMessageAsync("Failed to remove roles. Most likely reason: Insufficient permissions.").ConfigureAwait(false); + await channel.SendMessageAsync("Failed to remove roles. Most likely reason: Insufficient permissions.").ConfigureAwait(false); } } @@ -140,11 +140,11 @@ namespace NadekoBot.Modules.Administration try { var r = await channel.Guild.CreateRoleAsync(roleName).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Successfully created role **{r.Name}**.").ConfigureAwait(false); + await channel.SendMessageAsync($"Successfully created role **{r.Name}**.").ConfigureAwait(false); } catch (Exception) { - await imsg.Channel.SendMessageAsync(":warning: Unspecified error.").ConfigureAwait(false); + await channel.SendMessageAsync(":warning: Unspecified error.").ConfigureAwait(false); } } @@ -157,7 +157,7 @@ namespace NadekoBot.Modules.Administration if (args.Count() != 2 && args.Count() != 4) { - await imsg.Channel.SendMessageAsync("The parameters are invalid.").ConfigureAwait(false); + await channel.SendMessageAsync("The parameters are invalid.").ConfigureAwait(false); return; } var roleName = args[0].ToUpperInvariant(); @@ -165,7 +165,7 @@ namespace NadekoBot.Modules.Administration if (role == null) { - await imsg.Channel.SendMessageAsync("That role does not exist.").ConfigureAwait(false); + await channel.SendMessageAsync("That role does not exist.").ConfigureAwait(false); return; } try @@ -178,11 +178,11 @@ namespace NadekoBot.Modules.Administration var blue = Convert.ToByte(rgb ? int.Parse(args[3]) : Convert.ToInt32(arg1.Substring(4, 2), 16)); await role.ModifyAsync(r => r.Color = new Color(red, green, blue).RawValue).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Role {role.Name}'s color has been changed.").ConfigureAwait(false); + await channel.SendMessageAsync($"Role {role.Name}'s color has been changed.").ConfigureAwait(false); } catch (Exception) { - await imsg.Channel.SendMessageAsync("Error occured, most likely invalid parameters or insufficient permissions.").ConfigureAwait(false); + await channel.SendMessageAsync("Error occured, most likely invalid parameters or insufficient permissions.").ConfigureAwait(false); } } @@ -205,11 +205,11 @@ namespace NadekoBot.Modules.Administration { await channel.Guild.AddBanAsync(user, 7).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync("Banned user " + user.Username + " Id: " + user.Id).ConfigureAwait(false); + await channel.SendMessageAsync("Banned user " + user.Username + " Id: " + user.Id).ConfigureAwait(false); } catch { - await imsg.Channel.SendMessageAsync("Error. Most likely I don't have sufficient permissions.").ConfigureAwait(false); + await channel.SendMessageAsync("Error. Most likely I don't have sufficient permissions.").ConfigureAwait(false); } } @@ -231,11 +231,11 @@ namespace NadekoBot.Modules.Administration await channel.Guild.AddBanAsync(user, 7).ConfigureAwait(false); await channel.Guild.RemoveBanAsync(user).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync("Soft-Banned user " + user.Username + " Id: " + user.Id).ConfigureAwait(false); + await channel.SendMessageAsync("Soft-Banned user " + user.Username + " Id: " + user.Id).ConfigureAwait(false); } catch { - await imsg.Channel.SendMessageAsync("Error. Most likely I don't have sufficient permissions.").ConfigureAwait(false); + await channel.SendMessageAsync("Error. Most likely I don't have sufficient permissions.").ConfigureAwait(false); } } @@ -247,7 +247,7 @@ namespace NadekoBot.Modules.Administration if (user == null) { - await imsg.Channel.SendMessageAsync("User not found.").ConfigureAwait(false); + await channel.SendMessageAsync("User not found.").ConfigureAwait(false); return; } if (!string.IsNullOrWhiteSpace(msg)) @@ -259,11 +259,11 @@ namespace NadekoBot.Modules.Administration try { await user.KickAsync().ConfigureAwait(false); - await imsg.Channel.SendMessageAsync("Kicked user " + user.Username + " Id: " + user.Id).ConfigureAwait(false); + await channel.SendMessageAsync("Kicked user " + user.Username + " Id: " + user.Id).ConfigureAwait(false); } catch { - await imsg.Channel.SendMessageAsync("Error. Most likely I don't have sufficient permissions.").ConfigureAwait(false); + await channel.SendMessageAsync("Error. Most likely I don't have sufficient permissions.").ConfigureAwait(false); } } @@ -282,11 +282,11 @@ namespace NadekoBot.Modules.Administration { await u.ModifyAsync(usr => usr.Mute = true).ConfigureAwait(false); } - await imsg.Channel.SendMessageAsync("Mute successful").ConfigureAwait(false); + await channel.SendMessageAsync("Mute successful").ConfigureAwait(false); } catch { - await imsg.Channel.SendMessageAsync("I most likely don't have the permission necessary for that.").ConfigureAwait(false); + await channel.SendMessageAsync("I most likely don't have the permission necessary for that.").ConfigureAwait(false); } } @@ -305,11 +305,11 @@ namespace NadekoBot.Modules.Administration { await u.ModifyAsync(usr => usr.Mute = false).ConfigureAwait(false); } - await imsg.Channel.SendMessageAsync("Unmute successful").ConfigureAwait(false); + await channel.SendMessageAsync("Unmute successful").ConfigureAwait(false); } catch { - await imsg.Channel.SendMessageAsync("I most likely don't have the permission necessary for that.").ConfigureAwait(false); + await channel.SendMessageAsync("I most likely don't have the permission necessary for that.").ConfigureAwait(false); } } @@ -328,11 +328,11 @@ namespace NadekoBot.Modules.Administration { await u.ModifyAsync(usr=>usr.Deaf = true).ConfigureAwait(false); } - await imsg.Channel.SendMessageAsync("Deafen successful").ConfigureAwait(false); + await channel.SendMessageAsync("Deafen successful").ConfigureAwait(false); } catch { - await imsg.Channel.SendMessageAsync("I most likely don't have the permission necessary for that.").ConfigureAwait(false); + await channel.SendMessageAsync("I most likely don't have the permission necessary for that.").ConfigureAwait(false); } } @@ -351,11 +351,11 @@ namespace NadekoBot.Modules.Administration { await u.ModifyAsync(usr=> usr.Deaf = false).ConfigureAwait(false); } - await imsg.Channel.SendMessageAsync("Undeafen successful").ConfigureAwait(false); + await channel.SendMessageAsync("Undeafen successful").ConfigureAwait(false); } catch { - await imsg.Channel.SendMessageAsync("I most likely don't have the permission necessary for that.").ConfigureAwait(false); + await channel.SendMessageAsync("I most likely don't have the permission necessary for that.").ConfigureAwait(false); } } @@ -365,7 +365,7 @@ namespace NadekoBot.Modules.Administration public async Task DelVoiChanl(IMessage imsg, [Remainder] IVoiceChannel channel) { await channel.DeleteAsync().ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Removed channel **{channel.Name}**.").ConfigureAwait(false); + await channel.SendMessageAsync($"Removed channel **{channel.Name}**.").ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -376,7 +376,7 @@ namespace NadekoBot.Modules.Administration var channel = imsg.Channel as ITextChannel; //todo actually print info about created channel await channel.Guild.CreateVoiceChannelAsync(channelName).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Created voice channel **{channelName}**.").ConfigureAwait(false); + await channel.SendMessageAsync($"Created voice channel **{channelName}**.").ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -385,7 +385,7 @@ namespace NadekoBot.Modules.Administration public async Task DelTxtChanl(IMessage imsg, [Remainder] ITextChannel channel) { await channel.DeleteAsync().ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Removed text channel **{channel.Name}**.").ConfigureAwait(false); + await channel.SendMessageAsync($"Removed text channel **{channel.Name}**.").ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -396,7 +396,7 @@ namespace NadekoBot.Modules.Administration var channel = imsg.Channel as ITextChannel; //todo actually print info about created channel var txtCh = await channel.Guild.CreateTextChannelAsync(channelName).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Added text channel **{channelName}**.").ConfigureAwait(false); + await channel.SendMessageAsync($"Added text channel **{channelName}**.").ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -408,7 +408,7 @@ namespace NadekoBot.Modules.Administration topic = topic ?? ""; await (channel as ITextChannel).ModifyAsync(c => c.Topic = topic); //await (channel).ModifyAsync(c => c).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync(":ok: **New channel topic set.**").ConfigureAwait(false); + await channel.SendMessageAsync(":ok: **New channel topic set.**").ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -419,7 +419,7 @@ namespace NadekoBot.Modules.Administration var channel = imsg.Channel as ITextChannel; await channel.ModifyAsync(c => c.Name = name).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync(":ok: **New channel name set.**").ConfigureAwait(false); + await channel.SendMessageAsync(":ok: **New channel name set.**").ConfigureAwait(false); } @@ -471,7 +471,7 @@ namespace NadekoBot.Modules.Administration //{ // var channel = imsg.Channel as ITextChannel; - // await imsg.Channel.SendMessageAsync("`Shutting down.`").ConfigureAwait(false); + // await channel.SendMessageAsync("`Shutting down.`").ConfigureAwait(false); // await Task.Delay(2000).ConfigureAwait(false); // Environment.Exit(0); //} @@ -501,7 +501,7 @@ namespace NadekoBot.Modules.Administration // await client.CurrentUser.Edit("", avatar: image.ToStream()).ConfigureAwait(false); // // Send confirm. - // await imsg.Channel.SendMessageAsync("New avatar set.").ConfigureAwait(false); + // await channel.SendMessageAsync("New avatar set.").ConfigureAwait(false); //} ////todo owner only @@ -557,7 +557,7 @@ namespace NadekoBot.Modules.Administration // } // else // { - // await imsg.Channel.SendMessageAsync("`Invalid format.`"); + // await channel.SendMessageAsync("`Invalid format.`"); // } //} @@ -579,7 +579,7 @@ namespace NadekoBot.Modules.Administration // UserName = donator.Name, // UserId = (long)donator.Id // }); - // imsg.Channel.SendMessageAsync("Successfuly added a new donator. πŸ‘‘").ConfigureAwait(false); + // channel.SendMessageAsync("Successfuly added a new donator. πŸ‘‘").ConfigureAwait(false); // } // catch { } @@ -594,10 +594,10 @@ namespace NadekoBot.Modules.Administration // foreach (var ch in (await _client.GetGuildsAsync().ConfigureAwait(false)).Select(async g => await g.GetDefaultChannelAsync().ConfigureAwait(false))) // { - // await imsg.Channel.SendMessageAsync(message).ConfigureAwait(false); + // await channel.SendMessageAsync(message).ConfigureAwait(false); // } - // await imsg.Channel.SendMessageAsync(":ok:").ConfigureAwait(false); + // await channel.SendMessageAsync(":ok:").ConfigureAwait(false); //} ////todo owner only @@ -669,7 +669,7 @@ namespace NadekoBot.Modules.Administration // var donatorsOrdered = rows.OrderByDescending(d => d.Amount); // string str = $"**Thanks to the people listed below for making this project happen!**\n"; - // await imsg.Channel.SendMessageAsync(str + string.Join("⭐", donatorsOrdered.Select(d => d.UserName))).ConfigureAwait(false); + // await channel.SendMessageAsync(str + string.Join("⭐", donatorsOrdered.Select(d => d.UserName))).ConfigureAwait(false); //} } } diff --git a/src/NadekoBot/Modules/Administration/Commands/AutoAssignRole.cs b/src/NadekoBot/Modules/Administration/Commands/AutoAssignRole.cs index cddc115c..f9100e5c 100644 --- a/src/NadekoBot/Modules/Administration/Commands/AutoAssignRole.cs +++ b/src/NadekoBot/Modules/Administration/Commands/AutoAssignRole.cs @@ -41,12 +41,12 @@ namespace NadekoBot.Modules.Administration.Commands // { // config.AutoAssignedRole = 0; - // await imsg.Channel.SendMessageAsync("`Auto assign role on user join is now disabled.`").ConfigureAwait(false); + // await channel.SendMessageAsync("`Auto assign role on user join is now disabled.`").ConfigureAwait(false); // return; // } // config.AutoAssignedRole = role.Id; - // await imsg.Channel.SendMessageAsync("`Auto assigned role is set.`").ConfigureAwait(false); + // await channel.SendMessageAsync("`Auto assigned role is set.`").ConfigureAwait(false); //} } } diff --git a/src/NadekoBot/Modules/Administration/Commands/CrossServerTextChannel.cs b/src/NadekoBot/Modules/Administration/Commands/CrossServerTextChannel.cs index d502d505..0e0bade4 100644 --- a/src/NadekoBot/Modules/Administration/Commands/CrossServerTextChannel.cs +++ b/src/NadekoBot/Modules/Administration/Commands/CrossServerTextChannel.cs @@ -92,7 +92,7 @@ // if (!Subscribers.TryGetValue(token, out set)) // return; // set.Add(e.Channel); -// await imsg.Channel.SendMessageAsync(":ok:").ConfigureAwait(false); +// await channel.SendMessageAsync(":ok:").ConfigureAwait(false); // }); // cgb.CreateCommand(Module.Prefix + "lcsc") @@ -104,7 +104,7 @@ // { // subscriber.Value.Remove(e.Channel); // } -// await imsg.Channel.SendMessageAsync(":ok:").ConfigureAwait(false); +// await channel.SendMessageAsync(":ok:").ConfigureAwait(false); // }); // } // } diff --git a/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs b/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs index 2c11a6ac..83f301ae 100644 --- a/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs +++ b/src/NadekoBot/Modules/Administration/Commands/LogCommand.cs @@ -44,7 +44,7 @@ // var usr = e.Message.MentionedUsers.FirstOrDefault(u => u != e.User); // if (usr?.Status != UserStatus.Offline) // return; -// await imsg.Channel.SendMessageAsync($"User `{usr.Name}` is offline. PM sent.").ConfigureAwait(false); +// await channel.SendMessageAsync($"User `{usr.Name}` is offline. PM sent.").ConfigureAwait(false); // await usr.SendMessage( // $"User `{e.User.Name}` mentioned you on " + // $"`{e.Server.Name}` server while you were offline.\n" + @@ -385,10 +385,10 @@ // specificConfig.SendPrivateMessageOnMention = // !specificConfig.SendPrivateMessageOnMention; // if (specificConfig.SendPrivateMessageOnMention) -// await imsg.Channel.SendMessageAsync(":ok: I will send private messages " + +// await channel.SendMessageAsync(":ok: I will send private messages " + // "to mentioned offline users.").ConfigureAwait(false); // else -// await imsg.Channel.SendMessageAsync(":ok: I won't send private messages " + +// await channel.SendMessageAsync(":ok: I won't send private messages " + // "to mentioned offline users anymore.").ConfigureAwait(false); // }); @@ -402,7 +402,7 @@ // if (chId == null) // { // SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel = e.Channel.Id; -// await imsg.Channel.SendMessageAsync($"❗**I WILL BEGIN LOGGING SERVER ACTIVITY IN THIS CHANNEL**❗").ConfigureAwait(false); +// await channel.SendMessageAsync($"❗**I WILL BEGIN LOGGING SERVER ACTIVITY IN THIS CHANNEL**❗").ConfigureAwait(false); // return; // } // Channel ch; @@ -410,7 +410,7 @@ // return; // SpecificConfigurations.Default.Of(e.Server.Id).LogServerChannel = null; -// await imsg.Channel.SendMessageAsync($"❗**NO LONGER LOGGING IN {ch.Mention} CHANNEL**❗").ConfigureAwait(false); +// await channel.SendMessageAsync($"❗**NO LONGER LOGGING IN {ch.Mention} CHANNEL**❗").ConfigureAwait(false); // }); @@ -423,12 +423,12 @@ // var config = SpecificConfigurations.Default.Of(e.Server.Id); // if (config.LogserverIgnoreChannels.Remove(e.Channel.Id)) // { -// await imsg.Channel.SendMessageAsync($"`{Prefix}logserver will stop ignoring this channel.`"); +// await channel.SendMessageAsync($"`{Prefix}logserver will stop ignoring this channel.`"); // } // else // { // config.LogserverIgnoreChannels.Add(e.Channel.Id); -// await imsg.Channel.SendMessageAsync($"`{Prefix}logserver will ignore this channel.`"); +// await channel.SendMessageAsync($"`{Prefix}logserver will ignore this channel.`"); // } // }); @@ -441,11 +441,11 @@ // if (chId == null) // { // SpecificConfigurations.Default.Of(e.Server.Id).LogPresenceChannel = e.Channel.Id; -// await imsg.Channel.SendMessageAsync($"**User presence notifications enabled.**").ConfigureAwait(false); +// await channel.SendMessageAsync($"**User presence notifications enabled.**").ConfigureAwait(false); // return; // } // SpecificConfigurations.Default.Of(e.Server.Id).LogPresenceChannel = null; -// await imsg.Channel.SendMessageAsync($"**User presence notifications disabled.**").ConfigureAwait(false); +// await channel.SendMessageAsync($"**User presence notifications disabled.**").ConfigureAwait(false); // }); // cgb.CreateCommand(Module.Prefix + "voicepresence") @@ -462,23 +462,23 @@ // { // config.VoiceChannelLog.TryAdd(voiceChannel.Id, e.Channel.Id); // } -// await imsg.Channel.SendMessageAsync("Started logging user presence for **ALL** voice channels!").ConfigureAwait(false); +// await channel.SendMessageAsync("Started logging user presence for **ALL** voice channels!").ConfigureAwait(false); // return; // } // if (e.User.VoiceChannel == null) // { -// await imsg.Channel.SendMessageAsync("πŸ’’ You are not in a voice channel right now. If you are, please rejoin it.").ConfigureAwait(false); +// await channel.SendMessageAsync("πŸ’’ You are not in a voice channel right now. If you are, please rejoin it.").ConfigureAwait(false); // return; // } // ulong throwaway; // if (!config.VoiceChannelLog.TryRemove(e.User.VoiceChannel.Id, out throwaway)) // { // config.VoiceChannelLog.TryAdd(e.User.VoiceChannel.Id, e.Channel.Id); -// await imsg.Channel.SendMessageAsync($"`Logging user updates for` {e.User.VoiceChannel.Mention} `voice channel.`").ConfigureAwait(false); +// await channel.SendMessageAsync($"`Logging user updates for` {e.User.VoiceChannel.Mention} `voice channel.`").ConfigureAwait(false); // } // else -// await imsg.Channel.SendMessageAsync($"`Stopped logging user updates for` {e.User.VoiceChannel.Mention} `voice channel.`").ConfigureAwait(false); +// await channel.SendMessageAsync($"`Stopped logging user updates for` {e.User.VoiceChannel.Mention} `voice channel.`").ConfigureAwait(false); // }); // } // } diff --git a/src/NadekoBot/Modules/Administration/Commands/MessageRepeater.cs b/src/NadekoBot/Modules/Administration/Commands/MessageRepeater.cs index 7ba42c73..f85700f4 100644 --- a/src/NadekoBot/Modules/Administration/Commands/MessageRepeater.cs +++ b/src/NadekoBot/Modules/Administration/Commands/MessageRepeater.cs @@ -65,7 +65,7 @@ // Repeater rep; // if (!repeaters.TryGetValue(e.Server, out rep)) // { -// await imsg.Channel.SendMessageAsync("`No repeating message found on this server.`"); +// await channel.SendMessageAsync("`No repeating message found on this server.`"); // return; // } @@ -91,13 +91,13 @@ // if (!repeaters.TryRemove(e.Server, out rep)) // return; // rep.MessageTimer.Stop(); -// await imsg.Channel.SendMessageAsync("Repeating disabled").ConfigureAwait(false); +// await channel.SendMessageAsync("Repeating disabled").ConfigureAwait(false); // return; // } // int minutes; // if (!int.TryParse(minutesStr, out minutes) || minutes < 1 || minutes > 1440) // { -// await imsg.Channel.SendMessageAsync("Invalid value").ConfigureAwait(false); +// await channel.SendMessageAsync("Invalid value").ConfigureAwait(false); // return; // } @@ -118,7 +118,7 @@ // repeater.MessageTimer.Stop(); // repeater.MessageTimer.Start(); -// await imsg.Channel.SendMessageAsync(String.Format("πŸ‘Œ Repeating `{0}` every " + +// await channel.SendMessageAsync(String.Format("πŸ‘Œ Repeating `{0}` every " + // "**{1}** minutes on {2} channel.", // repeater.RepeatingMessage, minutes, repeater.RepeatingChannel)) // .ConfigureAwait(false); diff --git a/src/NadekoBot/Modules/Administration/Commands/PlayingRotate.cs b/src/NadekoBot/Modules/Administration/Commands/PlayingRotate.cs index 4f20c78d..362d691b 100644 --- a/src/NadekoBot/Modules/Administration/Commands/PlayingRotate.cs +++ b/src/NadekoBot/Modules/Administration/Commands/PlayingRotate.cs @@ -90,7 +90,7 @@ // finally { // playingPlaceholderLock.Release(); // } -// await imsg.Channel.SendMessageAsync($"❗`Rotating playing status has been {(timer.Enabled ? "enabled" : "disabled")}.`").ConfigureAwait(false); +// await channel.SendMessageAsync($"❗`Rotating playing status has been {(timer.Enabled ? "enabled" : "disabled")}.`").ConfigureAwait(false); // }; // internal override void Init(CommandGroupBuilder cgb) @@ -122,7 +122,7 @@ // { // playingPlaceholderLock.Release(); // } -// await imsg.Channel.SendMessageAsync("πŸ†— `Added a new playing string.`").ConfigureAwait(false); +// await channel.SendMessageAsync("πŸ†— `Added a new playing string.`").ConfigureAwait(false); // }); // cgb.CreateCommand(Module.Prefix + "listplaying") @@ -132,14 +132,14 @@ // .Do(async e => // { // if (NadekoBot.Config.RotatingStatuses.Count == 0) -// await imsg.Channel.SendMessageAsync("`There are no playing strings. " + +// await channel.SendMessageAsync("`There are no playing strings. " + // "Add some with .addplaying [text] command.`").ConfigureAwait(false); // var sb = new StringBuilder(); // for (var i = 0; i < NadekoBot.Config.RotatingStatuses.Count; i++) // { // sb.AppendLine($"`{i + 1}.` {NadekoBot.Config.RotatingStatuses[i]}"); // } -// await imsg.Channel.SendMessageAsync(sb.ToString()).ConfigureAwait(false); +// await channel.SendMessageAsync(sb.ToString()).ConfigureAwait(false); // }); // cgb.CreateCommand(Module.Prefix + "removeplaying") @@ -161,7 +161,7 @@ // await ConfigHandler.SaveConfig().ConfigureAwait(false); // } // finally { playingPlaceholderLock.Release(); } -// await imsg.Channel.SendMessageAsync($"πŸ†— `Removed playing string #{num}`({str})").ConfigureAwait(false); +// await channel.SendMessageAsync($"πŸ†— `Removed playing string #{num}`({str})").ConfigureAwait(false); // }); // } // } diff --git a/src/NadekoBot/Modules/Administration/Commands/RatelimitCommand.cs b/src/NadekoBot/Modules/Administration/Commands/RatelimitCommand.cs index e807f49c..b0d5ef84 100644 --- a/src/NadekoBot/Modules/Administration/Commands/RatelimitCommand.cs +++ b/src/NadekoBot/Modules/Administration/Commands/RatelimitCommand.cs @@ -60,12 +60,12 @@ namespace NadekoBot.Modules.Administration.Commands ConcurrentDictionary throwaway; if (RatelimitingChannels.TryRemove(channel.Id, out throwaway)) { - await imsg.Channel.SendMessageAsync("Slow mode disabled.").ConfigureAwait(false); + await channel.SendMessageAsync("Slow mode disabled.").ConfigureAwait(false); return; } if (RatelimitingChannels.TryAdd(channel.Id, new ConcurrentDictionary())) { - await imsg.Channel.SendMessageAsync("Slow mode initiated. " + + await channel.SendMessageAsync("Slow mode initiated. " + "Users can't send more than 1 message every 5 seconds.") .ConfigureAwait(false); } diff --git a/src/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs b/src/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs index 8c7d3bf3..3ae023d9 100644 --- a/src/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs +++ b/src/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs @@ -40,7 +40,7 @@ // msg.AppendLine($":ok:Role **{role.Name}** added to the list."); // } // } -// await imsg.Channel.SendMessageAsync(msg.ToString()).ConfigureAwait(false); +// await channel.SendMessageAsync(msg.ToString()).ConfigureAwait(false); // }); // cgb.CreateCommand(Module.Prefix + "rsar") @@ -55,17 +55,17 @@ // var role = e.Server.FindRoles(roleName).FirstOrDefault(); // if (role == null) // { -// await imsg.Channel.SendMessageAsync(":anger:That role does not exist.").ConfigureAwait(false); +// await channel.SendMessageAsync(":anger:That role does not exist.").ConfigureAwait(false); // return; // } // var config = SpecificConfigurations.Default.Of(e.Server.Id); // if (!config.ListOfSelfAssignableRoles.Contains(role.Id)) // { -// await imsg.Channel.SendMessageAsync(":anger:That role is not self-assignable.").ConfigureAwait(false); +// await channel.SendMessageAsync(":anger:That role is not self-assignable.").ConfigureAwait(false); // return; // } // config.ListOfSelfAssignableRoles.Remove(role.Id); -// await imsg.Channel.SendMessageAsync($":ok:**{role.Name}** has been removed from the list of self-assignable roles").ConfigureAwait(false); +// await channel.SendMessageAsync($":ok:**{role.Name}** has been removed from the list of self-assignable roles").ConfigureAwait(false); // }); // cgb.CreateCommand(Module.Prefix + "lsar") @@ -93,7 +93,7 @@ // { // config.ListOfSelfAssignableRoles.Remove(id); // } -// await imsg.Channel.SendMessageAsync(msg.ToString()).ConfigureAwait(false); +// await channel.SendMessageAsync(msg.ToString()).ConfigureAwait(false); // }); @@ -106,7 +106,7 @@ // var config = SpecificConfigurations.Default.Of(e.Server.Id); // config.ExclusiveSelfAssignedRoles = !config.ExclusiveSelfAssignedRoles; // string exl = config.ExclusiveSelfAssignedRoles ? "exclusive" : "not exclusive"; -// await imsg.Channel.SendMessageAsync("Self assigned roles are now " + exl); +// await channel.SendMessageAsync("Self assigned roles are now " + exl); // }); // cgb.CreateCommand(Module.Prefix + "iam") @@ -122,24 +122,24 @@ // var role = e.Server.FindRoles(roleName).FirstOrDefault(); // if (role == null) // { -// await imsg.Channel.SendMessageAsync(":anger:That role does not exist.").ConfigureAwait(false); +// await channel.SendMessageAsync(":anger:That role does not exist.").ConfigureAwait(false); // return; // } // var config = SpecificConfigurations.Default.Of(e.Server.Id); // if (!config.ListOfSelfAssignableRoles.Contains(role.Id)) // { -// await imsg.Channel.SendMessageAsync(":anger:That role is not self-assignable.").ConfigureAwait(false); +// await channel.SendMessageAsync(":anger:That role is not self-assignable.").ConfigureAwait(false); // return; // } // if (e.User.HasRole(role)) // { -// await imsg.Channel.SendMessageAsync($":anger:You already have {role.Name} role.").ConfigureAwait(false); +// await channel.SendMessageAsync($":anger:You already have {role.Name} role.").ConfigureAwait(false); // return; // } // var sameRoles = e.User.Roles.Where(r => config.ListOfSelfAssignableRoles.Contains(r.Id)); // if (config.ExclusiveSelfAssignedRoles && sameRoles.Any()) // { -// await imsg.Channel.SendMessageAsync($":anger:You already have {sameRoles.FirstOrDefault().Name} role.").ConfigureAwait(false); +// await channel.SendMessageAsync($":anger:You already have {sameRoles.FirstOrDefault().Name} role.").ConfigureAwait(false); // return; // } // try @@ -151,10 +151,10 @@ // } // catch (Exception ex) // { -// await imsg.Channel.SendMessageAsync($":anger:`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.SendMessageAsync($":anger:`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); // return; // } -// var msg = await imsg.Channel.SendMessageAsync($":ok:You now have {role.Name} role.").ConfigureAwait(false); +// var msg = await channel.SendMessageAsync($":ok:You now have {role.Name} role.").ConfigureAwait(false); // await Task.Delay(3000).ConfigureAwait(false); // await msg.Delete().ConfigureAwait(false); // try @@ -178,22 +178,22 @@ // var role = e.Server.FindRoles(roleName).FirstOrDefault(); // if (role == null) // { -// await imsg.Channel.SendMessageAsync(":anger:That role does not exist.").ConfigureAwait(false); +// await channel.SendMessageAsync(":anger:That role does not exist.").ConfigureAwait(false); // return; // } // var config = SpecificConfigurations.Default.Of(e.Server.Id); // if (!config.ListOfSelfAssignableRoles.Contains(role.Id)) // { -// await imsg.Channel.SendMessageAsync(":anger:That role is not self-assignable.").ConfigureAwait(false); +// await channel.SendMessageAsync(":anger:That role is not self-assignable.").ConfigureAwait(false); // return; // } // if (!e.User.HasRole(role)) // { -// await imsg.Channel.SendMessageAsync($":anger:You don't have {role.Name} role.").ConfigureAwait(false); +// await channel.SendMessageAsync($":anger:You don't have {role.Name} role.").ConfigureAwait(false); // return; // } // await e.User.RemoveRoles(role).ConfigureAwait(false); -// var msg = await imsg.Channel.SendMessageAsync($":ok:Successfuly removed {role.Name} role from you.").ConfigureAwait(false); +// var msg = await channel.SendMessageAsync($":ok:Successfuly removed {role.Name} role from you.").ConfigureAwait(false); // await Task.Delay(3000).ConfigureAwait(false); // await msg.Delete().ConfigureAwait(false); // try diff --git a/src/NadekoBot/Modules/Administration/Commands/SelfCommands.cs b/src/NadekoBot/Modules/Administration/Commands/SelfCommands.cs index 96c2a914..7eb2bb04 100644 --- a/src/NadekoBot/Modules/Administration/Commands/SelfCommands.cs +++ b/src/NadekoBot/Modules/Administration/Commands/SelfCommands.cs @@ -31,7 +31,7 @@ // if (server == null) // { -// await imsg.Channel.SendMessageAsync("Cannot find that server").ConfigureAwait(false); +// await channel.SendMessageAsync("Cannot find that server").ConfigureAwait(false); // return; // } // if (server.OwnerId != _client.GetCurrentUser().Id) diff --git a/src/NadekoBot/Modules/Administration/Commands/ServerGreetCommand.cs b/src/NadekoBot/Modules/Administration/Commands/ServerGreetCommand.cs index 97451d54..d8f745c9 100644 --- a/src/NadekoBot/Modules/Administration/Commands/ServerGreetCommand.cs +++ b/src/NadekoBot/Modules/Administration/Commands/ServerGreetCommand.cs @@ -215,9 +215,9 @@ // var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id)); // if (ann.ToggleDelete()) -// await imsg.Channel.SendMessageAsync("`Automatic deletion of greet and bye messages has been enabled.`").ConfigureAwait(false); +// await channel.SendMessageAsync("`Automatic deletion of greet and bye messages has been enabled.`").ConfigureAwait(false); // else -// await imsg.Channel.SendMessageAsync("`Automatic deletion of greet and bye messages has been disabled.`").ConfigureAwait(false); +// await channel.SendMessageAsync("`Automatic deletion of greet and bye messages has been disabled.`").ConfigureAwait(false); // }); // cgb.CreateCommand(Module.Prefix + "greet") @@ -228,9 +228,9 @@ // var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id)); // if (ann.ToggleGreet(e.Channel.Id)) -// await imsg.Channel.SendMessageAsync("Greet announcements enabled on this channel.").ConfigureAwait(false); +// await channel.SendMessageAsync("Greet announcements enabled on this channel.").ConfigureAwait(false); // else -// await imsg.Channel.SendMessageAsync("Greet announcements disabled.").ConfigureAwait(false); +// await channel.SendMessageAsync("Greet announcements disabled.").ConfigureAwait(false); // }); // cgb.CreateCommand(Module.Prefix + "greetmsg") @@ -242,15 +242,15 @@ // var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id)); // if (string.IsNullOrWhiteSpace(e.GetArg("msg"))) // { -// await imsg.Channel.SendMessageAsync("`Current greet message:` " + ann.GreetText); +// await channel.SendMessageAsync("`Current greet message:` " + ann.GreetText); // return; // } // ann.GreetText = e.GetArg("msg"); -// await imsg.Channel.SendMessageAsync("New greet message set.").ConfigureAwait(false); +// await channel.SendMessageAsync("New greet message set.").ConfigureAwait(false); // if (!ann.Greet) -// await imsg.Channel.SendMessageAsync("Enable greet messsages by typing `.greet`").ConfigureAwait(false); +// await channel.SendMessageAsync("Enable greet messsages by typing `.greet`").ConfigureAwait(false); // }); // cgb.CreateCommand(Module.Prefix + "bye") @@ -261,9 +261,9 @@ // var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id)); // if (ann.ToggleBye(e.Channel.Id)) -// await imsg.Channel.SendMessageAsync("Bye announcements enabled on this channel.").ConfigureAwait(false); +// await channel.SendMessageAsync("Bye announcements enabled on this channel.").ConfigureAwait(false); // else -// await imsg.Channel.SendMessageAsync("Bye announcements disabled.").ConfigureAwait(false); +// await channel.SendMessageAsync("Bye announcements disabled.").ConfigureAwait(false); // }); // cgb.CreateCommand(Module.Prefix + "byemsg") @@ -275,14 +275,14 @@ // var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id)); // if (string.IsNullOrWhiteSpace(e.GetArg("msg"))) // { -// await imsg.Channel.SendMessageAsync("`Current bye message:` " + ann.ByeText); +// await channel.SendMessageAsync("`Current bye message:` " + ann.ByeText); // return; // } // ann.ByeText = e.GetArg("msg"); -// await imsg.Channel.SendMessageAsync("New bye message set.").ConfigureAwait(false); +// await channel.SendMessageAsync("New bye message set.").ConfigureAwait(false); // if (!ann.Bye) -// await imsg.Channel.SendMessageAsync("Enable bye messsages by typing `.bye`.").ConfigureAwait(false); +// await channel.SendMessageAsync("Enable bye messsages by typing `.bye`.").ConfigureAwait(false); // }); // cgb.CreateCommand(Module.Prefix + "byepm") @@ -294,11 +294,11 @@ // if (ann.ToggleByePM()) -// await imsg.Channel.SendMessageAsync("Bye messages will be sent in a PM from now on.\n ⚠ Keep in mind this might fail if the user and the bot have no common servers after the user leaves.").ConfigureAwait(false); +// await channel.SendMessageAsync("Bye messages will be sent in a PM from now on.\n ⚠ Keep in mind this might fail if the user and the bot have no common servers after the user leaves.").ConfigureAwait(false); // else -// await imsg.Channel.SendMessageAsync("Bye messages will be sent in a bound channel from now on.").ConfigureAwait(false); +// await channel.SendMessageAsync("Bye messages will be sent in a bound channel from now on.").ConfigureAwait(false); // if (!ann.Bye) -// await imsg.Channel.SendMessageAsync("Enable bye messsages by typing `.bye`, and set the bye message using `.byemsg`").ConfigureAwait(false); +// await channel.SendMessageAsync("Enable bye messsages by typing `.bye`, and set the bye message using `.byemsg`").ConfigureAwait(false); // }); // cgb.CreateCommand(Module.Prefix + "greetpm") @@ -310,11 +310,11 @@ // var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id)); // if (ann.ToggleGreetPM()) -// await imsg.Channel.SendMessageAsync("Greet messages will be sent in a PM from now on.").ConfigureAwait(false); +// await channel.SendMessageAsync("Greet messages will be sent in a PM from now on.").ConfigureAwait(false); // else -// await imsg.Channel.SendMessageAsync("Greet messages will be sent in a bound channel from now on.").ConfigureAwait(false); +// await channel.SendMessageAsync("Greet messages will be sent in a bound channel from now on.").ConfigureAwait(false); // if (!ann.Greet) -// await imsg.Channel.SendMessageAsync("Enable greet messsages by typing `.greet`, and set the greet message using `.greetmsg`").ConfigureAwait(false); +// await channel.SendMessageAsync("Enable greet messsages by typing `.greet`, and set the greet message using `.greetmsg`").ConfigureAwait(false); // }); // } // } diff --git a/src/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommand.cs b/src/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommand.cs index 331f80b2..7643791f 100644 --- a/src/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommand.cs +++ b/src/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommand.cs @@ -97,7 +97,7 @@ // { // if (!e.Server.CurrentUser.ServerPermissions.ManageChannels) // { -// await imsg.Channel.SendMessageAsync("`I have insufficient permission to do that.`"); +// await channel.SendMessageAsync("`I have insufficient permission to do that.`"); // return; // } @@ -116,7 +116,7 @@ // await Task.Delay(500); // } -// await imsg.Channel.SendMessageAsync("`Done.`"); +// await channel.SendMessageAsync("`Done.`"); // }); // cgb.CreateCommand(Module.Prefix + "voice+text") @@ -141,24 +141,24 @@ // } // catch // { -// await imsg.Channel.SendMessageAsync( +// await channel.SendMessageAsync( // ":anger: Error: Most likely i don't have permissions to do this.") // .ConfigureAwait(false); // return; // } // } -// await imsg.Channel.SendMessageAsync("Successfuly removed voice + text feature.").ConfigureAwait(false); +// await channel.SendMessageAsync("Successfuly removed voice + text feature.").ConfigureAwait(false); // return; // } // config.VoicePlusTextEnabled = true; -// await imsg.Channel.SendMessageAsync("Successfuly enabled voice + text feature. " + +// await channel.SendMessageAsync("Successfuly enabled voice + text feature. " + // "**Make sure the bot has manage roles and manage channels permissions**") // .ConfigureAwait(false); // } // catch (Exception ex) // { -// await imsg.Channel.SendMessageAsync(ex.ToString()).ConfigureAwait(false); +// await channel.SendMessageAsync(ex.ToString()).ConfigureAwait(false); // } // }); // } diff --git a/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs b/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs index 23975f05..2368480a 100644 --- a/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs +++ b/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs @@ -49,7 +49,7 @@ namespace NadekoBot.Modules.ClashOfClans if (size < 10 || size > 50 || size % 5 != 0) { - await imsg.Channel.SendMessageAsync("πŸ’’πŸ”° Not a Valid war size").ConfigureAwait(false); + await channel.SendMessageAsync("πŸ’’πŸ”° Not a Valid war size").ConfigureAwait(false); return; } List wars; @@ -65,7 +65,7 @@ namespace NadekoBot.Modules.ClashOfClans //cw.Start(); wars.Add(cw); - await imsg.Channel.SendMessageAsync($"β—πŸ”°**CREATED CLAN WAR AGAINST {cw.ShortPrint()}**").ConfigureAwait(false); + await channel.SendMessageAsync($"β—πŸ”°**CREATED CLAN WAR AGAINST {cw.ShortPrint()}**").ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -80,18 +80,18 @@ namespace NadekoBot.Modules.ClashOfClans var warsInfo = GetWarInfo(imsg, num); if (warsInfo == null) { - await imsg.Channel.SendMessageAsync("πŸ’’πŸ”° **That war does not exist.**").ConfigureAwait(false); + await channel.SendMessageAsync("πŸ’’πŸ”° **That war does not exist.**").ConfigureAwait(false); return; } var war = warsInfo.Item1[warsInfo.Item2]; try { war.Start(); - await imsg.Channel.SendMessageAsync($"πŸ”°**STARTED WAR AGAINST {war.ShortPrint()}**").ConfigureAwait(false); + await channel.SendMessageAsync($"πŸ”°**STARTED WAR AGAINST {war.ShortPrint()}**").ConfigureAwait(false); } catch { - await imsg.Channel.SendMessageAsync($"πŸ”°**WAR AGAINST {war.ShortPrint()} HAS ALREADY STARTED**").ConfigureAwait(false); + await channel.SendMessageAsync($"πŸ”°**WAR AGAINST {war.ShortPrint()} HAS ALREADY STARTED**").ConfigureAwait(false); } } @@ -109,7 +109,7 @@ namespace NadekoBot.Modules.ClashOfClans ClashWars.TryGetValue(channel.Guild.Id, out wars); if (wars == null || wars.Count == 0) { - await imsg.Channel.SendMessageAsync("πŸ”° **No active wars.**").ConfigureAwait(false); + await channel.SendMessageAsync("πŸ”° **No active wars.**").ConfigureAwait(false); return; } @@ -122,7 +122,7 @@ namespace NadekoBot.Modules.ClashOfClans sb.AppendLine($"\t\t`Size:` **{wars[i].Size} v {wars[i].Size}**"); sb.AppendLine("**-------------------------**"); } - await imsg.Channel.SendMessageAsync(sb.ToString()).ConfigureAwait(false); + await channel.SendMessageAsync(sb.ToString()).ConfigureAwait(false); return; } @@ -132,10 +132,10 @@ namespace NadekoBot.Modules.ClashOfClans var warsInfo = GetWarInfo(imsg, num); if (warsInfo == null) { - await imsg.Channel.SendMessageAsync("πŸ’’πŸ”° **That war does not exist.**").ConfigureAwait(false); + await channel.SendMessageAsync("πŸ’’πŸ”° **That war does not exist.**").ConfigureAwait(false); return; } - await imsg.Channel.SendMessageAsync(warsInfo.Item1[warsInfo.Item2].ToString()).ConfigureAwait(false); + await channel.SendMessageAsync(warsInfo.Item1[warsInfo.Item2].ToString()).ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -146,7 +146,7 @@ namespace NadekoBot.Modules.ClashOfClans var warsInfo = GetWarInfo(imsg, number); if (warsInfo == null || warsInfo.Item1.Count == 0) { - await imsg.Channel.SendMessageAsync("πŸ’’πŸ”° **That war does not exist.**").ConfigureAwait(false); + await channel.SendMessageAsync("πŸ’’πŸ”° **That war does not exist.**").ConfigureAwait(false); return; } var usr = @@ -157,11 +157,11 @@ namespace NadekoBot.Modules.ClashOfClans { var war = warsInfo.Item1[warsInfo.Item2]; war.Call(usr, baseNumber - 1); - await imsg.Channel.SendMessageAsync($"πŸ”°**{usr}** claimed a base #{baseNumber} for a war against {war.ShortPrint()}").ConfigureAwait(false); + await channel.SendMessageAsync($"πŸ”°**{usr}** claimed a base #{baseNumber} for a war against {war.ShortPrint()}").ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync($"πŸ’’πŸ”° {ex.Message}").ConfigureAwait(false); + await channel.SendMessageAsync($"πŸ’’πŸ”° {ex.Message}").ConfigureAwait(false); } } @@ -198,11 +198,11 @@ namespace NadekoBot.Modules.ClashOfClans var warsInfo = GetWarInfo(imsg,number); if (warsInfo == null) { - await imsg.Channel.SendMessageAsync("πŸ’’πŸ”° That war does not exist.").ConfigureAwait(false); + await channel.SendMessageAsync("πŸ’’πŸ”° That war does not exist.").ConfigureAwait(false); return; } warsInfo.Item1[warsInfo.Item2].End(); - await imsg.Channel.SendMessageAsync($"β—πŸ”°**War against {warsInfo.Item1[warsInfo.Item2].ShortPrint()} ended.**").ConfigureAwait(false); + await channel.SendMessageAsync($"β—πŸ”°**War against {warsInfo.Item1[warsInfo.Item2].ShortPrint()} ended.**").ConfigureAwait(false); var size = warsInfo.Item1[warsInfo.Item2].Size; warsInfo.Item1.RemoveAt(warsInfo.Item2); @@ -217,7 +217,7 @@ namespace NadekoBot.Modules.ClashOfClans var warsInfo = GetWarInfo(imsg, number); if (warsInfo == null || warsInfo.Item1.Count == 0) { - await imsg.Channel.SendMessageAsync("πŸ’’πŸ”° **That war does not exist.**").ConfigureAwait(false); + await channel.SendMessageAsync("πŸ’’πŸ”° **That war does not exist.**").ConfigureAwait(false); return; } var usr = @@ -228,11 +228,11 @@ namespace NadekoBot.Modules.ClashOfClans { var war = warsInfo.Item1[warsInfo.Item2]; var baseNumber = war.Uncall(usr); - await imsg.Channel.SendMessageAsync($"πŸ”° @{usr} has **UNCLAIMED** a base #{baseNumber + 1} from a war against {war.ShortPrint()}").ConfigureAwait(false); + await channel.SendMessageAsync($"πŸ”° @{usr} has **UNCLAIMED** a base #{baseNumber + 1} from a war against {war.ShortPrint()}").ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync($"πŸ’’πŸ”° {ex.Message}").ConfigureAwait(false); + await channel.SendMessageAsync($"πŸ’’πŸ”° {ex.Message}").ConfigureAwait(false); } } @@ -242,7 +242,7 @@ namespace NadekoBot.Modules.ClashOfClans var warInfo = GetWarInfo(imsg, number); if (warInfo == null || warInfo.Item1.Count == 0) { - await imsg.Channel.SendMessageAsync("πŸ’’πŸ”° **That war does not exist.**").ConfigureAwait(false); + await channel.SendMessageAsync("πŸ’’πŸ”° **That war does not exist.**").ConfigureAwait(false); return; } var usr = @@ -254,11 +254,11 @@ namespace NadekoBot.Modules.ClashOfClans try { var baseNum = war.FinishClaim(usr, stars); - await imsg.Channel.SendMessageAsync($"β—πŸ”°{imsg.Author.Mention} **DESTROYED** a base #{baseNum + 1} in a war against {war.ShortPrint()}").ConfigureAwait(false); + await channel.SendMessageAsync($"β—πŸ”°{imsg.Author.Mention} **DESTROYED** a base #{baseNum + 1} in a war against {war.ShortPrint()}").ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync($"πŸ’’πŸ”° {ex.Message}").ConfigureAwait(false); + await channel.SendMessageAsync($"πŸ’’πŸ”° {ex.Message}").ConfigureAwait(false); } } diff --git a/src/NadekoBot/Modules/Gambling/Commands/DiceRollCommand.cs b/src/NadekoBot/Modules/Gambling/Commands/DiceRollCommand.cs index 6a34d922..58c9bb84 100644 --- a/src/NadekoBot/Modules/Gambling/Commands/DiceRollCommand.cs +++ b/src/NadekoBot/Modules/Gambling/Commands/DiceRollCommand.cs @@ -78,7 +78,7 @@ namespace NadekoBot.Modules.Gambling arr[i] = r.Next(1, n2 + 1); } var elemCnt = 0; - await imsg.Channel.SendMessageAsync($"`Rolled {n1} {(n1 == 1 ? "die" : "dice")} 1-{n2}.`\n`Result:` " + string.Join(", ", (ordered ? arr.OrderBy(x => x).AsEnumerable() : arr).Select(x => elemCnt++ % 2 == 0 ? $"**{x}**" : x.ToString()))).ConfigureAwait(false); + await channel.SendMessageAsync($"`Rolled {n1} {(n1 == 1 ? "die" : "dice")} 1-{n2}.`\n`Result:` " + string.Join(", ", (ordered ? arr.OrderBy(x => x).AsEnumerable() : arr).Select(x => elemCnt++ % 2 == 0 ? $"**{x}**" : x.ToString()))).ConfigureAwait(false); } return; } @@ -88,7 +88,7 @@ namespace NadekoBot.Modules.Gambling if (num < 1) num = 1; if (num > 30) { - await imsg.Channel.SendMessageAsync("You can roll up to 30 dice at a time.").ConfigureAwait(false); + await channel.SendMessageAsync("You can roll up to 30 dice at a time.").ConfigureAwait(false); num = 30; } var dices = new List(num); @@ -119,12 +119,12 @@ namespace NadekoBot.Modules.Gambling } var bitmap = dices.Merge(); - await imsg.Channel.SendMessageAsync(values.Count + " Dice rolled. Total: **" + values.Sum() + "** Average: **" + (values.Sum() / (1.0f * values.Count)).ToString("N2") + "**").ConfigureAwait(false); + await channel.SendMessageAsync(values.Count + " Dice rolled. Total: **" + values.Sum() + "** Average: **" + (values.Sum() / (1.0f * values.Count)).ToString("N2") + "**").ConfigureAwait(false); await e.Channel.SendFile("dice.png", bitmap.ToStream(ImageFormat.Png)).ConfigureAwait(false); } catch { - await imsg.Channel.SendMessageAsync("Please enter a number of dice to roll.").ConfigureAwait(false); + await channel.SendMessageAsync("Please enter a number of dice to roll.").ConfigureAwait(false); } }; } @@ -151,11 +151,11 @@ namespace NadekoBot.Modules.Gambling rolled = new Random().Next(0, int.Parse(e.GetArg("range")) + 1); } - await imsg.Channel.SendMessageAsync($"{e.User.Mention} rolled **{rolled}**.").ConfigureAwait(false); + await channel.SendMessageAsync($"{e.User.Mention} rolled **{rolled}**.").ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync($":anger: {ex.Message}").ConfigureAwait(false); + await channel.SendMessageAsync($":anger: {ex.Message}").ConfigureAwait(false); } }; } diff --git a/src/NadekoBot/Modules/Gambling/Commands/DrawCommand.cs b/src/NadekoBot/Modules/Gambling/Commands/DrawCommand.cs index c926da48..2d1e2964 100644 --- a/src/NadekoBot/Modules/Gambling/Commands/DrawCommand.cs +++ b/src/NadekoBot/Modules/Gambling/Commands/DrawCommand.cs @@ -41,7 +41,7 @@ namespace NadekoBot.Modules.Gambling return c; }); - await imsg.Channel.SendMessageAsync("Deck reshuffled.").ConfigureAwait(false); + await channel.SendMessageAsync("Deck reshuffled.").ConfigureAwait(false); }; } @@ -68,7 +68,7 @@ namespace NadekoBot.Modules.Gambling { if (cards.CardPool.Count == 0 && i != 0) { - await imsg.Channel.SendMessageAsync("No more cards in a deck.").ConfigureAwait(false); + await channel.SendMessageAsync("No more cards in a deck.").ConfigureAwait(false); break; } var currentCard = cards.DrawACard(); @@ -79,7 +79,7 @@ namespace NadekoBot.Modules.Gambling await e.Channel.SendFile(images.Count + " cards.jpg", bitmap.ToStream()).ConfigureAwait(false); if (cardObjects.Count == 5) { - await imsg.Channel.SendMessageAsync($"{e.User.Mention} `{Cards.GetHandValue(cardObjects)}`").ConfigureAwait(false); + await channel.SendMessageAsync($"{e.User.Mention} `{Cards.GetHandValue(cardObjects)}`").ConfigureAwait(false); } } catch (Exception ex) diff --git a/src/NadekoBot/Modules/Gambling/Gambling.cs b/src/NadekoBot/Modules/Gambling/Gambling.cs index 449b452e..3634f9b2 100644 --- a/src/NadekoBot/Modules/Gambling/Gambling.cs +++ b/src/NadekoBot/Modules/Gambling/Gambling.cs @@ -29,180 +29,180 @@ namespace NadekoBot.Modules.Gambling var members = (await role.Members()).Where(u => u.Status == UserStatus.Online); var membersArray = members as IUser[] ?? members.ToArray(); var usr = membersArray[new Random().Next(0, membersArray.Length)]; - await imsg.Channel.SendMessageAsync($"**Raffled user:** {usr.Username} (id: {usr.Id})").ConfigureAwait(false); + await channel.SendMessageAsync($"**Raffled user:** {usr.Username} (id: {usr.Id})").ConfigureAwait(false); } + + ////todo DB + //[LocalizedCommand("$$$"), LocalizedDescription("$$$"), LocalizedSummary("$$$")] + //[RequireContext(ContextType.Guild)] + //public async Task Cash(IMessage imsg, [Remainder] string arg) + //{ + // var channel = imsg.Channel as ITextChannel; + + // var usr = e.Message.MentionedUsers.FirstOrDefault() ?? e.User; + // var pts = GetUserFlowers(usr.Id); + // var str = $"{usr.Name} has {pts} {NadekoBot.Config.CurrencySign}"; + // await channel.SendMessageAsync(str).ConfigureAwait(false); + //} + + ////todo DB + //[LocalizedCommand, LocalizedDescription, LocalizedSummary] + //[RequireContext(ContextType.Guild)] + //public async Task Give(IMessage imsg, long amount, [Remainder] IUser receiver) + //{ + // var channel = imsg.Channel as ITextChannel; + // if (amount <= 0) + // return; + // var userFlowers = GetUserFlowers(imsg.Author.Id); + + // if (userFlowers < amount) + // { + // await channel.SendMessageAsync($"{e.User.Mention} You don't have enough {NadekoBot.Config.CurrencyName}s. You only have {userFlowers}{NadekoBot.Config.CurrencySign}.").ConfigureAwait(false); + // return; + // } + + // await FlowersHandler.RemoveFlowers(e.User, "Gift", (int)amount, true).ConfigureAwait(false); + // await FlowersHandler.AddFlowersAsync(receiver, "Gift", (int)amount).ConfigureAwait(false); + + // await channel.SendMessageAsync($"{e.User.Mention} successfully sent {amount} {NadekoBot.Config.CurrencyName}s to {receiver.Mention}!").ConfigureAwait(false); + + //} + + ////todo DB + ////todo owner only + //[LocalizedCommand, LocalizedDescription, LocalizedSummary] + //[RequireContext(ContextType.Guild)] + //public Task Award(IMessage imsg, long amount, [Remainder] IGuildUser usr) => + // Award(imsg, amount, usr.Id); + + //[LocalizedCommand, LocalizedDescription, LocalizedSummary] + //[RequireContext(ContextType.Guild)] + //public async Task Award(IMessage imsg, long amount, [Remainder] ulong usrId) + //{ + // var channel = imsg.Channel as ITextChannel; + + // if (amount <= 0) + // return; + + // await FlowersHandler.AddFlowersAsync(usrId, $"Awarded by bot owner. ({imsg.Author.Username}/{imsg.Author.Id})", (int)amount).ConfigureAwait(false); + + // await channel.SendMessageAsync($"{e.User.Mention} successfully awarded {amount} {NadekoBot.Config.CurrencyName}s to <@{usrId}>!").ConfigureAwait(false); + //} + + + [LocalizedCommand, LocalizedDescription, LocalizedSummary] + [RequireContext(ContextType.Guild)] + public async Task Take(IMessage imsg, long amount, [Remainder] IGuildUser ownedPerson) + { + var channel = imsg.Channel as ITextChannel; + + if (amount < 0) + return; + + var mentionedUser = e.Message.MentionedUsers.FirstOrDefault(u => + u.Id != NadekoBot.Client.CurrentUser.Id); + if (mentionedUser == null) + return; + + await FlowersHandler.RemoveFlowers(ownedPerson.Id, $"Taken by bot owner.({e.User.Name}/{e.User.Id})", (int)amount).ConfigureAwait(false); + + await channel.SendMessageAsync($"{e.User.Mention} successfully took {amount} {NadekoBot.Config.CurrencyName}s from {mentionedUser.Mention}!").ConfigureAwait(false); + } + public override void Install(ModuleManager manager) { - manager.CreateCommands("", cgb => - { - cgb.CreateCommand(Prefix + "raffle") - .Description($"Prints a name and ID of a random user from the online list from the (optional) role. | `{Prefix}raffle` or `{Prefix}raffle RoleName`") - .Parameter("role", ParameterType.Optional) - .Do(async e => + cgb.CreateCommand(Prefix + "award") + .Description($"Gives someone a certain amount of flowers. **Bot Owner Only!** | `{Prefix}award 100 @person`") + .AddCheck(SimpleCheckers.OwnerOnly()) + .Parameter("amount", ParameterType.Required) + .Parameter("receiver", ParameterType.Unparsed) + .Do(async e => + { + + }); + + cgb.CreateCommand(Prefix + "take") + .Description($"Takes a certain amount of flowers from someone. **Bot Owner Only!** | `{Prefix}take 1 \"@someguy\"`") + .AddCheck(SimpleCheckers.OwnerOnly()) + .Parameter("amount", ParameterType.Required) + .Parameter("rektperson", ParameterType.Unparsed) + .Do(async e => + { + }); + + cgb.CreateCommand(Prefix + "betroll") + .Alias(Prefix + "br") + .Description($"Bets a certain amount of {NadekoBot.Config.CurrencyName}s and rolls a dice. Rolling over 66 yields x2 flowers, over 90 - x3 and 100 x10. | `{Prefix}br 5`") + .Parameter("amount", ParameterType.Required) + .Do(async e => + { + var amountstr = e.GetArg("amount").Trim(); + int amount; + + if (!int.TryParse(amountstr, out amount) || amount < 1) + return; + + var userFlowers = GetUserFlowers(e.User.Id); + + if (userFlowers < amount) { - - }); + await channel.SendMessageAsync($"{e.User.Mention} You don't have enough {NadekoBot.Config.CurrencyName}s. You only have {userFlowers}{NadekoBot.Config.CurrencySign}.").ConfigureAwait(false); + return; + } - cgb.CreateCommand(Prefix + "$$") - .Description(string.Format("Check how much {0}s a person has. (Defaults to yourself) |`{1}$$` or `{1}$$ @Someone`", - NadekoBot.Config.CurrencyName, Prefix)) - .Parameter("all", ParameterType.Unparsed) - .Do(async e => + await FlowersHandler.RemoveFlowers(e.User, "Betroll Gamble", (int)amount, true).ConfigureAwait(false); + + var rng = new Random().Next(0, 101); + var str = $"{e.User.Mention} `You rolled {rng}.` "; + if (rng < 67) { - var usr = e.Message.MentionedUsers.FirstOrDefault() ?? e.User; - var pts = GetUserFlowers(usr.Id); - var str = $"{usr.Name} has {pts} {NadekoBot.Config.CurrencySign}"; - await imsg.Channel.SendMessageAsync(str).ConfigureAwait(false); - }); - - cgb.CreateCommand(Prefix + "give") - .Description(string.Format("Give someone a certain amount of {0}s", NadekoBot.Config.CurrencyName)+ $"|`{Prefix}give 1 \"@SomeGuy\"`") - .Parameter("amount", ParameterType.Required) - .Parameter("receiver", ParameterType.Unparsed) - .Do(async e => + str += "Better luck next time."; + } + else if (rng < 90) { - var amountStr = e.GetArg("amount")?.Trim(); - long amount; - if (!long.TryParse(amountStr, out amount) || amount <= 0) - return; - - var mentionedUser = e.Message.MentionedUsers.FirstOrDefault(u => - u.Id != NadekoBot.Client.CurrentUser.Id && - u.Id != e.User.Id); - if (mentionedUser == null) - return; - - var userFlowers = GetUserFlowers(e.User.Id); - - if (userFlowers < amount) - { - await imsg.Channel.SendMessageAsync($"{e.User.Mention} You don't have enough {NadekoBot.Config.CurrencyName}s. You only have {userFlowers}{NadekoBot.Config.CurrencySign}.").ConfigureAwait(false); - return; - } - - await FlowersHandler.RemoveFlowers(e.User, "Gift", (int)amount, true).ConfigureAwait(false); - await FlowersHandler.AddFlowersAsync(mentionedUser, "Gift", (int)amount).ConfigureAwait(false); - - await imsg.Channel.SendMessageAsync($"{e.User.Mention} successfully sent {amount} {NadekoBot.Config.CurrencyName}s to {mentionedUser.Mention}!").ConfigureAwait(false); - - }); - - cgb.CreateCommand(Prefix + "award") - .Description($"Gives someone a certain amount of flowers. **Bot Owner Only!** | `{Prefix}award 100 @person`") - .AddCheck(SimpleCheckers.OwnerOnly()) - .Parameter("amount", ParameterType.Required) - .Parameter("receiver", ParameterType.Unparsed) - .Do(async e => + str += $"Congratulations! You won {amount * 2}{NadekoBot.Config.CurrencySign} for rolling above 66"; + await FlowersHandler.AddFlowersAsync(e.User, "Betroll Gamble", amount * 2, true).ConfigureAwait(false); + } + else if (rng < 100) { - var amountStr = e.GetArg("amount")?.Trim(); - long amount; - if (!long.TryParse(amountStr, out amount) || amount < 0) - return; - - var mentionedUser = e.Message.MentionedUsers.FirstOrDefault(u => - u.Id != NadekoBot.Client.CurrentUser.Id); - if (mentionedUser == null) - return; - - await FlowersHandler.AddFlowersAsync(mentionedUser, $"Awarded by bot owner. ({e.User.Name}/{e.User.Id})", (int)amount).ConfigureAwait(false); - - await imsg.Channel.SendMessageAsync($"{e.User.Mention} successfully awarded {amount} {NadekoBot.Config.CurrencyName}s to {mentionedUser.Mention}!").ConfigureAwait(false); - }); - - cgb.CreateCommand(Prefix + "take") - .Description($"Takes a certain amount of flowers from someone. **Bot Owner Only!** | `{Prefix}take 1 \"@someguy\"`") - .AddCheck(SimpleCheckers.OwnerOnly()) - .Parameter("amount", ParameterType.Required) - .Parameter("rektperson", ParameterType.Unparsed) - .Do(async e => + str += $"Congratulations! You won {amount * 3}{NadekoBot.Config.CurrencySign} for rolling above 90."; + await FlowersHandler.AddFlowersAsync(e.User, "Betroll Gamble", amount * 3, true).ConfigureAwait(false); + } + else { - var amountStr = e.GetArg("amount")?.Trim(); - long amount; - if (!long.TryParse(amountStr, out amount) || amount < 0) - return; + str += $"πŸ‘‘ Congratulations! You won {amount * 10}{NadekoBot.Config.CurrencySign} for rolling **100**. πŸ‘‘"; + await FlowersHandler.AddFlowersAsync(e.User, "Betroll Gamble", amount * 10, true).ConfigureAwait(false); + } - var mentionedUser = e.Message.MentionedUsers.FirstOrDefault(u => - u.Id != NadekoBot.Client.CurrentUser.Id); - if (mentionedUser == null) - return; + await channel.SendMessageAsync(str).ConfigureAwait(false); - await FlowersHandler.RemoveFlowers(mentionedUser, $"Taken by bot owner.({e.User.Name}/{e.User.Id})", (int)amount).ConfigureAwait(false); + }); - await imsg.Channel.SendMessageAsync($"{e.User.Mention} successfully took {amount} {NadekoBot.Config.CurrencyName}s from {mentionedUser.Mention}!").ConfigureAwait(false); - }); - - cgb.CreateCommand(Prefix + "betroll") - .Alias(Prefix + "br") - .Description($"Bets a certain amount of {NadekoBot.Config.CurrencyName}s and rolls a dice. Rolling over 66 yields x2 flowers, over 90 - x3 and 100 x10. | `{Prefix}br 5`") - .Parameter("amount",ParameterType.Required) - .Do(async e => - { - var amountstr = e.GetArg("amount").Trim(); - int amount; - - if (!int.TryParse(amountstr, out amount) || amount < 1) - return; - - var userFlowers = GetUserFlowers(e.User.Id); - - if (userFlowers < amount) - { - await imsg.Channel.SendMessageAsync($"{e.User.Mention} You don't have enough {NadekoBot.Config.CurrencyName}s. You only have {userFlowers}{NadekoBot.Config.CurrencySign}.").ConfigureAwait(false); - return; - } - - await FlowersHandler.RemoveFlowers(e.User, "Betroll Gamble", (int)amount, true).ConfigureAwait(false); - - var rng = new Random().Next(0, 101); - var str = $"{e.User.Mention} `You rolled {rng}.` "; - if (rng < 67) - { - str += "Better luck next time."; - } - else if (rng < 90) - { - str += $"Congratulations! You won {amount * 2}{NadekoBot.Config.CurrencySign} for rolling above 66"; - await FlowersHandler.AddFlowersAsync(e.User, "Betroll Gamble", amount * 2, true).ConfigureAwait(false); - } - else if (rng < 100) - { - str += $"Congratulations! You won {amount * 3}{NadekoBot.Config.CurrencySign} for rolling above 90."; - await FlowersHandler.AddFlowersAsync(e.User, "Betroll Gamble", amount * 3, true).ConfigureAwait(false); - } - else { - str += $"πŸ‘‘ Congratulations! You won {amount * 10}{NadekoBot.Config.CurrencySign} for rolling **100**. πŸ‘‘"; - await FlowersHandler.AddFlowersAsync(e.User, "Betroll Gamble", amount * 10, true).ConfigureAwait(false); - } - - await imsg.Channel.SendMessageAsync(str).ConfigureAwait(false); - - }); - - cgb.CreateCommand(Prefix + "leaderboard") - .Alias(Prefix + "lb") - .Description($"Displays bot currency leaderboard | `{Prefix}lb`") - .Do(async e => - { - var richestTemp = DbHandler.Instance.GetTopRichest(); - var richest = richestTemp as CurrencyState[] ?? richestTemp.ToArray(); - if (richest.Length == 0) - return; - await imsg.Channel.SendMessageAsync( - richest.Aggregate(new StringBuilder( - $@"```xl + cgb.CreateCommand(Prefix + "leaderboard") + .Alias(Prefix + "lb") + .Description($"Displays bot currency leaderboard | `{Prefix}lb`") + .Do(async e => + { + var richestTemp = DbHandler.Instance.GetTopRichest(); + var richest = richestTemp as CurrencyState[] ?? richestTemp.ToArray(); + if (richest.Length == 0) + return; + await channel.SendMessageAsync( + richest.Aggregate(new StringBuilder( +$@"```xl ┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┓ ┃ Id ┃ $$$ ┃ "), - (cur, cs) => cur.AppendLine( - $@"┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━┫ + (cur, cs) => cur.AppendLine( +$@"┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━┫ ┃{(e.Server.Users.Where(u => u.Id == (ulong)cs.UserId).FirstOrDefault()?.Name.TrimTo(18, true) ?? cs.UserId.ToString()),-20} ┃ {cs.Value,5} ┃") - ).ToString() + "┗━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━┛```").ConfigureAwait(false); - }); - }); + ).ToString() + "┗━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━┛```").ConfigureAwait(false); + }); + }); } - public static long GetUserFlowers(ulong userId) => - Classes.DbHandler.Instance.GetStateByUserId((long)userId)?.Value ?? 0; - } + public static long GetUserFlowers(ulong userId) => + Classes.DbHandler.Instance.GetStateByUserId((long)userId)?.Value ?? 0; +} } diff --git a/src/NadekoBot/Modules/Games/Commands/LeetCommands.cs b/src/NadekoBot/Modules/Games/Commands/LeetCommands.cs index 708fd642..daf04553 100644 --- a/src/NadekoBot/Modules/Games/Commands/LeetCommands.cs +++ b/src/NadekoBot/Modules/Games/Commands/LeetCommands.cs @@ -21,7 +21,7 @@ namespace NadekoBot.Modules.Games.Commands text = text.Trim(); if (string.IsNullOrWhiteSpace(text)) return; - await imsg.Channel.SendMessageAsync(ToLeet(text, level)).ConfigureAwait(false); + await channel.SendMessageAsync(ToLeet(text, level)).ConfigureAwait(false); } diff --git a/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs b/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs index 64520c6b..57ac60c6 100644 --- a/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs +++ b/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs @@ -51,7 +51,7 @@ // var rnd = Math.Abs(rng.Next(0,101)); // if (rnd == 0) // { -// var msgs = new[] { await e.Channel.SendFile(GetRandomCurrencyImagePath()), await imsg.Channel.SendMessageAsync($"❗ A random {NadekoBot.Config.CurrencyName} appeared! Pick it up by typing `>pick`") }; +// var msgs = new[] { await e.Channel.SendFile(GetRandomCurrencyImagePath()), await channel.SendMessageAsync($"❗ A random {NadekoBot.Config.CurrencyName} appeared! Pick it up by typing `>pick`") }; // plantedFlowerChannels.AddOrUpdate(e.Channel.Id, msgs, (u, m) => { m.ForEach(async msgToDelete => { try { await msgToDelete.Delete(); } catch { } }); return msgs; }); // plantpickCooldowns.AddOrUpdate(e.Channel.Id, now, (i, d) => now); // } @@ -80,7 +80,7 @@ // await msgToDelete.Delete().ConfigureAwait(false); // await FlowersHandler.AddFlowersAsync(e.User, "Picked a flower.", 1, true).ConfigureAwait(false); -// var msg = await imsg.Channel.SendMessageAsync($"**{e.User.Name}** picked a {NadekoBot.Config.CurrencyName}!").ConfigureAwait(false); +// var msg = await channel.SendMessageAsync($"**{e.User.Name}** picked a {NadekoBot.Config.CurrencyName}!").ConfigureAwait(false); // ThreadPool.QueueUserWorkItem(async (state) => // { // try @@ -101,24 +101,24 @@ // { // if (plantedFlowerChannels.ContainsKey(e.Channel.Id)) // { -// await imsg.Channel.SendMessageAsync($"There is already a {NadekoBot.Config.CurrencyName} in this channel.").ConfigureAwait(false); +// await channel.SendMessageAsync($"There is already a {NadekoBot.Config.CurrencyName} in this channel.").ConfigureAwait(false); // return; // } // var removed = await FlowersHandler.RemoveFlowers(e.User, "Planted a flower.", 1, true).ConfigureAwait(false); // if (!removed) // { -// await imsg.Channel.SendMessageAsync($"You don't have any {NadekoBot.Config.CurrencyName}s.").ConfigureAwait(false); +// await channel.SendMessageAsync($"You don't have any {NadekoBot.Config.CurrencyName}s.").ConfigureAwait(false); // return; // } // var file = GetRandomCurrencyImagePath(); // Message msg; // if (file == null) -// msg = await imsg.Channel.SendMessageAsync(NadekoBot.Config.CurrencySign).ConfigureAwait(false); +// msg = await channel.SendMessageAsync(NadekoBot.Config.CurrencySign).ConfigureAwait(false); // else // msg = await e.Channel.SendFile(file).ConfigureAwait(false); // var vowelFirst = new[] { 'a', 'e', 'i', 'o', 'u' }.Contains(NadekoBot.Config.CurrencyName[0]); -// var msg2 = await imsg.Channel.SendMessageAsync($"Oh how Nice! **{e.User.Name}** planted {(vowelFirst ? "an" : "a")} {NadekoBot.Config.CurrencyName}. Pick it using {Module.Prefix}pick").ConfigureAwait(false); +// var msg2 = await channel.SendMessageAsync($"Oh how Nice! **{e.User.Name}** planted {(vowelFirst ? "an" : "a")} {NadekoBot.Config.CurrencyName}. Pick it using {Module.Prefix}pick").ConfigureAwait(false); // plantedFlowerChannels.TryAdd(e.Channel.Id, new[] { msg, msg2 }); // } // finally { locker.Release(); } @@ -141,12 +141,12 @@ // int throwaway; // if (config.GenerateCurrencyChannels.TryRemove(e.Channel.Id, out throwaway)) // { -// await imsg.Channel.SendMessageAsync("`Currency generation disabled on this channel.`").ConfigureAwait(false); +// await channel.SendMessageAsync("`Currency generation disabled on this channel.`").ConfigureAwait(false); // } // else // { // if (config.GenerateCurrencyChannels.TryAdd(e.Channel.Id, cd)) -// await imsg.Channel.SendMessageAsync($"`Currency generation enabled on this channel. Cooldown is {cd} minutes.`").ConfigureAwait(false); +// await channel.SendMessageAsync($"`Currency generation enabled on this channel. Cooldown is {cd} minutes.`").ConfigureAwait(false); // } // }); // } diff --git a/src/NadekoBot/Modules/Games/Commands/PollCommands.cs b/src/NadekoBot/Modules/Games/Commands/PollCommands.cs index 4059fcfc..1a046c9c 100644 --- a/src/NadekoBot/Modules/Games/Commands/PollCommands.cs +++ b/src/NadekoBot/Modules/Games/Commands/PollCommands.cs @@ -76,7 +76,7 @@ namespace NadekoBot.Modules.Games.Commands var num = 1; msgToSend = answers.Aggregate(msgToSend, (current, answ) => current + $"`{num++}.` **{answ}**\n"); msgToSend += "\n**Private Message me with the corresponding number of the answer.**"; - await imsg.Channel.SendMessageAsync(msgToSend).ConfigureAwait(false); + await channel.SendMessageAsync(msgToSend).ConfigureAwait(false); } public async Task StopPoll(IGuildChannel ch) @@ -91,7 +91,7 @@ namespace NadekoBot.Modules.Games.Commands var totalVotesCast = results.Sum(kvp => kvp.Value); if (totalVotesCast == 0) { - await imsg.Channel.SendMessageAsync("πŸ“„ **No votes have been cast.**").ConfigureAwait(false); + await channel.SendMessageAsync("πŸ“„ **No votes have been cast.**").ConfigureAwait(false); return; } var closeMessage = $"--------------**POLL CLOSED**--------------\n" + @@ -100,7 +100,7 @@ namespace NadekoBot.Modules.Games.Commands $" has {kvp.Value} votes." + $"({kvp.Value * 1.0f / totalVotesCast * 100}%)\n"); - await imsg.Channel.SendMessageAsync($"πŸ“„ **Total votes cast**: {totalVotesCast}\n{closeMessage}").ConfigureAwait(false); + await channel.SendMessageAsync($"πŸ“„ **Total votes cast**: {totalVotesCast}\n{closeMessage}").ConfigureAwait(false); } catch (Exception ex) { diff --git a/src/NadekoBot/Modules/Games/Commands/SpeedTypingCommands.cs b/src/NadekoBot/Modules/Games/Commands/SpeedTypingCommands.cs index 6130b363..bf533c54 100644 --- a/src/NadekoBot/Modules/Games/Commands/SpeedTypingCommands.cs +++ b/src/NadekoBot/Modules/Games/Commands/SpeedTypingCommands.cs @@ -115,7 +115,7 @@ // await channel.Send($"{e.User.Mention} finished in **{sw.Elapsed.Seconds}** seconds with { distance } errors, **{ CurrentSentence.Length / WORD_VALUE / sw.Elapsed.Seconds * 60 }** WPM!").ConfigureAwait(false); // if (finishedUserIds.Count % 2 == 0) // { -// await imsg.Channel.SendMessageAsync($":exclamation: `A lot of people finished, here is the text for those still typing:`\n\n:book:**{CurrentSentence}**:book:").ConfigureAwait(false); +// await channel.SendMessageAsync($":exclamation: `A lot of people finished, here is the text for those still typing:`\n\n:book:**{CurrentSentence}**:book:").ConfigureAwait(false); // } // } // } @@ -143,7 +143,7 @@ // if (game.IsActive) // { -// await imsg.Channel.SendMessageAsync( +// await channel.SendMessageAsync( // $"Contest already running in " + // $"{game.Channell.Mention} channel.") // .ConfigureAwait(false); @@ -163,7 +163,7 @@ // await game.Stop().ConfigureAwait(false); // return; // } -// await imsg.Channel.SendMessageAsync("No contest to stop on this channel.").ConfigureAwait(false); +// await channel.SendMessageAsync("No contest to stop on this channel.").ConfigureAwait(false); // }; // internal override void Init(CommandGroupBuilder cgb) @@ -189,7 +189,7 @@ // DateAdded = DateTime.Now // }); -// await imsg.Channel.SendMessageAsync("Added new article for typing game.").ConfigureAwait(false); +// await channel.SendMessageAsync("Added new article for typing game.").ConfigureAwait(false); // }); // } // } diff --git a/src/NadekoBot/Modules/Games/Commands/TriviaCommands.cs b/src/NadekoBot/Modules/Games/Commands/TriviaCommands.cs index 3838d2c5..98ca7cf5 100644 --- a/src/NadekoBot/Modules/Games/Commands/TriviaCommands.cs +++ b/src/NadekoBot/Modules/Games/Commands/TriviaCommands.cs @@ -36,12 +36,12 @@ namespace NadekoBot.Modules.Games.Commands return; var triviaGame = new TriviaGame(channel.Guild, imsg.Channel as ITextChannel, showHints, number == 0 ? 10 : number); if (RunningTrivias.TryAdd(channel.Guild.Id, triviaGame)) - await imsg.Channel.SendMessageAsync($"**Trivia game started! {triviaGame.WinRequirement} points needed to win.**").ConfigureAwait(false); + await channel.SendMessageAsync($"**Trivia game started! {triviaGame.WinRequirement} points needed to win.**").ConfigureAwait(false); else await triviaGame.StopGame().ConfigureAwait(false); } else - await imsg.Channel.SendMessageAsync("Trivia game is already running on this server.\n" + trivia.CurrentQuestion).ConfigureAwait(false); + await channel.SendMessageAsync("Trivia game is already running on this server.\n" + trivia.CurrentQuestion).ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -52,9 +52,9 @@ namespace NadekoBot.Modules.Games.Commands TriviaGame trivia; if (RunningTrivias.TryGetValue(channel.Guild.Id, out trivia)) - await imsg.Channel.SendMessageAsync(trivia.GetLeaderboard()).ConfigureAwait(false); + await channel.SendMessageAsync(trivia.GetLeaderboard()).ConfigureAwait(false); else - await imsg.Channel.SendMessageAsync("No trivia is running on this server.").ConfigureAwait(false); + await channel.SendMessageAsync("No trivia is running on this server.").ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -69,7 +69,7 @@ namespace NadekoBot.Modules.Games.Commands await trivia.StopGame().ConfigureAwait(false); } else - await imsg.Channel.SendMessageAsync("No trivia is running on this server.").ConfigureAwait(false); + await channel.SendMessageAsync("No trivia is running on this server.").ConfigureAwait(false); } } } diff --git a/src/NadekoBot/Modules/Games/Games.cs b/src/NadekoBot/Modules/Games/Games.cs index 49f58e2c..7f5e4429 100644 --- a/src/NadekoBot/Modules/Games/Games.cs +++ b/src/NadekoBot/Modules/Games/Games.cs @@ -30,7 +30,7 @@ namespace NadekoBot.Modules.Games if (listArr.Count() < 2) return; var rng = new Random(); - await imsg.Channel.SendMessageAsync(listArr[rng.Next(0, listArr.Length)]).ConfigureAwait(false); + await channel.SendMessageAsync(listArr[rng.Next(0, listArr.Length)]).ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -42,7 +42,7 @@ namespace NadekoBot.Modules.Games if (string.IsNullOrWhiteSpace(question)) return; var rng = new Random(); - await imsg.Channel.SendMessageAsync($@":question: `Question` __**{question}**__ + await channel.SendMessageAsync($@":question: `Question` __**{question}**__ 🎱 `8Ball Answers` __**{_8BallResponses.Shuffle().FirstOrDefault()}**__").ConfigureAwait(false); } @@ -93,7 +93,7 @@ namespace NadekoBot.Modules.Games else msg = $"{imsg.Author.Mention} won! :{GetRPSPick(pick)}: beats :{GetRPSPick(nadekoPick)}:"; - await imsg.Channel.SendMessageAsync(msg).ConfigureAwait(false); + await channel.SendMessageAsync(msg).ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -102,7 +102,7 @@ namespace NadekoBot.Modules.Games { var channel = imsg.Channel as ITextChannel; - await imsg.Channel.SendMessageAsync( + await channel.SendMessageAsync( $@"I'd just like to interject for moment. What you're refering to as {loonix}, is in fact, {guhnoo}/{loonix}, or as I've recently taken to calling it, {guhnoo} plus {loonix}. {loonix} is not an operating system unto itself, but rather another free component of a fully functioning {guhnoo} system made useful by the {guhnoo} corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX. Many computer users run a modified version of the {guhnoo} system every day, without realizing it. Through a peculiar turn of events, the version of {guhnoo} which is widely used today is often called {loonix}, and many of its users are not aware that it is basically the {guhnoo} system, developed by the {guhnoo} Project. diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index 0c0a4c78..e3469f1c 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -30,7 +30,7 @@ namespace NadekoBot.Modules.Help { var channel = imsg.Channel as ITextChannel; - await imsg.Channel.SendMessageAsync("`List of modules:` \nβ€’ " + string.Join("\nβ€’ ", _commands.Modules.Select(m => m.Name)) + $"\n`Type \"-commands module_name\" to get a list of commands in that module.`") + await channel.SendMessageAsync("`List of modules:` \nβ€’ " + string.Join("\nβ€’ ", _commands.Modules.Select(m => m.Name)) + $"\n`Type \"-commands module_name\" to get a list of commands in that module.`") .ConfigureAwait(false); } @@ -49,19 +49,19 @@ namespace NadekoBot.Modules.Help var cmdsArray = cmds as Command[] ?? cmds.ToArray(); if (!cmdsArray.Any()) { - await imsg.Channel.SendMessageAsync("That module does not exist.").ConfigureAwait(false); + await channel.SendMessageAsync("That module does not exist.").ConfigureAwait(false); return; } if (module != "customreactions" && module != "conversations") { //todo aliases - await imsg.Channel.SendTableAsync("`List Of Commands:`\n", cmdsArray, el => $"{el.Text,-15}").ConfigureAwait(false); + await channel.SendTableAsync("`List Of Commands:`\n", cmdsArray, el => $"{el.Text,-15}").ConfigureAwait(false); } else { - await imsg.Channel.SendMessageAsync("`List Of Commands:`\nβ€’ " + string.Join("\nβ€’ ", cmdsArray.Select(c => $"{c.Text}"))); + await channel.SendMessageAsync("`List Of Commands:`\nβ€’ " + string.Join("\nβ€’ ", cmdsArray.Select(c => $"{c.Text}"))); } - await imsg.Channel.SendMessageAsync($"`You can type \"-h command_name\" to see the help about that specific command.`").ConfigureAwait(false); + await channel.SendMessageAsync($"`You can type \"-h command_name\" to see the help about that specific command.`").ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -80,7 +80,7 @@ namespace NadekoBot.Modules.Help //todo aliases if (com != null) - await imsg.Channel.SendMessageAsync($@"**__Help for:__ `{com.Text}`** + await channel.SendMessageAsync($@"**__Help for:__ `{com.Text}`** **Desc:** {com.Description} **Usage:** {com.Summary}").ConfigureAwait(false); } @@ -118,7 +118,7 @@ namespace NadekoBot.Modules.Help { var channel = imsg.Channel as ITextChannel; - await imsg.Channel.SendMessageAsync( + await channel.SendMessageAsync( @"**LIST OF COMMANDS**: **Hosting Guides and docs can be found here**: ").ConfigureAwait(false); } @@ -129,7 +129,7 @@ namespace NadekoBot.Modules.Help { var channel = imsg.Channel as ITextChannel; - await imsg.Channel.SendMessageAsync( + await channel.SendMessageAsync( $@"You can support the project on patreon. or You can send donations to `nadekodiscordbot@gmail.com` Don't forget to leave your discord name or id in the message. diff --git a/src/NadekoBot/Modules/NSFW/NSFW.cs b/src/NadekoBot/Modules/NSFW/NSFW.cs index 2d897147..e9d165ca 100644 --- a/src/NadekoBot/Modules/NSFW/NSFW.cs +++ b/src/NadekoBot/Modules/NSFW/NSFW.cs @@ -32,11 +32,11 @@ namespace NadekoBot.Modules.NSFW if (links.All(l => l == null)) { - await imsg.Channel.SendMessageAsync("`No results.`"); + await channel.SendMessageAsync("`No results.`"); return; } - await imsg.Channel.SendMessageAsync(String.Join("\n\n", links)).ConfigureAwait(false); + await channel.SendMessageAsync(String.Join("\n\n", links)).ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -48,9 +48,9 @@ namespace NadekoBot.Modules.NSFW tag = tag?.Trim() ?? ""; var link = await GetDanbooruImageLink(tag).ConfigureAwait(false); if (string.IsNullOrWhiteSpace(link)) - await imsg.Channel.SendMessageAsync("Search yielded no results ;("); + await channel.SendMessageAsync("Search yielded no results ;("); else - await imsg.Channel.SendMessageAsync(link).ConfigureAwait(false); + await channel.SendMessageAsync(link).ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -62,9 +62,9 @@ namespace NadekoBot.Modules.NSFW tag = tag?.Trim() ?? ""; var link = await GetRule34ImageLink(tag).ConfigureAwait(false); if (string.IsNullOrWhiteSpace(link)) - await imsg.Channel.SendMessageAsync("Search yielded no results ;("); + await channel.SendMessageAsync("Search yielded no results ;("); else - await imsg.Channel.SendMessageAsync(link).ConfigureAwait(false); + await channel.SendMessageAsync(link).ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -76,9 +76,9 @@ namespace NadekoBot.Modules.NSFW tag = tag?.Trim() ?? ""; var link = await GetGelbooruImageLink(tag).ConfigureAwait(false); if (string.IsNullOrWhiteSpace(link)) - await imsg.Channel.SendMessageAsync("Search yielded no results ;("); + await channel.SendMessageAsync("Search yielded no results ;("); else - await imsg.Channel.SendMessageAsync(link).ConfigureAwait(false); + await channel.SendMessageAsync(link).ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -90,9 +90,9 @@ namespace NadekoBot.Modules.NSFW tag = tag?.Trim() ?? ""; var link = await GetE621ImageLink(tag).ConfigureAwait(false); if (string.IsNullOrWhiteSpace(link)) - await imsg.Channel.SendMessageAsync("Search yielded no results ;("); + await channel.SendMessageAsync("Search yielded no results ;("); else - await imsg.Channel.SendMessageAsync(link).ConfigureAwait(false); + await channel.SendMessageAsync(link).ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -101,7 +101,7 @@ namespace NadekoBot.Modules.NSFW { var channel = imsg.Channel as ITextChannel; - await imsg.Channel.SendMessageAsync("http://i.imgur.com/MZkY1md.jpg").ConfigureAwait(false); + await channel.SendMessageAsync("http://i.imgur.com/MZkY1md.jpg").ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -116,11 +116,11 @@ namespace NadekoBot.Modules.NSFW { obj = JArray.Parse(await http.GetStringAsync($"http://api.oboobs.ru/boobs/{ new Random().Next(0, 9880) }").ConfigureAwait(false))[0]; } - await imsg.Channel.SendMessageAsync($"http://media.oboobs.ru/{ obj["preview"].ToString() }").ConfigureAwait(false); + await channel.SendMessageAsync($"http://media.oboobs.ru/{ obj["preview"].ToString() }").ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync($"πŸ’’ {ex.Message}").ConfigureAwait(false); + await channel.SendMessageAsync($"πŸ’’ {ex.Message}").ConfigureAwait(false); } } @@ -137,11 +137,11 @@ namespace NadekoBot.Modules.NSFW { obj = JArray.Parse(await http.GetStringAsync($"http://api.obutts.ru/butts/{ new Random().Next(0, 3873) }").ConfigureAwait(false))[0]; } - await imsg.Channel.SendMessageAsync($"http://media.obutts.ru/{ obj["preview"].ToString() }").ConfigureAwait(false); + await channel.SendMessageAsync($"http://media.obutts.ru/{ obj["preview"].ToString() }").ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync($"πŸ’’ {ex.Message}").ConfigureAwait(false); + await channel.SendMessageAsync($"πŸ’’ {ex.Message}").ConfigureAwait(false); } } diff --git a/src/NadekoBot/Modules/Searches/Commands/AnimeSearchCommands.cs b/src/NadekoBot/Modules/Searches/Commands/AnimeSearchCommands.cs index 4f095bbd..7333d00a 100644 --- a/src/NadekoBot/Modules/Searches/Commands/AnimeSearchCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/AnimeSearchCommands.cs @@ -25,11 +25,11 @@ // } // catch // { -// await imsg.Channel.SendMessageAsync("Failed to find that anime.").ConfigureAwait(false); +// await channel.SendMessageAsync("Failed to find that anime.").ConfigureAwait(false); // return; // } -// await imsg.Channel.SendMessageAsync(result.ToString()).ConfigureAwait(false); +// await channel.SendMessageAsync(result.ToString()).ConfigureAwait(false); // } // [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -46,10 +46,10 @@ // } // catch // { -// await imsg.Channel.SendMessageAsync("Failed to find that manga.").ConfigureAwait(false); +// await channel.SendMessageAsync("Failed to find that manga.").ConfigureAwait(false); // return; // } -// await imsg.Channel.SendMessageAsync(result).ConfigureAwait(false); +// await channel.SendMessageAsync(result).ConfigureAwait(false); // } // public static async Task GetAnimeData(string query) diff --git a/src/NadekoBot/Modules/Searches/Commands/ConverterCommands.cs b/src/NadekoBot/Modules/Searches/Commands/ConverterCommands.cs index d3e37a65..cb7a278c 100644 --- a/src/NadekoBot/Modules/Searches/Commands/ConverterCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/ConverterCommands.cs @@ -62,7 +62,7 @@ // msg += curr + "; "; // } -// await imsg.Channel.SendMessageAsync(msg).ConfigureAwait(false); +// await channel.SendMessageAsync(msg).ConfigureAwait(false); // }; // private Func ConvertFunc() => @@ -89,7 +89,7 @@ // { // Unit inUnit = new Unit(fromCode, quantity, table); // Unit outUnit = inUnit.Convert(toCode); -// await imsg.Channel.SendMessageAsync(inUnit.ToString() + " = " + outUnit.ToString()).ConfigureAwait(false); +// await channel.SendMessageAsync(inUnit.ToString() + " = " + outUnit.ToString()).ConfigureAwait(false); // } // else // { @@ -98,13 +98,13 @@ // reInitCurrencyConverterTable(); // Unit inUnit = currTable.CreateUnit(quantity, from.ToUpperInvariant()); // Unit outUnit = inUnit.Convert(currTable.CurrencyCode(to.ToUpperInvariant())); -// await imsg.Channel.SendMessageAsync(inUnit.ToString() + " = " + outUnit.ToString()).ConfigureAwait(false); +// await channel.SendMessageAsync(inUnit.ToString() + " = " + outUnit.ToString()).ConfigureAwait(false); // } // } // catch //(Exception ex) // { // //Console.WriteLine(ex.ToString()); -// await imsg.Channel.SendMessageAsync("Bad input format, or sth went wrong... Try to list them with `" + Module.Prefix + "`convertlist").ConfigureAwait(false); +// await channel.SendMessageAsync("Bad input format, or sth went wrong... Try to list them with `" + Module.Prefix + "`convertlist").ConfigureAwait(false); // } // }; diff --git a/src/NadekoBot/Modules/Searches/Commands/EvalCommand.cs b/src/NadekoBot/Modules/Searches/Commands/EvalCommand.cs index 9a58a312..8d3eef9c 100644 --- a/src/NadekoBot/Modules/Searches/Commands/EvalCommand.cs +++ b/src/NadekoBot/Modules/Searches/Commands/EvalCommand.cs @@ -35,10 +35,10 @@ // string answer = Evaluate(expression); // if (answer == null) // { -// await imsg.Channel.SendMessageAsync($"Expression {expression} failed to evaluate"); +// await channel.SendMessageAsync($"Expression {expression} failed to evaluate"); // return; // } -// await imsg.Channel.SendMessageAsync($"βš™ `{answer}`"); +// await channel.SendMessageAsync($"βš™ `{answer}`"); // }; // private string Evaluate(string expression) diff --git a/src/NadekoBot/Modules/Searches/Commands/JokeCommands.cs b/src/NadekoBot/Modules/Searches/Commands/JokeCommands.cs index 0efbf9b1..c20354fe 100644 --- a/src/NadekoBot/Modules/Searches/Commands/JokeCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/JokeCommands.cs @@ -36,7 +36,7 @@ namespace NadekoBot.Modules.Searches.Commands using (var http = new HttpClient()) { var response = await http.GetStringAsync("http://api.yomomma.info/").ConfigureAwait(false); - await imsg.Channel.SendMessageAsync("`" + JObject.Parse(response)["joke"].ToString() + "` πŸ˜†").ConfigureAwait(false); + await channel.SendMessageAsync("`" + JObject.Parse(response)["joke"].ToString() + "` πŸ˜†").ConfigureAwait(false); } } @@ -48,7 +48,7 @@ namespace NadekoBot.Modules.Searches.Commands using (var http = new HttpClient()) { var response = await http.GetStringAsync("http://tambal.azurewebsites.net/joke/random").ConfigureAwait(false); - await imsg.Channel.SendMessageAsync("`" + JObject.Parse(response)["joke"].ToString() + "` πŸ˜†").ConfigureAwait(false); + await channel.SendMessageAsync("`" + JObject.Parse(response)["joke"].ToString() + "` πŸ˜†").ConfigureAwait(false); } } @@ -60,7 +60,7 @@ namespace NadekoBot.Modules.Searches.Commands using (var http = new HttpClient()) { var response = await http.GetStringAsync("http://tambal.azurewebsites.net/joke/random").ConfigureAwait(false); - await imsg.Channel.SendMessageAsync("`" + JObject.Parse(response)["joke"].ToString() + "` πŸ˜†").ConfigureAwait(false); + await channel.SendMessageAsync("`" + JObject.Parse(response)["joke"].ToString() + "` πŸ˜†").ConfigureAwait(false); } } @@ -73,7 +73,7 @@ namespace NadekoBot.Modules.Searches.Commands if (!wowJokes.Any()) { } - await imsg.Channel.SendMessageAsync(wowJokes[new Random().Next(0, wowJokes.Count)].ToString()); + await channel.SendMessageAsync(wowJokes[new Random().Next(0, wowJokes.Count)].ToString()); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -84,7 +84,7 @@ namespace NadekoBot.Modules.Searches.Commands var rng = new Random(); var item = magicItems[rng.Next(0, magicItems.Count)].ToString(); - await imsg.Channel.SendMessageAsync(item).ConfigureAwait(false); + await channel.SendMessageAsync(item).ConfigureAwait(false); } } } diff --git a/src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs b/src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs index a1850dbe..8e473ef3 100644 --- a/src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/LoLCommands.cs @@ -107,7 +107,7 @@ // } // if (data == null) // { -// await imsg.Channel.SendMessageAsync("πŸ’’ Data for that role does not exist.").ConfigureAwait(false); +// await channel.SendMessageAsync("πŸ’’ Data for that role does not exist.").ConfigureAwait(false); // return; // } // } @@ -276,7 +276,7 @@ // catch (Exception ex) // { // Console.WriteLine(ex); -// await imsg.Channel.SendMessageAsync("πŸ’’ Failed retreiving data for that champion.").ConfigureAwait(false); +// await channel.SendMessageAsync("πŸ’’ Failed retreiving data for that champion.").ConfigureAwait(false); // } // }); @@ -308,11 +308,11 @@ // //sb.AppendLine($" ({dataList[i]["general"]["banRate"]}%)"); // } -// await imsg.Channel.SendMessageAsync(sb.ToString()).ConfigureAwait(false); +// await channel.SendMessageAsync(sb.ToString()).ConfigureAwait(false); // } // catch (Exception) // { -// await imsg.Channel.SendMessageAsync($":anger: Fail: Champion.gg didsabled ban data until next patch. Sorry for the inconvenience.").ConfigureAwait(false); +// await channel.SendMessageAsync($":anger: Fail: Champion.gg didsabled ban data until next patch. Sorry for the inconvenience.").ConfigureAwait(false); // } // }); // } diff --git a/src/NadekoBot/Modules/Searches/Commands/MemegenCommands.cs b/src/NadekoBot/Modules/Searches/Commands/MemegenCommands.cs index 17299bb2..d9bbd55d 100644 --- a/src/NadekoBot/Modules/Searches/Commands/MemegenCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/MemegenCommands.cs @@ -29,7 +29,7 @@ namespace NadekoBot.Modules.Searches.Commands var data = JsonConvert.DeserializeObject>(await http.GetStringAsync("http://memegen.link/templates/")) .Select(kvp => Path.GetFileName(kvp.Value)); - await imsg.Channel.SendTableAsync(data, x => $"{x,-17}", 3); + await channel.SendTableAsync(data, x => $"{x,-17}", 3); } } @@ -41,7 +41,7 @@ namespace NadekoBot.Modules.Searches.Commands var top = Uri.EscapeDataString(topText.Replace(' ', '-')); var bot = Uri.EscapeDataString(botText.Replace(' ', '-')); - await imsg.Channel.SendMessageAsync($"http://memegen.link/{meme}/{top}/{bot}.jpg"); + await channel.SendMessageAsync($"http://memegen.link/{meme}/{top}/{bot}.jpg"); } } } diff --git a/src/NadekoBot/Modules/Searches/Commands/OsuCommands.cs b/src/NadekoBot/Modules/Searches/Commands/OsuCommands.cs index 5ec99747..082a4790 100644 --- a/src/NadekoBot/Modules/Searches/Commands/OsuCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/OsuCommands.cs @@ -44,14 +44,14 @@ // try // { // await e.Channel.SendFile($"{e.GetArg("usr")}.png", new MemoryStream(cle.Result)).ConfigureAwait(false); -// await imsg.Channel.SendMessageAsync($"`Profile Link:`https://osu.ppy.sh/u/{Uri.EscapeDataString(e.GetArg("usr"))}\n`Image provided by https://lemmmy.pw/osusig`").ConfigureAwait(false); +// await channel.SendMessageAsync($"`Profile Link:`https://osu.ppy.sh/u/{Uri.EscapeDataString(e.GetArg("usr"))}\n`Image provided by https://lemmmy.pw/osusig`").ConfigureAwait(false); // } // catch { } // }; // } // catch // { -// await imsg.Channel.SendMessageAsync("πŸ’’ Failed retrieving osu signature :\\").ConfigureAwait(false); +// await channel.SendMessageAsync("πŸ’’ Failed retrieving osu signature :\\").ConfigureAwait(false); // } // } // }); @@ -63,7 +63,7 @@ // { // if (string.IsNullOrWhiteSpace(NadekoBot.Creds.OsuAPIKey)) // { -// await imsg.Channel.SendMessageAsync("πŸ’’ An osu! API key is required.").ConfigureAwait(false); +// await channel.SendMessageAsync("πŸ’’ An osu! API key is required.").ConfigureAwait(false); // return; // } @@ -80,11 +80,11 @@ // var time = TimeSpan.FromSeconds(Double.Parse($"{obj["total_length"]}")).ToString(@"mm\:ss"); // sb.AppendLine($"{obj["artist"]} - {obj["title"]}, mapped by {obj["creator"]}. https://osu.ppy.sh/s/{obj["beatmapset_id"]}"); // sb.AppendLine($"{starRating} stars, {obj["bpm"]} BPM | AR{obj["diff_approach"]}, CS{obj["diff_size"]}, OD{obj["diff_overall"]} | Length: {time}"); -// await imsg.Channel.SendMessageAsync(sb.ToString()).ConfigureAwait(false); +// await channel.SendMessageAsync(sb.ToString()).ConfigureAwait(false); // } // catch // { -// await imsg.Channel.SendMessageAsync("Something went wrong."); +// await channel.SendMessageAsync("Something went wrong."); // } // }); @@ -96,13 +96,13 @@ // { // if (string.IsNullOrWhiteSpace(NadekoBot.Creds.OsuAPIKey)) // { -// await imsg.Channel.SendMessageAsync("πŸ’’ An osu! API key is required.").ConfigureAwait(false); +// await channel.SendMessageAsync("πŸ’’ An osu! API key is required.").ConfigureAwait(false); // return; // } // if (string.IsNullOrWhiteSpace(e.GetArg("usr"))) // { -// await imsg.Channel.SendMessageAsync("πŸ’’ Please provide a username.").ConfigureAwait(false); +// await channel.SendMessageAsync("πŸ’’ Please provide a username.").ConfigureAwait(false); // return; // } @@ -130,11 +130,11 @@ // sb.AppendLine($"{pp + "pp",-7} | {acc + "%",-7} | {map["artist"] + "-" + map["title"] + " (" + map["version"],-40}) | /b/{item["beatmap_id"]}"); // } // sb.Append("```"); -// await imsg.Channel.SendMessageAsync(sb.ToString()).ConfigureAwait(false); +// await channel.SendMessageAsync(sb.ToString()).ConfigureAwait(false); // } // catch // { -// await imsg.Channel.SendMessageAsync("Something went wrong."); +// await channel.SendMessageAsync("Something went wrong."); // } // }); // } diff --git a/src/NadekoBot/Modules/Searches/Commands/PokemonSearchCommands.cs b/src/NadekoBot/Modules/Searches/Commands/PokemonSearchCommands.cs index cfcc9940..c305fca2 100644 --- a/src/NadekoBot/Modules/Searches/Commands/PokemonSearchCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/PokemonSearchCommands.cs @@ -38,11 +38,11 @@ namespace NadekoBot.Modules.Searches.Commands { if (kvp.Key.ToUpperInvariant() == pokemon.ToUpperInvariant()) { - await imsg.Channel.SendMessageAsync($"`Stats for \"{kvp.Key}\" pokemon:`\n{kvp.Value}"); + await channel.SendMessageAsync($"`Stats for \"{kvp.Key}\" pokemon:`\n{kvp.Value}"); return; } } - await imsg.Channel.SendMessageAsync("`No pokemon found.`"); + await channel.SendMessageAsync("`No pokemon found.`"); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -58,11 +58,11 @@ namespace NadekoBot.Modules.Searches.Commands { if (kvp.Key.ToUpperInvariant() == ability) { - await imsg.Channel.SendMessageAsync($"`Info for \"{kvp.Key}\" ability:`\n{kvp.Value}"); + await channel.SendMessageAsync($"`Info for \"{kvp.Key}\" ability:`\n{kvp.Value}"); return; } } - await imsg.Channel.SendMessageAsync("`No ability found.`"); + await channel.SendMessageAsync("`No ability found.`"); } } } diff --git a/src/NadekoBot/Modules/Searches/Commands/StreamNotificationCommands.cs b/src/NadekoBot/Modules/Searches/Commands/StreamNotificationCommands.cs index 472da870..f42afdac 100644 --- a/src/NadekoBot/Modules/Searches/Commands/StreamNotificationCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/StreamNotificationCommands.cs @@ -166,12 +166,12 @@ // })); // if (streamStatus.Item1) // { -// await imsg.Channel.SendMessageAsync($"`Streamer {streamStatus.Item2} is online.`"); +// await channel.SendMessageAsync($"`Streamer {streamStatus.Item2} is online.`"); // } // } // catch // { -// await imsg.Channel.SendMessageAsync("No channel found."); +// await channel.SendMessageAsync("No channel found."); // } // }); @@ -195,12 +195,12 @@ // })); // if (streamStatus.Item1) // { -// await imsg.Channel.SendMessageAsync($"`Streamer {streamStatus.Item2} is online.`"); +// await channel.SendMessageAsync($"`Streamer {streamStatus.Item2} is online.`"); // } // } // catch // { -// await imsg.Channel.SendMessageAsync("No channel found."); +// await channel.SendMessageAsync("No channel found."); // } // }); @@ -224,12 +224,12 @@ // })); // if (streamStatus.Item1) // { -// await imsg.Channel.SendMessageAsync($"`Streamer {streamStatus.Item2} is online.`"); +// await channel.SendMessageAsync($"`Streamer {streamStatus.Item2} is online.`"); // } // } // catch // { -// await imsg.Channel.SendMessageAsync("No channel found."); +// await channel.SendMessageAsync("No channel found."); // } // }); @@ -252,13 +252,13 @@ // snc.Username.ToLower().Trim() == username); // if (toRemove == null) // { -// await imsg.Channel.SendMessageAsync(":anger: No such stream.").ConfigureAwait(false); +// await channel.SendMessageAsync(":anger: No such stream.").ConfigureAwait(false); // return; // } // config.ObservingStreams.Remove(toRemove); // await ConfigHandler.SaveConfig().ConfigureAwait(false); -// await imsg.Channel.SendMessageAsync($":ok: Removed `{toRemove.Username}`'s stream from notifications.").ConfigureAwait(false); +// await channel.SendMessageAsync($":ok: Removed `{toRemove.Username}`'s stream from notifications.").ConfigureAwait(false); // }); // cgb.CreateCommand(Module.Prefix + "liststreams") @@ -277,7 +277,7 @@ // if (streamsArray.Length == 0) // { -// await imsg.Channel.SendMessageAsync("You are not following any streams on this server.").ConfigureAwait(false); +// await channel.SendMessageAsync("You are not following any streams on this server.").ConfigureAwait(false); // return; // } @@ -291,7 +291,7 @@ // return ""; // })); -// await imsg.Channel.SendMessageAsync($"You are following **{streamsArray.Length}** streams on this server.\n\n" + text).ConfigureAwait(false); +// await channel.SendMessageAsync($"You are following **{streamsArray.Length}** streams on this server.\n\n" + text).ConfigureAwait(false); // }); // } @@ -314,7 +314,7 @@ // var exists = config.ObservingStreams.Contains(stream); // if (exists) // { -// await imsg.Channel.SendMessageAsync(":anger: I am already notifying that stream on this channel.").ConfigureAwait(false); +// await channel.SendMessageAsync(":anger: I am already notifying that stream on this channel.").ConfigureAwait(false); // return; // } // Tuple data; @@ -324,7 +324,7 @@ // } // catch // { -// await imsg.Channel.SendMessageAsync(":anger: Stream probably doesn't exist.").ConfigureAwait(false); +// await channel.SendMessageAsync(":anger: Stream probably doesn't exist.").ConfigureAwait(false); // return; // } // var msg = $"Stream is currently **{(data.Item1 ? "ONLINE" : "OFFLINE")}** with **{data.Item2}** viewers"; @@ -340,7 +340,7 @@ // stream.LastStatus = data.Item1; // if (!exists) // msg = $":ok: I will notify this channel when status changes.\n{msg}"; -// await imsg.Channel.SendMessageAsync(msg).ConfigureAwait(false); +// await channel.SendMessageAsync(msg).ConfigureAwait(false); // config.ObservingStreams.Add(stream); // }; // } diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index 50d6b831..b8d9b0c7 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -39,7 +39,7 @@ namespace NadekoBot.Modules.Searches var obj = JObject.Parse(response)["weather"]; - await imsg.Channel.SendMessageAsync( + await channel.SendMessageAsync( $@"🌍 **Weather for** 【{obj["target"]}】 πŸ“ **Lat,Long:** ({obj["latitude"]}, {obj["longitude"]}) ☁ **Condition:** {obj["condition"]} πŸ˜“ **Humidity:** {obj["humidity"]}% πŸ’¨ **Wind Speed:** {obj["windspeedk"]}km/h / {obj["windspeedm"]}mph @@ -56,11 +56,11 @@ $@"🌍 **Weather for** 【{obj["target"]}】 var result = (await _yt.FindVideosByKeywordsAsync(query, 1)).FirstOrDefault(); if (string.IsNullOrWhiteSpace(result)) { - await imsg.Channel.SendMessageAsync("No results found for that query."); + await channel.SendMessageAsync("No results found for that query."); return; } var shortUrl = await result.ShortenUrl().ConfigureAwait(false); - await imsg.Channel.SendMessageAsync(shortUrl).ConfigureAwait(false); + await channel.SendMessageAsync(shortUrl).ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -80,11 +80,11 @@ $@"🌍 **Weather for** 【{obj["target"]}】 } catch { - await imsg.Channel.SendMessageAsync("Failed to find that movie.").ConfigureAwait(false); + await channel.SendMessageAsync("Failed to find that movie.").ConfigureAwait(false); return; } - await imsg.Channel.SendMessageAsync(result.ToString()).ConfigureAwait(false); + await channel.SendMessageAsync(result.ToString()).ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -94,7 +94,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】 var channel = imsg.Channel as ITextChannel; using (var http = new HttpClient()) { - await imsg.Channel.SendMessageAsync(JObject.Parse( + await channel.SendMessageAsync(JObject.Parse( await http.GetStringAsync("http://www.random.cat/meow").ConfigureAwait(false))["file"].ToString()) .ConfigureAwait(false); } @@ -107,7 +107,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】 var channel = imsg.Channel as ITextChannel; using (var http = new HttpClient()) { - await imsg.Channel.SendMessageAsync("http://random.dog/" + await http.GetStringAsync("http://random.dog/woof").ConfigureAwait(false)).ConfigureAwait(false); + await channel.SendMessageAsync("http://random.dog/" + await http.GetStringAsync("http://random.dog/woof").ConfigureAwait(false)).ConfigureAwait(false); } } @@ -125,18 +125,18 @@ $@"🌍 **Weather for** 【{obj["target"]}】 { var reqString = $"https://www.googleapis.com/customsearch/v1?q={Uri.EscapeDataString(query)}&cx=018084019232060951019%3Ahs5piey28-e&num=1&searchType=image&fields=items%2Flink&key={NadekoBot.Credentials.GoogleApiKey}"; var obj = JObject.Parse(await http.GetStringAsync(reqString).ConfigureAwait(false)); - await imsg.Channel.SendMessageAsync(obj["items"][0]["link"].ToString()).ConfigureAwait(false); + await channel.SendMessageAsync(obj["items"][0]["link"].ToString()).ConfigureAwait(false); } } catch (HttpRequestException exception) { if (exception.Message.Contains("403 (Forbidden)")) { - await imsg.Channel.SendMessageAsync("Daily limit reached!"); + await channel.SendMessageAsync("Daily limit reached!"); } else { - await imsg.Channel.SendMessageAsync("Something went wrong."); + await channel.SendMessageAsync("Something went wrong."); } } } @@ -157,18 +157,18 @@ $@"🌍 **Weather for** 【{obj["target"]}】 var reqString = $"https://www.googleapis.com/customsearch/v1?q={Uri.EscapeDataString(query)}&cx=018084019232060951019%3Ahs5piey28-e&num=1&searchType=image&start={ rng.Next(1, 50) }&fields=items%2Flink&key={NadekoBot.Credentials.GoogleApiKey}"; var obj = JObject.Parse(await http.GetStringAsync(reqString).ConfigureAwait(false)); var items = obj["items"] as JArray; - await imsg.Channel.SendMessageAsync(items[0]["link"].ToString()).ConfigureAwait(false); + await channel.SendMessageAsync(items[0]["link"].ToString()).ConfigureAwait(false); } } catch (HttpRequestException exception) { if (exception.Message.Contains("403 (Forbidden)")) { - await imsg.Channel.SendMessageAsync("Daily limit reached!"); + await channel.SendMessageAsync("Daily limit reached!"); } else { - await imsg.Channel.SendMessageAsync("Something went wrong."); + await channel.SendMessageAsync("Something went wrong."); } } } @@ -183,7 +183,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】 if (string.IsNullOrWhiteSpace(ffs)) return; - await imsg.Channel.SendMessageAsync(await $"".ShortenUrl()) + await channel.SendMessageAsync(await $"".ShortenUrl()) .ConfigureAwait(false); } @@ -197,7 +197,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】 terms = terms?.Trim(); if (string.IsNullOrWhiteSpace(terms)) return; - await imsg.Channel.SendMessageAsync($"https://google.com/search?q={ WebUtility.UrlEncode(terms).Replace(' ', '+') }") + await channel.SendMessageAsync($"https://google.com/search?q={ WebUtility.UrlEncode(terms).Replace(' ', '+') }") .ConfigureAwait(false); } ////todo drawing @@ -209,7 +209,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】 // var arg = e.GetArg("name"); // if (string.IsNullOrWhiteSpace(arg)) // { - // await imsg.Channel.SendMessageAsync("πŸ’’ Please enter a card name to search for.").ConfigureAwait(false); + // await channel.SendMessageAsync("πŸ’’ Please enter a card name to search for.").ConfigureAwait(false); // return; // } // await imsg.Channel.TriggerTypingAsync().ConfigureAwait(false); @@ -234,14 +234,14 @@ $@"🌍 **Weather for** 【{obj["target"]}】 // } // if (items.Count > 4) // { - // await imsg.Channel.SendMessageAsync("⚠ Found over 4 images. Showing random 4.").ConfigureAwait(false); + // await channel.SendMessageAsync("⚠ Found over 4 images. Showing random 4.").ConfigureAwait(false); // } - // await imsg.Channel.SendMessageAsync(arg + ".png", (await images.MergeAsync()).ToStream(System.Drawing.Imaging.ImageFormat.Png)) + // await channel.SendMessageAsync(arg + ".png", (await images.MergeAsync()).ToStream(System.Drawing.Imaging.ImageFormat.Png)) // .ConfigureAwait(false); // } // catch (Exception ex) // { - // await imsg.Channel.SendMessageAsync($"πŸ’’ Error {ex.Message}").ConfigureAwait(false); + // await channel.SendMessageAsync($"πŸ’’ Error {ex.Message}").ConfigureAwait(false); // } // } //} @@ -255,7 +255,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】 var arg = query; if (string.IsNullOrWhiteSpace(arg)) { - await imsg.Channel.SendMessageAsync("πŸ’’ Please enter a search term.").ConfigureAwait(false); + await channel.SendMessageAsync("πŸ’’ Please enter a search term.").ConfigureAwait(false); return; } await imsg.Channel.TriggerTypingAsync().ConfigureAwait(false); @@ -271,11 +271,11 @@ $@"🌍 **Weather for** 【{obj["target"]}】 sb.AppendLine($"`Term:` {items["list"][0]["word"].ToString()}"); sb.AppendLine($"`Definition:` {items["list"][0]["definition"].ToString()}"); sb.Append($"`Link:` <{await items["list"][0]["permalink"].ToString().ShortenUrl().ConfigureAwait(false)}>"); - await imsg.Channel.SendMessageAsync(sb.ToString()); + await channel.SendMessageAsync(sb.ToString()); } catch { - await imsg.Channel.SendMessageAsync("πŸ’’ Failed finding a definition for that term.").ConfigureAwait(false); + await channel.SendMessageAsync("πŸ’’ Failed finding a definition for that term.").ConfigureAwait(false); } } } @@ -289,7 +289,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】 var arg = query; if (string.IsNullOrWhiteSpace(arg)) { - await imsg.Channel.SendMessageAsync("πŸ’’ Please enter a search term.").ConfigureAwait(false); + await channel.SendMessageAsync("πŸ’’ Please enter a search term.").ConfigureAwait(false); return; } await imsg.Channel.TriggerTypingAsync().ConfigureAwait(false); @@ -307,11 +307,11 @@ $@"🌍 **Weather for** 【{obj["target"]}】 var str = $@"`Hashtag:` {items["defs"]["def"]["hashtag"].ToString()} `Definition:` {items["defs"]["def"]["text"].ToString()} `Link:` <{await items["defs"]["def"]["uri"].ToString().ShortenUrl().ConfigureAwait(false)}>"; - await imsg.Channel.SendMessageAsync(str); + await channel.SendMessageAsync(str); } catch { - await imsg.Channel.SendMessageAsync("πŸ’’ Failed finding a definition for that tag.").ConfigureAwait(false); + await channel.SendMessageAsync("πŸ’’ Failed finding a definition for that tag.").ConfigureAwait(false); } } //todo DB @@ -322,7 +322,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】 // var channel = imsg.Channel as ITextChannel; // var quote = NadekoBot.Config.Quotes[rng.Next(0, NadekoBot.Config.Quotes.Count)].ToString(); - // await imsg.Channel.SendMessageAsync(quote).ConfigureAwait(false); + // await channel.SendMessageAsync(quote).ConfigureAwait(false); //} [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -335,7 +335,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】 var response = await http.GetStringAsync("http://catfacts-api.appspot.com/api/facts").ConfigureAwait(false); if (response == null) return; - await imsg.Channel.SendMessageAsync($"🐈 `{JObject.Parse(response)["facts"][0].ToString()}`").ConfigureAwait(false); + await channel.SendMessageAsync($"🐈 `{JObject.Parse(response)["facts"][0].ToString()}`").ConfigureAwait(false); } } @@ -353,7 +353,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】 if (usr == null || string.IsNullOrWhiteSpace(usr.AvatarUrl)) return; - await imsg.Channel.SendMessageAsync($"https://images.google.com/searchbyimage?image_url={usr.AvatarUrl}").ConfigureAwait(false); + await channel.SendMessageAsync($"https://images.google.com/searchbyimage?image_url={usr.AvatarUrl}").ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -365,7 +365,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】 if (string.IsNullOrWhiteSpace(imageLink)) return; - await imsg.Channel.SendMessageAsync($"https://images.google.com/searchbyimage?image_url={imageLink}").ConfigureAwait(false); + await channel.SendMessageAsync($"https://images.google.com/searchbyimage?image_url={imageLink}").ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -377,9 +377,9 @@ $@"🌍 **Weather for** 【{obj["target"]}】 tag = tag?.Trim() ?? ""; var link = await GetSafebooruImageLink(tag).ConfigureAwait(false); if (link == null) - await imsg.Channel.SendMessageAsync("`No results.`"); + await channel.SendMessageAsync("`No results.`"); else - await imsg.Channel.SendMessageAsync(link).ConfigureAwait(false); + await channel.SendMessageAsync(link).ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -396,9 +396,9 @@ $@"🌍 **Weather for** 【{obj["target"]}】 var result = await http.GetStringAsync("https://en.wikipedia.org//w/api.php?action=query&format=json&prop=info&redirects=1&formatversion=2&inprop=url&titles=" + Uri.EscapeDataString(query)); var data = JsonConvert.DeserializeObject(result); if (data.Query.Pages[0].Missing) - await imsg.Channel.SendMessageAsync("`That page could not be found.`"); + await channel.SendMessageAsync("`That page could not be found.`"); else - await imsg.Channel.SendMessageAsync(data.Query.Pages[0].FullUrl); + await channel.SendMessageAsync(data.Query.Pages[0].FullUrl); } } @@ -425,7 +425,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】 // g.Flush(); // } - // await imsg.Channel.SendFileAsync("arg1.png", img.ToStream()); + // await channel.SendFileAsync("arg1.png", img.ToStream()); //} [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -460,10 +460,10 @@ $@"🌍 **Weather for** 【{obj["target"]}】 var usr = imsg.MentionedUsers.FirstOrDefault(); if (usr == null) { - await imsg.Channel.SendMessageAsync("Invalid user specified.").ConfigureAwait(false); + await channel.SendMessageAsync("Invalid user specified.").ConfigureAwait(false); return; } - await imsg.Channel.SendMessageAsync(await usr.AvatarUrl.ShortenUrl()).ConfigureAwait(false); + await channel.SendMessageAsync(await usr.AvatarUrl.ShortenUrl()).ConfigureAwait(false); } public static async Task GetSafebooruImageLink(string tag) diff --git a/src/NadekoBot/Modules/Translator/Translator.cs b/src/NadekoBot/Modules/Translator/Translator.cs index 9c6ca537..430ee760 100644 --- a/src/NadekoBot/Modules/Translator/Translator.cs +++ b/src/NadekoBot/Modules/Translator/Translator.cs @@ -34,12 +34,12 @@ namespace NadekoBot.Modules.Translator await imsg.Channel.TriggerTypingAsync().ConfigureAwait(false); string translation = await GoogleTranslator.Instance.Translate(text, from, to).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync(translation).ConfigureAwait(false); + await channel.SendMessageAsync(translation).ConfigureAwait(false); } catch (Exception ex) { Console.WriteLine(ex); - await imsg.Channel.SendMessageAsync("Bad input format, or something went wrong...").ConfigureAwait(false); + await channel.SendMessageAsync("Bad input format, or something went wrong...").ConfigureAwait(false); } } @@ -49,7 +49,7 @@ namespace NadekoBot.Modules.Translator { var channel = imsg.Channel as ITextChannel; - await imsg.Channel.SendTableAsync(GoogleTranslator.Instance.Languages, str => str, columns: 4); + await channel.SendTableAsync(GoogleTranslator.Instance.Languages, str => str, columns: 4); } } diff --git a/src/NadekoBot/Modules/Trello/Trello.cs b/src/NadekoBot/Modules/Trello/Trello.cs index 29bc4ea2..4af06285 100644 --- a/src/NadekoBot/Modules/Trello/Trello.cs +++ b/src/NadekoBot/Modules/Trello/Trello.cs @@ -82,7 +82,7 @@ // bound = e.Channel; // board = new Board(e.GetArg("board_id").Trim()); // board.Refresh(); -// await imsg.Channel.SendMessageAsync("Successfully bound to this channel and board " + board.Name); +// await channel.SendMessageAsync("Successfully bound to this channel and board " + board.Name); // t.Start(); // } // catch (Exception ex) @@ -100,7 +100,7 @@ // t.Stop(); // bound = null; // board = null; -// await imsg.Channel.SendMessageAsync("Successfully unbound trello from this channel.").ConfigureAwait(false); +// await channel.SendMessageAsync("Successfully unbound trello from this channel.").ConfigureAwait(false); // }); @@ -111,7 +111,7 @@ // { // if (!NadekoBot.IsOwner(e.User.Id)) return; // if (bound == null || board == null || bound != e.Channel) return; -// await imsg.Channel.SendMessageAsync("Lists for a board '" + board.Name + "'\n" + string.Join("\n", board.Lists.Select(l => "**β€’ " + l.ToString() + "**"))) +// await channel.SendMessageAsync("Lists for a board '" + board.Name + "'\n" + string.Join("\n", board.Lists.Select(l => "**β€’ " + l.ToString() + "**"))) // .ConfigureAwait(false); // }); @@ -133,10 +133,10 @@ // if (list != null) -// await imsg.Channel.SendMessageAsync("There are " + list.Cards.Count() + " cards in a **" + list.Name + "** list\n" + string.Join("\n", list.Cards.Select(c => "**β€’ " + c.ToString() + "**"))) +// await channel.SendMessageAsync("There are " + list.Cards.Count() + " cards in a **" + list.Name + "** list\n" + string.Join("\n", list.Cards.Select(c => "**β€’ " + c.ToString() + "**"))) // .ConfigureAwait(false); // else -// await imsg.Channel.SendMessageAsync("No such list.") +// await channel.SendMessageAsync("No such list.") // .ConfigureAwait(false); // }); // }); diff --git a/src/NadekoBot/Modules/Utility/Commands/Remind.cs b/src/NadekoBot/Modules/Utility/Commands/Remind.cs index 8ad7ea55..4f4bea7f 100644 --- a/src/NadekoBot/Modules/Utility/Commands/Remind.cs +++ b/src/NadekoBot/Modules/Utility/Commands/Remind.cs @@ -113,7 +113,7 @@ // if (ch == null) // { -// await imsg.Channel.SendMessageAsync($"{e.User.Mention} Something went wrong (channel cannot be found) ;(").ConfigureAwait(false); +// await channel.SendMessageAsync($"{e.User.Mention} Something went wrong (channel cannot be found) ;(").ConfigureAwait(false); // return; // } @@ -123,7 +123,7 @@ // if (m.Length == 0) // { -// await imsg.Channel.SendMessageAsync("Not a valid time format blablabla").ConfigureAwait(false); +// await channel.SendMessageAsync("Not a valid time format blablabla").ConfigureAwait(false); // return; // } @@ -148,7 +148,7 @@ // (groupName == "hours" && value > 23) || // (groupName == "minutes" && value > 59)) // { -// await imsg.Channel.SendMessageAsync($"Invalid {groupName} value.").ConfigureAwait(false); +// await channel.SendMessageAsync($"Invalid {groupName} value.").ConfigureAwait(false); // return; // } // else @@ -175,7 +175,7 @@ // reminders.Add(StartNewReminder(rem)); -// await imsg.Channel.SendMessageAsync($"⏰ I will remind \"{ch.Name}\" to \"{e.GetArg("message").ToString()}\" in {output}. ({time:d.M.yyyy.} at {time:HH:mm})").ConfigureAwait(false); +// await channel.SendMessageAsync($"⏰ I will remind \"{ch.Name}\" to \"{e.GetArg("message").ToString()}\" in {output}. ({time:d.M.yyyy.} at {time:HH:mm})").ConfigureAwait(false); // }); // cgb.CreateCommand(Module.Prefix + "remindmsg") // .Description("Sets message for when the remind is triggered. " + @@ -190,7 +190,7 @@ // return; // NadekoBot.Config.RemindMessageFormat = arg; -// await imsg.Channel.SendMessageAsync("`New remind message set.`"); +// await channel.SendMessageAsync("`New remind message set.`"); // }); // } // } diff --git a/src/NadekoBot/Modules/Utility/Utility.cs b/src/NadekoBot/Modules/Utility/Utility.cs index b88fe48b..63cb2d13 100644 --- a/src/NadekoBot/Modules/Utility/Utility.cs +++ b/src/NadekoBot/Modules/Utility/Utility.cs @@ -37,9 +37,9 @@ namespace NadekoBot.Modules.Utility int i = 0; if (!arr.Any()) - await imsg.Channel.SendMessageAsync(_l["`Nobody is playing that game.`"]).ConfigureAwait(false); + await channel.SendMessageAsync(_l["`Nobody is playing that game.`"]).ConfigureAwait(false); else - await imsg.Channel.SendMessageAsync("```xl\n" + string.Join("\n", arr.GroupBy(item => (i++) / 3).Select(ig => string.Concat(ig.Select(el => $"β€’ {el,-35}")))) + "\n```").ConfigureAwait(false); + await channel.SendMessageAsync("```xl\n" + string.Join("\n", arr.GroupBy(item => (i++) / 3).Select(ig => string.Concat(ig.Select(el => $"β€’ {el,-35}")))) + "\n```").ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] @@ -63,16 +63,16 @@ namespace NadekoBot.Modules.Utility { if (!usr.GetPermissions(channel).ManageMessages) { - await imsg.Channel.SendMessageAsync($"{usr.Mention} you are not allowed to use this command on roles with a lot of users in them to prevent abuse."); + await channel.SendMessageAsync($"{usr.Mention} you are not allowed to use this command on roles with a lot of users in them to prevent abuse."); return; } var curstr = send.Substring(0, 2000); - await imsg.Channel.SendMessageAsync(curstr.Substring(0, + await channel.SendMessageAsync(curstr.Substring(0, curstr.LastIndexOf(", ", StringComparison.Ordinal) + 1)).ConfigureAwait(false); send = curstr.Substring(curstr.LastIndexOf(", ", StringComparison.Ordinal) + 1) + send.Substring(2000); } - await imsg.Channel.SendMessageAsync(send).ConfigureAwait(false); + await channel.SendMessageAsync(send).ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary] diff --git a/src/NadekoBot/_Modules/CustomReactions/CustomReactions.cs b/src/NadekoBot/_Modules/CustomReactions/CustomReactions.cs index 96826ac5..81a59f2f 100644 --- a/src/NadekoBot/_Modules/CustomReactions/CustomReactions.cs +++ b/src/NadekoBot/_Modules/CustomReactions/CustomReactions.cs @@ -58,7 +58,7 @@ namespace NadekoBot.Modules.CustomReactions commandFuncs.Keys.ForEach(key => str = key.Replace(str, m => commandFuncs[key](e, m))); - await imsg.Channel.SendMessageAsync(str).ConfigureAwait(false); + await channel.SendMessageAsync(str).ConfigureAwait(false); }); } }); diff --git a/src/NadekoBot/_Modules/Music/MusicModule.cs b/src/NadekoBot/_Modules/Music/MusicModule.cs index dfde594b..e89094d2 100644 --- a/src/NadekoBot/_Modules/Music/MusicModule.cs +++ b/src/NadekoBot/_Modules/Music/MusicModule.cs @@ -92,9 +92,9 @@ namespace NadekoBot.Modules.Music return; musicPlayer.TogglePause(); if (musicPlayer.Paused) - await imsg.Channel.SendMessageAsync("🎡`Music Player paused.`").ConfigureAwait(false); + await channel.SendMessageAsync("🎡`Music Player paused.`").ConfigureAwait(false); else - await imsg.Channel.SendMessageAsync("🎡`Music Player unpaused.`").ConfigureAwait(false); + await channel.SendMessageAsync("🎡`Music Player unpaused.`").ConfigureAwait(false); }); cgb.CreateCommand(Prefix + "queue") @@ -137,7 +137,7 @@ namespace NadekoBot.Modules.Music MusicPlayer musicPlayer; if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer)) { - await imsg.Channel.SendMessageAsync("🎡 No active music player.").ConfigureAwait(false); + await channel.SendMessageAsync("🎡 No active music player.").ConfigureAwait(false); return; } @@ -163,7 +163,7 @@ namespace NadekoBot.Modules.Music const int itemsPerPage = 15; int startAt = itemsPerPage * (page - 1); var number = 1 + startAt; - await imsg.Channel.SendMessageAsync(toSend + string.Join("\n", musicPlayer.Playlist.Skip(startAt).Take(15).Select(v => $"`{number++}.` {v.PrettyName}"))).ConfigureAwait(false); + await channel.SendMessageAsync(toSend + string.Join("\n", musicPlayer.Playlist.Skip(startAt).Take(15).Select(v => $"`{number++}.` {v.PrettyName}"))).ConfigureAwait(false); }); cgb.CreateCommand(Prefix + "nowplaying") @@ -177,7 +177,7 @@ namespace NadekoBot.Modules.Music var currentSong = musicPlayer.CurrentSong; if (currentSong == null) return; - await imsg.Channel.SendMessageAsync($"🎡`Now Playing` {currentSong.PrettyName} " + + await channel.SendMessageAsync($"🎡`Now Playing` {currentSong.PrettyName} " + $"{currentSong.PrettyCurrentTime()}").ConfigureAwait(false); }); @@ -196,11 +196,11 @@ namespace NadekoBot.Modules.Music int volume; if (!int.TryParse(arg, out volume)) { - await imsg.Channel.SendMessageAsync("Volume number invalid.").ConfigureAwait(false); + await channel.SendMessageAsync("Volume number invalid.").ConfigureAwait(false); return; } volume = musicPlayer.SetVolume(volume); - await imsg.Channel.SendMessageAsync($"🎡 `Volume set to {volume}%`").ConfigureAwait(false); + await channel.SendMessageAsync($"🎡 `Volume set to {volume}%`").ConfigureAwait(false); }); cgb.CreateCommand(Prefix + "defvol") @@ -214,12 +214,12 @@ namespace NadekoBot.Modules.Music float volume; if (!float.TryParse(arg, out volume) || volume < 0 || volume > 100) { - await imsg.Channel.SendMessageAsync("Volume number invalid.").ConfigureAwait(false); + await channel.SendMessageAsync("Volume number invalid.").ConfigureAwait(false); return; } var conf = SpecificConfigurations.Default.Of(e.Server.Id); conf.DefaultMusicVolume = volume / 100; - await imsg.Channel.SendMessageAsync($"🎡 `Default volume set to {volume}%`").ConfigureAwait(false); + await channel.SendMessageAsync($"🎡 `Default volume set to {volume}%`").ConfigureAwait(false); }); cgb.CreateCommand(Prefix + "mute") @@ -271,12 +271,12 @@ namespace NadekoBot.Modules.Music return; if (musicPlayer.Playlist.Count < 2) { - await imsg.Channel.SendMessageAsync("πŸ’’ Not enough songs in order to perform the shuffle.").ConfigureAwait(false); + await channel.SendMessageAsync("πŸ’’ Not enough songs in order to perform the shuffle.").ConfigureAwait(false); return; } musicPlayer.Shuffle(); - await imsg.Channel.SendMessageAsync("🎡 `Songs shuffled.`").ConfigureAwait(false); + await channel.SendMessageAsync("🎡 `Songs shuffled.`").ConfigureAwait(false); }); cgb.CreateCommand(Prefix + "playlist") @@ -290,25 +290,25 @@ namespace NadekoBot.Modules.Music return; if (e.User.VoiceChannel?.Server != e.Server) { - await imsg.Channel.SendMessageAsync("πŸ’’ You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining it.").ConfigureAwait(false); + await channel.SendMessageAsync("πŸ’’ You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining it.").ConfigureAwait(false); return; } var plId = await SearchHelper.GetPlaylistIdByKeyword(arg).ConfigureAwait(false); if (plId == null) { - await imsg.Channel.SendMessageAsync("No search results for that query."); + await channel.SendMessageAsync("No search results for that query."); return; } var ids = await SearchHelper.GetVideoIDs(plId, 500).ConfigureAwait(false); if (ids == null || ids.Count == 0) { - await imsg.Channel.SendMessageAsync($"🎡 `Failed to find any songs.`").ConfigureAwait(false); + await channel.SendMessageAsync($"🎡 `Failed to find any songs.`").ConfigureAwait(false); return; } var idArray = ids as string[] ?? ids.ToArray(); var count = idArray.Length; var msg = - await imsg.Channel.SendMessageAsync($"🎡 `Attempting to queue {count} songs".SnPl(count) + "...`").ConfigureAwait(false); + await channel.SendMessageAsync($"🎡 `Attempting to queue {count} songs".SnPl(count) + "...`").ConfigureAwait(false); foreach (var id in idArray) { try @@ -383,7 +383,7 @@ namespace NadekoBot.Modules.Music } catch { } } - await imsg.Channel.SendMessageAsync("🎡 `Directory queue complete.`").ConfigureAwait(false); + await channel.SendMessageAsync("🎡 `Directory queue complete.`").ConfigureAwait(false); } catch { } }); @@ -395,7 +395,7 @@ namespace NadekoBot.Modules.Music { if (e.User.VoiceChannel?.Server != e.Server) { - await imsg.Channel.SendMessageAsync("πŸ’’ You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining it.").ConfigureAwait(false); + await channel.SendMessageAsync("πŸ’’ You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining it.").ConfigureAwait(false); return; } await QueueSong(e.User, e.Channel, e.User.VoiceChannel, e.GetArg("radio_link"), musicType: MusicType.Radio).ConfigureAwait(false); @@ -448,7 +448,7 @@ namespace NadekoBot.Modules.Music if (arg?.ToLower() == "all") { musicPlayer.ClearQueue(); - await imsg.Channel.SendMessageAsync($"🎡`Queue cleared!`").ConfigureAwait(false); + await channel.SendMessageAsync($"🎡`Queue cleared!`").ConfigureAwait(false); return; } int num; @@ -460,7 +460,7 @@ namespace NadekoBot.Modules.Music return; var song = (musicPlayer.Playlist as List)?[num - 1]; musicPlayer.RemoveSongAt(num - 1); - await imsg.Channel.SendMessageAsync($"🎡**Track {song.PrettyName} at position `#{num}` has been removed.**").ConfigureAwait(false); + await channel.SendMessageAsync($"🎡**Track {song.PrettyName} at position `#{num}` has been removed.**").ConfigureAwait(false); }); //var msRegex = new Regex(@"(?\d+)>(?\d+)", RegexOptions.Compiled); @@ -487,7 +487,7 @@ namespace NadekoBot.Modules.Music !int.TryParse(fromtoArr[1], out n2) || n1 < 1 || n2 < 1 || n1 == n2 || n1 > playlist.Count || n2 > playlist.Count) { - await imsg.Channel.SendMessageAsync("`Invalid input.`").ConfigureAwait(false); + await channel.SendMessageAsync("`Invalid input.`").ConfigureAwait(false); return; } @@ -496,7 +496,7 @@ namespace NadekoBot.Modules.Music var nn1 = n2 < n1 ? n1 : n1 - 1; playlist.RemoveAt(nn1); - await imsg.Channel.SendMessageAsync($"🎡`Moved` {s.PrettyName} `from #{n1} to #{n2}`").ConfigureAwait(false); + await channel.SendMessageAsync($"🎡`Moved` {s.PrettyName} `from #{n1} to #{n2}`").ConfigureAwait(false); }); @@ -520,7 +520,7 @@ namespace NadekoBot.Modules.Music } musicPlayer.MaxQueueSize = size; - await imsg.Channel.SendMessageAsync($"🎡 `Max queue set to {(size == 0 ? ("unlimited") : size + " tracks")}`"); + await channel.SendMessageAsync($"🎡 `Max queue set to {(size == 0 ? ("unlimited") : size + " tracks")}`"); }); cgb.CreateCommand(Prefix + "cleanup") @@ -553,7 +553,7 @@ namespace NadekoBot.Modules.Music if (currentSong == null) return; var currentValue = musicPlayer.ToggleRepeatSong(); - await imsg.Channel.SendMessageAsync(currentValue ? + await channel.SendMessageAsync(currentValue ? $"πŸŽ΅πŸ”‚`Repeating track:`{currentSong.PrettyName}" : $"πŸŽ΅πŸ”‚`Current track repeat stopped.`") .ConfigureAwait(false); @@ -568,7 +568,7 @@ namespace NadekoBot.Modules.Music if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer)) return; var currentValue = musicPlayer.ToggleRepeatPlaylist(); - await imsg.Channel.SendMessageAsync($"πŸŽ΅πŸ”`Repeat playlist {(currentValue ? "enabled" : "disabled")}`").ConfigureAwait(false); + await channel.SendMessageAsync($"πŸŽ΅πŸ”`Repeat playlist {(currentValue ? "enabled" : "disabled")}`").ConfigureAwait(false); }); cgb.CreateCommand(Prefix + "save") @@ -620,7 +620,7 @@ namespace NadekoBot.Modules.Music SongInfoId = s.Id.Value }), typeof(PlaylistSongInfo)); - await imsg.Channel.SendMessageAsync($"🎡 `Saved playlist as {name}-{playlist.Id}`").ConfigureAwait(false); + await channel.SendMessageAsync($"🎡 `Saved playlist as {name}-{playlist.Id}`").ConfigureAwait(false); }); @@ -655,7 +655,7 @@ namespace NadekoBot.Modules.Music if (playlist == null) { - await imsg.Channel.SendMessageAsync("Can't find playlist under that name.").ConfigureAwait(false); + await channel.SendMessageAsync("Can't find playlist under that name.").ConfigureAwait(false); return; } @@ -665,7 +665,7 @@ namespace NadekoBot.Modules.Music var songInfos = psis.Select(psi => DbHandler.Instance .FindOne(si => si.Id == psi.SongInfoId)); - await imsg.Channel.SendMessageAsync($"`Attempting to load {songInfos.Count()} songs`").ConfigureAwait(false); + await channel.SendMessageAsync($"`Attempting to load {songInfos.Count()} songs`").ConfigureAwait(false); foreach (var si in songInfos) { try @@ -695,9 +695,9 @@ namespace NadekoBot.Modules.Music return; var result = DbHandler.Instance.GetPlaylistData(num); if (result.Count == 0) - imsg.Channel.SendMessageAsync($"`No saved playlists found on page {num}`").ConfigureAwait(false); + channel.SendMessageAsync($"`No saved playlists found on page {num}`").ConfigureAwait(false); else - imsg.Channel.SendMessageAsync($"```js\n--- List of saved playlists ---\n\n" + string.Join("\n", result.Select(r => $"'{r.Name}-{r.Id}' by {r.Creator} ({r.SongCnt} songs)")) + $"\n\n --- Page {num} ---```").ConfigureAwait(false); + channel.SendMessageAsync($"```js\n--- List of saved playlists ---\n\n" + string.Join("\n", result.Select(r => $"'{r.Name}-{r.Id}' by {r.Creator} ({r.SongCnt} songs)")) + $"\n\n --- Page {num} ---```").ConfigureAwait(false); }); cgb.CreateCommand(Prefix + "deleteplaylist") @@ -714,7 +714,7 @@ namespace NadekoBot.Modules.Music DbHandler.Instance.Delete(plnum); else DbHandler.Instance.DeleteWhere(mp => mp.Id == plnum && (long)e.User.Id == mp.CreatorId); - await imsg.Channel.SendMessageAsync("`Ok.` :ok:").ConfigureAwait(false); + await channel.SendMessageAsync("`Ok.` :ok:").ConfigureAwait(false); }); cgb.CreateCommand(Prefix + "goto") @@ -751,7 +751,7 @@ namespace NadekoBot.Modules.Music if (seconds.Length == 1) seconds = "0" + seconds; - await imsg.Channel.SendMessageAsync($"`Skipped to {minutes}:{seconds}`").ConfigureAwait(false); + await channel.SendMessageAsync($"`Skipped to {minutes}:{seconds}`").ConfigureAwait(false); }); cgb.CreateCommand(Prefix + "getlink") @@ -771,12 +771,12 @@ namespace NadekoBot.Modules.Music var selSong = musicPlayer.Playlist.DefaultIfEmpty(null).ElementAtOrDefault(index - 1); if (selSong == null) { - await imsg.Channel.SendMessageAsync("Could not select song, likely wrong index"); + await channel.SendMessageAsync("Could not select song, likely wrong index"); } else { - await imsg.Channel.SendMessageAsync($"🎢`Selected song {selSong.SongInfo.Title}:` <{selSong.SongInfo.Query}>").ConfigureAwait(false); + await channel.SendMessageAsync($"🎢`Selected song {selSong.SongInfo.Title}:` <{selSong.SongInfo.Query}>").ConfigureAwait(false); } } else @@ -784,7 +784,7 @@ namespace NadekoBot.Modules.Music var curSong = musicPlayer.CurrentSong; if (curSong == null) return; - await imsg.Channel.SendMessageAsync($"🎢`Current song:` <{curSong.SongInfo.Query}>").ConfigureAwait(false); + await channel.SendMessageAsync($"🎢`Current song:` <{curSong.SongInfo.Query}>").ConfigureAwait(false); } }); @@ -800,9 +800,9 @@ namespace NadekoBot.Modules.Music return; if (!musicPlayer.ToggleAutoplay()) - await imsg.Channel.SendMessageAsync("🎢`Autoplay disabled.`").ConfigureAwait(false); + await channel.SendMessageAsync("🎢`Autoplay disabled.`").ConfigureAwait(false); else - await imsg.Channel.SendMessageAsync("🎢`Autoplay enabled.`").ConfigureAwait(false); + await channel.SendMessageAsync("🎢`Autoplay enabled.`").ConfigureAwait(false); }); }); } diff --git a/src/NadekoBot/_Modules/Permissions/Commands/FilterInvitesCommand.cs b/src/NadekoBot/_Modules/Permissions/Commands/FilterInvitesCommand.cs index 80772f43..47ba8b53 100644 --- a/src/NadekoBot/_Modules/Permissions/Commands/FilterInvitesCommand.cs +++ b/src/NadekoBot/_Modules/Permissions/Commands/FilterInvitesCommand.cs @@ -72,7 +72,7 @@ namespace NadekoBot.Modules.Permissions.Commands ? e.Channel : PermissionHelper.ValidateChannel(e.Server, chanStr); await PermissionsHandler.SetChannelFilterInvitesPermission(chan, state).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Invite Filter has been **{(state ? "enabled" : "disabled")}** for **{chan.Name}** channel.") + await channel.SendMessageAsync($"Invite Filter has been **{(state ? "enabled" : "disabled")}** for **{chan.Name}** channel.") .ConfigureAwait(false); return; } @@ -82,13 +82,13 @@ namespace NadekoBot.Modules.Permissions.Commands { await PermissionsHandler.SetChannelFilterInvitesPermission(curChannel, state).ConfigureAwait(false); } - await imsg.Channel.SendMessageAsync($"Invite Filter has been **{(state ? "enabled" : "disabled")}** for **ALL** channels.") + await channel.SendMessageAsync($"Invite Filter has been **{(state ? "enabled" : "disabled")}** for **ALL** channels.") .ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync($"πŸ’’ Error: {ex.Message}") + await channel.SendMessageAsync($"πŸ’’ Error: {ex.Message}") .ConfigureAwait(false); } }); @@ -103,13 +103,13 @@ namespace NadekoBot.Modules.Permissions.Commands { var state = PermissionHelper.ValidateBool(e.GetArg("bool")); await PermissionsHandler.SetServerFilterInvitesPermission(e.Server, state).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Invite Filter has been **{(state ? "enabled" : "disabled")}** for this server.") + await channel.SendMessageAsync($"Invite Filter has been **{(state ? "enabled" : "disabled")}** for this server.") .ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync($"πŸ’’ Error: {ex.Message}").ConfigureAwait(false); + await channel.SendMessageAsync($"πŸ’’ Error: {ex.Message}").ConfigureAwait(false); } }); } diff --git a/src/NadekoBot/_Modules/Permissions/Commands/FilterWordsCommand.cs b/src/NadekoBot/_Modules/Permissions/Commands/FilterWordsCommand.cs index 0ba377e3..bd16354d 100644 --- a/src/NadekoBot/_Modules/Permissions/Commands/FilterWordsCommand.cs +++ b/src/NadekoBot/_Modules/Permissions/Commands/FilterWordsCommand.cs @@ -69,7 +69,7 @@ namespace NadekoBot.Modules.Permissions.Commands ? e.Channel : PermissionHelper.ValidateChannel(e.Server, chanStr); await PermissionsHandler.SetChannelWordPermission(chan, state).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Word filtering has been **{(state ? "enabled" : "disabled")}** for **{chan.Name}** channel.").ConfigureAwait(false); + await channel.SendMessageAsync($"Word filtering has been **{(state ? "enabled" : "disabled")}** for **{chan.Name}** channel.").ConfigureAwait(false); return; } //all channels @@ -78,11 +78,11 @@ namespace NadekoBot.Modules.Permissions.Commands { await PermissionsHandler.SetChannelWordPermission(curChannel, state).ConfigureAwait(false); } - await imsg.Channel.SendMessageAsync($"Word filtering has been **{(state ? "enabled" : "disabled")}** for **ALL** channels.").ConfigureAwait(false); + await channel.SendMessageAsync($"Word filtering has been **{(state ? "enabled" : "disabled")}** for **ALL** channels.").ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync($"πŸ’’ Error: {ex.Message}").ConfigureAwait(false); + await channel.SendMessageAsync($"πŸ’’ Error: {ex.Message}").ConfigureAwait(false); } }); @@ -99,12 +99,12 @@ namespace NadekoBot.Modules.Permissions.Commands if (string.IsNullOrWhiteSpace(word)) return; await PermissionsHandler.AddFilteredWord(e.Server, word.ToLowerInvariant().Trim()).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Successfully added new filtered word.").ConfigureAwait(false); + await channel.SendMessageAsync($"Successfully added new filtered word.").ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync($"πŸ’’ Error: {ex.Message}").ConfigureAwait(false); + await channel.SendMessageAsync($"πŸ’’ Error: {ex.Message}").ConfigureAwait(false); } }); @@ -121,12 +121,12 @@ namespace NadekoBot.Modules.Permissions.Commands if (string.IsNullOrWhiteSpace(word)) return; await PermissionsHandler.RemoveFilteredWord(e.Server, word.ToLowerInvariant().Trim()).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Successfully removed filtered word.").ConfigureAwait(false); + await channel.SendMessageAsync($"Successfully removed filtered word.").ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync($"πŸ’’ Error: {ex.Message}").ConfigureAwait(false); + await channel.SendMessageAsync($"πŸ’’ Error: {ex.Message}").ConfigureAwait(false); } }); @@ -141,12 +141,12 @@ namespace NadekoBot.Modules.Permissions.Commands Classes.ServerPermissions serverPerms; if (!PermissionsHandler.PermissionsDict.TryGetValue(e.Server.Id, out serverPerms)) return; - await imsg.Channel.SendMessageAsync($"There are `{serverPerms.Words.Count}` filtered words.\n" + + await channel.SendMessageAsync($"There are `{serverPerms.Words.Count}` filtered words.\n" + string.Join("\n", serverPerms.Words)).ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync($"πŸ’’ Error: {ex.Message}").ConfigureAwait(false); + await channel.SendMessageAsync($"πŸ’’ Error: {ex.Message}").ConfigureAwait(false); } }); @@ -160,13 +160,13 @@ namespace NadekoBot.Modules.Permissions.Commands { var state = PermissionHelper.ValidateBool(e.GetArg("bool")); await PermissionsHandler.SetServerWordPermission(e.Server, state).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Word filtering has been **{(state ? "enabled" : "disabled")}** on this server.") + await channel.SendMessageAsync($"Word filtering has been **{(state ? "enabled" : "disabled")}** on this server.") .ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync($"πŸ’’ Error: {ex.Message}").ConfigureAwait(false); + await channel.SendMessageAsync($"πŸ’’ Error: {ex.Message}").ConfigureAwait(false); } }); } diff --git a/src/NadekoBot/_Modules/Permissions/PermissionsModule.cs b/src/NadekoBot/_Modules/Permissions/PermissionsModule.cs index e1e15dbe..de616d1c 100644 --- a/src/NadekoBot/_Modules/Permissions/PermissionsModule.cs +++ b/src/NadekoBot/_Modules/Permissions/PermissionsModule.cs @@ -39,7 +39,7 @@ namespace NadekoBot.Modules.Permissions { if (string.IsNullOrWhiteSpace(e.GetArg("role"))) { - await imsg.Channel.SendMessageAsync($"Current permissions role is `{PermissionsHandler.GetServerPermissionsRoleName(e.Server)}`").ConfigureAwait(false); + await channel.SendMessageAsync($"Current permissions role is `{PermissionsHandler.GetServerPermissionsRoleName(e.Server)}`").ConfigureAwait(false); return; } @@ -52,11 +52,11 @@ namespace NadekoBot.Modules.Permissions catch (Exception ex) { Console.WriteLine(ex.Message); - await imsg.Channel.SendMessageAsync($"Role `{arg}` probably doesn't exist. Create the role with that name first.").ConfigureAwait(false); + await channel.SendMessageAsync($"Role `{arg}` probably doesn't exist. Create the role with that name first.").ConfigureAwait(false); return; } await PermissionsHandler.SetPermissionsRole(e.Server, role.Name).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Role `{role.Name}` is now required in order to change permissions.").ConfigureAwait(false); + await channel.SendMessageAsync($"Role `{role.Name}` is now required in order to change permissions.").ConfigureAwait(false); }); cgb.CreateCommand(Prefix + "rolepermscopy") @@ -71,7 +71,7 @@ namespace NadekoBot.Modules.Permissions var args = arg.Split('~').Select(a => a.Trim()).ToArray(); if (args.Length > 2) { - await imsg.Channel.SendMessageAsync("πŸ’’Invalid number of '~'s in the argument.").ConfigureAwait(false); + await channel.SendMessageAsync("πŸ’’Invalid number of '~'s in the argument.").ConfigureAwait(false); return; } try @@ -80,11 +80,11 @@ namespace NadekoBot.Modules.Permissions var toRole = PermissionHelper.ValidateRole(e.Server, args[1]); await PermissionsHandler.CopyRolePermissions(fromRole, toRole).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Copied permission settings from **{fromRole.Name}** to **{toRole.Name}**.").ConfigureAwait(false); + await channel.SendMessageAsync($"Copied permission settings from **{fromRole.Name}** to **{toRole.Name}**.").ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync($"πŸ’’{ex.Message}").ConfigureAwait(false); + await channel.SendMessageAsync($"πŸ’’{ex.Message}").ConfigureAwait(false); } }); cgb.CreateCommand(Prefix + "chnlpermscopy") @@ -99,7 +99,7 @@ namespace NadekoBot.Modules.Permissions var args = arg.Split('~').Select(a => a.Trim()).ToArray(); if (args.Length > 2) { - await imsg.Channel.SendMessageAsync("πŸ’’Invalid number of '~'s in the argument."); + await channel.SendMessageAsync("πŸ’’Invalid number of '~'s in the argument."); return; } try @@ -108,11 +108,11 @@ namespace NadekoBot.Modules.Permissions var toChannel = PermissionHelper.ValidateChannel(e.Server, args[1]); await PermissionsHandler.CopyChannelPermissions(fromChannel, toChannel).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Copied permission settings from **{fromChannel.Name}** to **{toChannel.Name}**.").ConfigureAwait(false); + await channel.SendMessageAsync($"Copied permission settings from **{fromChannel.Name}** to **{toChannel.Name}**.").ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync($"πŸ’’{ex.Message}"); + await channel.SendMessageAsync($"πŸ’’{ex.Message}"); } }); cgb.CreateCommand(Prefix + "usrpermscopy") @@ -127,7 +127,7 @@ namespace NadekoBot.Modules.Permissions var args = arg.Split('~').Select(a => a.Trim()).ToArray(); if (args.Length > 2) { - await imsg.Channel.SendMessageAsync("πŸ’’Invalid number of '~'s in the argument.").ConfigureAwait(false); + await channel.SendMessageAsync("πŸ’’Invalid number of '~'s in the argument.").ConfigureAwait(false); return; } try @@ -136,11 +136,11 @@ namespace NadekoBot.Modules.Permissions var toUser = PermissionHelper.ValidateUser(e.Server, args[1]); await PermissionsHandler.CopyUserPermissions(fromUser, toUser).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Copied permission settings from **{fromUser.ToString()}**to * *{toUser.ToString()}**.").ConfigureAwait(false); + await channel.SendMessageAsync($"Copied permission settings from **{fromUser.ToString()}**to * *{toUser.ToString()}**.").ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync($"πŸ’’{ex.Message}"); + await channel.SendMessageAsync($"πŸ’’{ex.Message}"); } }); @@ -153,7 +153,7 @@ namespace NadekoBot.Modules.Permissions var arg = e.GetArg("arg"); var val = PermissionHelper.ValidateBool(arg); await PermissionsHandler.SetVerbosity(e.Server, val).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Verbosity set to {val}.").ConfigureAwait(false); + await channel.SendMessageAsync($"Verbosity set to {val}.").ConfigureAwait(false); }); cgb.CreateCommand(Prefix + "srvrperms") @@ -163,8 +163,8 @@ namespace NadekoBot.Modules.Permissions { var perms = PermissionsHandler.GetServerPermissions(e.Server); if (string.IsNullOrWhiteSpace(perms?.ToString())) - await imsg.Channel.SendMessageAsync("No permissions set for this server.").ConfigureAwait(false); - await imsg.Channel.SendMessageAsync(perms.ToString()).ConfigureAwait(false); + await channel.SendMessageAsync("No permissions set for this server.").ConfigureAwait(false); + await channel.SendMessageAsync(perms.ToString()).ConfigureAwait(false); }); cgb.CreateCommand(Prefix + "roleperms") @@ -182,15 +182,15 @@ namespace NadekoBot.Modules.Permissions } catch (Exception ex) { - await imsg.Channel.SendMessageAsync("πŸ’’ Error: " + ex.Message).ConfigureAwait(false); + await channel.SendMessageAsync("πŸ’’ Error: " + ex.Message).ConfigureAwait(false); return; } var perms = PermissionsHandler.GetRolePermissionsById(e.Server, role.Id); if (string.IsNullOrWhiteSpace(perms?.ToString())) - await imsg.Channel.SendMessageAsync($"No permissions set for **{role.Name}** role.").ConfigureAwait(false); - await imsg.Channel.SendMessageAsync(perms.ToString()).ConfigureAwait(false); + await channel.SendMessageAsync($"No permissions set for **{role.Name}** role.").ConfigureAwait(false); + await channel.SendMessageAsync(perms.ToString()).ConfigureAwait(false); }); cgb.CreateCommand(Prefix + "chnlperms") @@ -208,14 +208,14 @@ namespace NadekoBot.Modules.Permissions } catch (Exception ex) { - await imsg.Channel.SendMessageAsync("πŸ’’ Error: " + ex.Message).ConfigureAwait(false); + await channel.SendMessageAsync("πŸ’’ Error: " + ex.Message).ConfigureAwait(false); return; } var perms = PermissionsHandler.GetChannelPermissionsById(e.Server, channel.Id); if (string.IsNullOrWhiteSpace(perms?.ToString())) - await imsg.Channel.SendMessageAsync($"No permissions set for **{channel.Name}** channel.").ConfigureAwait(false); - await imsg.Channel.SendMessageAsync(perms.ToString()).ConfigureAwait(false); + await channel.SendMessageAsync($"No permissions set for **{channel.Name}** channel.").ConfigureAwait(false); + await channel.SendMessageAsync(perms.ToString()).ConfigureAwait(false); }); cgb.CreateCommand(Prefix + "userperms") @@ -232,14 +232,14 @@ namespace NadekoBot.Modules.Permissions } catch (Exception ex) { - await imsg.Channel.SendMessageAsync("πŸ’’ Error: " + ex.Message).ConfigureAwait(false); + await channel.SendMessageAsync("πŸ’’ Error: " + ex.Message).ConfigureAwait(false); return; } var perms = PermissionsHandler.GetUserPermissionsById(e.Server, user.Id); if (string.IsNullOrWhiteSpace(perms?.ToString())) - await imsg.Channel.SendMessageAsync($"No permissions set for user **{user.Name}**.").ConfigureAwait(false); - await imsg.Channel.SendMessageAsync(perms.ToString()).ConfigureAwait(false); + await channel.SendMessageAsync($"No permissions set for user **{user.Name}**.").ConfigureAwait(false); + await channel.SendMessageAsync(perms.ToString()).ConfigureAwait(false); }); cgb.CreateCommand(Prefix + "srvrmdl") @@ -255,15 +255,15 @@ namespace NadekoBot.Modules.Permissions var state = PermissionHelper.ValidateBool(e.GetArg("bool")); await PermissionsHandler.SetServerModulePermission(e.Server, module, state).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** on this server.").ConfigureAwait(false); + await channel.SendMessageAsync($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** on this server.").ConfigureAwait(false); } catch (ArgumentException exArg) { - await imsg.Channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); + await channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); + await channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); } }); @@ -279,15 +279,15 @@ namespace NadekoBot.Modules.Permissions var state = PermissionHelper.ValidateBool(e.GetArg("bool")); await PermissionsHandler.SetServerCommandPermission(e.Server, command, state).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** on this server.").ConfigureAwait(false); + await channel.SendMessageAsync($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** on this server.").ConfigureAwait(false); } catch (ArgumentException exArg) { - await imsg.Channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); + await channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); + await channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); } }); @@ -309,23 +309,23 @@ namespace NadekoBot.Modules.Permissions { await PermissionsHandler.SetRoleModulePermission(role, module, state).ConfigureAwait(false); } - await imsg.Channel.SendMessageAsync($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **ALL** roles.").ConfigureAwait(false); + await channel.SendMessageAsync($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **ALL** roles.").ConfigureAwait(false); } else { var role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role")); await PermissionsHandler.SetRoleModulePermission(role, module, state).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.").ConfigureAwait(false); + await channel.SendMessageAsync($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.").ConfigureAwait(false); } } catch (ArgumentException exArg) { - await imsg.Channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); + await channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); + await channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); } }); @@ -347,23 +347,23 @@ namespace NadekoBot.Modules.Permissions { await PermissionsHandler.SetRoleCommandPermission(role, command, state).ConfigureAwait(false); } - await imsg.Channel.SendMessageAsync($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **ALL** roles.").ConfigureAwait(false); + await channel.SendMessageAsync($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **ALL** roles.").ConfigureAwait(false); } else { var role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role")); await PermissionsHandler.SetRoleCommandPermission(role, command, state).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.").ConfigureAwait(false); + await channel.SendMessageAsync($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.").ConfigureAwait(false); } } catch (ArgumentException exArg) { - await imsg.Channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); + await channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); + await channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); } }); @@ -385,28 +385,28 @@ namespace NadekoBot.Modules.Permissions { await PermissionsHandler.SetChannelModulePermission(channel, module, state).ConfigureAwait(false); } - await imsg.Channel.SendMessageAsync($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** on **ALL** channels.").ConfigureAwait(false); + await channel.SendMessageAsync($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** on **ALL** channels.").ConfigureAwait(false); } else if (string.IsNullOrWhiteSpace(channelArg)) { await PermissionsHandler.SetChannelModulePermission(e.Channel, module, state).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **{e.Channel.Name}** channel.").ConfigureAwait(false); + await channel.SendMessageAsync($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **{e.Channel.Name}** channel.").ConfigureAwait(false); } else { var channel = PermissionHelper.ValidateChannel(e.Server, channelArg); await PermissionsHandler.SetChannelModulePermission(channel, module, state).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.").ConfigureAwait(false); + await channel.SendMessageAsync($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.").ConfigureAwait(false); } } catch (ArgumentException exArg) { - await imsg.Channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); + await channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); + await channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); } }); @@ -428,23 +428,23 @@ namespace NadekoBot.Modules.Permissions { await PermissionsHandler.SetChannelCommandPermission(channel, command, state).ConfigureAwait(false); } - await imsg.Channel.SendMessageAsync($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** on **ALL** channels.").ConfigureAwait(false); + await channel.SendMessageAsync($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** on **ALL** channels.").ConfigureAwait(false); } else { var channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel")); await PermissionsHandler.SetChannelCommandPermission(channel, command, state).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.").ConfigureAwait(false); + await channel.SendMessageAsync($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.").ConfigureAwait(false); } } catch (ArgumentException exArg) { - await imsg.Channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); + await channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); + await channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); } }); @@ -462,15 +462,15 @@ namespace NadekoBot.Modules.Permissions var user = PermissionHelper.ValidateUser(e.Server, e.GetArg("user")); await PermissionsHandler.SetUserModulePermission(user, module, state).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for user **{user.Name}**.").ConfigureAwait(false); + await channel.SendMessageAsync($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for user **{user.Name}**.").ConfigureAwait(false); } catch (ArgumentException exArg) { - await imsg.Channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); + await channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); + await channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); } }); @@ -488,15 +488,15 @@ namespace NadekoBot.Modules.Permissions var user = PermissionHelper.ValidateUser(e.Server, e.GetArg("user")); await PermissionsHandler.SetUserCommandPermission(user, command, state).ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for user **{user.Name}**.").ConfigureAwait(false); + await channel.SendMessageAsync($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for user **{user.Name}**.").ConfigureAwait(false); } catch (ArgumentException exArg) { - await imsg.Channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); + await channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); + await channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); } }); @@ -513,15 +513,15 @@ namespace NadekoBot.Modules.Permissions { await PermissionsHandler.SetServerModulePermission(e.Server, module.Name, state).ConfigureAwait(false); } - await imsg.Channel.SendMessageAsync($"All modules have been **{(state ? "enabled" : "disabled")}** on this server.").ConfigureAwait(false); + await channel.SendMessageAsync($"All modules have been **{(state ? "enabled" : "disabled")}** on this server.").ConfigureAwait(false); } catch (ArgumentException exArg) { - await imsg.Channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); + await channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); + await channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); } }); @@ -540,15 +540,15 @@ namespace NadekoBot.Modules.Permissions { await PermissionsHandler.SetServerCommandPermission(e.Server, command.Text, state).ConfigureAwait(false); } - await imsg.Channel.SendMessageAsync($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** on this server.").ConfigureAwait(false); + await channel.SendMessageAsync($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** on this server.").ConfigureAwait(false); } catch (ArgumentException exArg) { - await imsg.Channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); + await channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); + await channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); } }); @@ -568,15 +568,15 @@ namespace NadekoBot.Modules.Permissions await PermissionsHandler.SetChannelModulePermission(channel, module.Name, state).ConfigureAwait(false); } - await imsg.Channel.SendMessageAsync($"All modules have been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.").ConfigureAwait(false); + await channel.SendMessageAsync($"All modules have been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.").ConfigureAwait(false); } catch (ArgumentException exArg) { - await imsg.Channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); + await channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); + await channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); } }); @@ -596,15 +596,15 @@ namespace NadekoBot.Modules.Permissions { await PermissionsHandler.SetChannelCommandPermission(channel, command.Text, state).ConfigureAwait(false); } - await imsg.Channel.SendMessageAsync($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.").ConfigureAwait(false); + await channel.SendMessageAsync($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.").ConfigureAwait(false); } catch (ArgumentException exArg) { - await imsg.Channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); + await channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); + await channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); } }); @@ -623,15 +623,15 @@ namespace NadekoBot.Modules.Permissions await PermissionsHandler.SetRoleModulePermission(role, module.Name, state).ConfigureAwait(false); } - await imsg.Channel.SendMessageAsync($"All modules have been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.").ConfigureAwait(false); + await channel.SendMessageAsync($"All modules have been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.").ConfigureAwait(false); } catch (ArgumentException exArg) { - await imsg.Channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); + await channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); + await channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); } }); @@ -655,7 +655,7 @@ namespace NadekoBot.Modules.Permissions await PermissionsHandler.SetRoleCommandPermission(role, command.Text, state).ConfigureAwait(false); } } - await imsg.Channel.SendMessageAsync($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **all roles** role.").ConfigureAwait(false); + await channel.SendMessageAsync($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **all roles** role.").ConfigureAwait(false); } else { @@ -665,16 +665,16 @@ namespace NadekoBot.Modules.Permissions { await PermissionsHandler.SetRoleCommandPermission(role, command.Text, state).ConfigureAwait(false); } - await imsg.Channel.SendMessageAsync($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.").ConfigureAwait(false); + await channel.SendMessageAsync($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.").ConfigureAwait(false); } } catch (ArgumentException exArg) { - await imsg.Channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); + await channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); + await channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); } }); @@ -690,7 +690,7 @@ namespace NadekoBot.Modules.Permissions var usr = e.Message.MentionedUsers.First(); NadekoBot.Config.UserBlacklist.Add(usr.Id); await ConfigHandler.SaveConfig().ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"`Sucessfully blacklisted user {usr.Name}`").ConfigureAwait(false); + await channel.SendMessageAsync($"`Sucessfully blacklisted user {usr.Name}`").ConfigureAwait(false); }).ConfigureAwait(false); }); @@ -708,11 +708,11 @@ namespace NadekoBot.Modules.Permissions { NadekoBot.Config.UserBlacklist.Remove(usr.Id); await ConfigHandler.SaveConfig().ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"`Sucessfully unblacklisted user {usr.Name}`").ConfigureAwait(false); + await channel.SendMessageAsync($"`Sucessfully unblacklisted user {usr.Name}`").ConfigureAwait(false); } else { - await imsg.Channel.SendMessageAsync($"`{usr.Name} was not in blacklist`").ConfigureAwait(false); + await channel.SendMessageAsync($"`{usr.Name} was not in blacklist`").ConfigureAwait(false); } }).ConfigureAwait(false); }); @@ -728,7 +728,7 @@ namespace NadekoBot.Modules.Permissions var ch = e.Message.MentionedChannels.First(); NadekoBot.Config.UserBlacklist.Add(ch.Id); await ConfigHandler.SaveConfig().ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"`Sucessfully blacklisted channel {ch.Name}`").ConfigureAwait(false); + await channel.SendMessageAsync($"`Sucessfully blacklisted channel {ch.Name}`").ConfigureAwait(false); }).ConfigureAwait(false); }); @@ -743,7 +743,7 @@ namespace NadekoBot.Modules.Permissions var ch = e.Message.MentionedChannels.First(); NadekoBot.Config.UserBlacklist.Remove(ch.Id); await ConfigHandler.SaveConfig().ConfigureAwait(false); - await imsg.Channel.SendMessageAsync($"`Sucessfully blacklisted channel {ch.Name}`").ConfigureAwait(false); + await channel.SendMessageAsync($"`Sucessfully blacklisted channel {ch.Name}`").ConfigureAwait(false); }).ConfigureAwait(false); }); @@ -762,7 +762,7 @@ namespace NadekoBot.Modules.Permissions NadekoBot.Client.FindServers(arg.Trim()).FirstOrDefault(); if (server == null) { - await imsg.Channel.SendMessageAsync("Cannot find that server").ConfigureAwait(false); + await channel.SendMessageAsync("Cannot find that server").ConfigureAwait(false); return; } var serverId = server.Id; @@ -774,7 +774,7 @@ namespace NadekoBot.Modules.Permissions TypingGame typeracer; SpeedTyping.RunningContests.TryRemove(serverId, out typeracer); - await imsg.Channel.SendMessageAsync($"`Sucessfully blacklisted server {server.Name}`").ConfigureAwait(false); + await channel.SendMessageAsync($"`Sucessfully blacklisted server {server.Name}`").ConfigureAwait(false); }).ConfigureAwait(false); }); @@ -797,17 +797,17 @@ namespace NadekoBot.Modules.Permissions await PermissionsHandler.SetCommandCooldown(e.Server, command, secs).ConfigureAwait(false); if(secs == 0) - await imsg.Channel.SendMessageAsync($"Command **{command}** has no coooldown now.").ConfigureAwait(false); + await channel.SendMessageAsync($"Command **{command}** has no coooldown now.").ConfigureAwait(false); else - await imsg.Channel.SendMessageAsync($"Command **{command}** now has a **{secs} {(secs==1 ? "second" : "seconds")}** cooldown.").ConfigureAwait(false); + await channel.SendMessageAsync($"Command **{command}** now has a **{secs} {(secs==1 ? "second" : "seconds")}** cooldown.").ConfigureAwait(false); } catch (ArgumentException exArg) { - await imsg.Channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); + await channel.SendMessageAsync(exArg.Message).ConfigureAwait(false); } catch (Exception ex) { - await imsg.Channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); + await channel.SendMessageAsync("Something went terribly wrong - " + ex.Message).ConfigureAwait(false); } }); @@ -823,10 +823,10 @@ namespace NadekoBot.Modules.Permissions if (!perms.CommandCooldowns.Any()) { - await imsg.Channel.SendMessageAsync("`No command cooldowns set.`").ConfigureAwait(false); + await channel.SendMessageAsync("`No command cooldowns set.`").ConfigureAwait(false); return; } - await imsg.Channel.SendMessageAsync(SearchHelper.ShowInPrettyCode(perms.CommandCooldowns.Select(c=>c.Key+ ": "+c.Value+" secs"),s=>$"{s,-30}",2)).ConfigureAwait(false); + await channel.SendMessageAsync(SearchHelper.ShowInPrettyCode(perms.CommandCooldowns.Select(c=>c.Key+ ": "+c.Value+" secs"),s=>$"{s,-30}",2)).ConfigureAwait(false); }); }); }