diff --git a/NadekoBot/Classes/Extensions.cs b/NadekoBot/Classes/Extensions.cs
index 0df27094..212f31e9 100644
--- a/NadekoBot/Classes/Extensions.cs
+++ b/NadekoBot/Classes/Extensions.cs
@@ -4,6 +4,8 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;
+using Discord.Commands;
+using Discord;
namespace NadekoBot
{
@@ -25,6 +27,37 @@ namespace NadekoBot
return "`"+string.Join(" ", letters)+"`";
}
+ ///
+ /// Sends a message to the channel from which this command is called.
+ ///
+ /// EventArg
+ /// Message to be sent
+ ///
+ public static async Task Send(this CommandEventArgs e, string message)
+ {
+ return await NadekoBot.client.SendMessage(e.Channel, message);
+ }
+ ///
+ /// Sends a message to the channel from which MessageEventArg came.
+ ///
+ /// EventArg
+ /// Message to be sent
+ ///
+ public static async Task Send(this MessageEventArgs e, string message)
+ {
+ await NadekoBot.client.SendMessage(e.Channel, message);
+ }
+
+ public static async Task Reply(this CommandEventArgs e, string message)
+ {
+ await NadekoBot.client.SendMessage(e.Channel, e.User.Mention + " " + message);
+ }
+
+ public static async Task Reply(this MessageEventArgs e, string message)
+ {
+ await NadekoBot.client.SendMessage(e.Channel, e.User.Mention + " " + message);
+ }
+
public static void Shuffle(this IList list)
{
RNGCryptoServiceProvider provider = new RNGCryptoServiceProvider();
diff --git a/NadekoBot/Classes/Trivia.cs b/NadekoBot/Classes/Trivia.cs
index 1e13c817..f83139d2 100644
--- a/NadekoBot/Classes/Trivia.cs
+++ b/NadekoBot/Classes/Trivia.cs
@@ -42,10 +42,10 @@ namespace NadekoBot
TriviaGame tg;
if ((tg = StartNewGame(e))!=null)
{
- await client.SendMessage(e.Channel, "**Trivia game started!**\nFirst player to get to 10 points wins! You have 30 seconds per question.\nUse command [tq] if game was started by accident.\nTyping [idfk] 15 seconds after the question has started will give you a hint.");
+ await e.Send( "**Trivia game started!**\nFirst player to get to 10 points wins! You have 30 seconds per question.\nUse command [tq] if game was started by accident.\nTyping [idfk] 15 seconds after the question has started will give you a hint.");
}
else
- await client.SendMessage(e.Channel, "Trivia game is already running on this server. The question is:\n**"+GetCurrentQuestion(e.Server.Id).Question+"**");
+ await e.Send( "Trivia game is already running on this server. The question is:\n**"+GetCurrentQuestion(e.Server.Id).Question+"**");
};
}
@@ -56,10 +56,10 @@ namespace NadekoBot
if (runningTrivias.ContainsKey(e.Server.Id))
{
var lb = runningTrivias[e.User.Server.Id].GetLeaderboard();
- await client.SendMessage(e.Channel, lb);
+ await e.Send( lb);
}
else
- await client.SendMessage(e.Channel, "Trivia game is not running on this server.");
+ await e.Send( "Trivia game is not running on this server.");
};
}
@@ -70,10 +70,10 @@ namespace NadekoBot
if (runningTrivias.ContainsKey(e.Server.Id))
{
var lb = runningTrivias[e.User.Server.Id].GetLeaderboard();
- await client.SendMessage(e.Channel, lb);
+ await e.Send( lb);
}
else
- await client.SendMessage(e.Channel, "Trivia game is not running on this server.");
+ await e.Send( "Trivia game is not running on this server.");
};
}
@@ -103,10 +103,10 @@ namespace NadekoBot
{
if (runningTrivias.ContainsKey(e.Server.Id) && runningTrivias[e.Server.Id].ChannelId ==e.Channel.Id)
{
- await client.SendMessage(e.Channel, "Trivia will stop after this question. Run [**@NadekoBot clr**] to remove this bot's messages from the channel.");
+ await e.Send( "Trivia will stop after this question. Run [**@NadekoBot clr**] to remove this bot's messages from the channel.");
runningTrivias[e.Server.Id].StopGame();
}
- else await client.SendMessage(e.Channel, "No trivias are running on this channel.");
+ else await e.Send( "No trivias are running on this channel.");
};
}
@@ -181,10 +181,10 @@ namespace NadekoBot
{
users[e.User.Id]++;
}
- await client.SendMessage(e.Channel, e.User.Mention + " Guessed it!\n The answer was: **" + currentQuestion.Answer + "**");
+ await e.Send( e.User.Mention + " Guessed it!\n The answer was: **" + currentQuestion.Answer + "**");
if (users[e.User.Id] >= 10) {
- await client.SendMessage(e.Channel, " We have a winner! It's " + e.User.Mention+"\n"+GetLeaderboard()+"\n To start a new game type '@NadekoBot t'");
+ await e.Send( " We have a winner! It's " + e.User.Mention+"\n"+GetLeaderboard()+"\n To start a new game type '@NadekoBot t'");
FinishGame();
return;
}
@@ -196,9 +196,9 @@ namespace NadekoBot
public async void GetHint(MessageEventArgs e) {
if (timeout != null && !isQuit && stopwatch.ElapsedMilliseconds > 10000)
- await client.SendMessage(e.Channel, currentQuestion.Answer.Scramble());
+ await e.Send( currentQuestion.Answer.Scramble());
else {
- await client.SendMessage(e.Channel, $"You have to wait {10-stopwatch.ElapsedMilliseconds/1000} more seconds in order to get a hint.");
+ await e.Send( $"You have to wait {10-stopwatch.ElapsedMilliseconds/1000} more seconds in order to get a hint.");
}
}
diff --git a/NadekoBot/Commands/CopyCommand.cs b/NadekoBot/Commands/CopyCommand.cs
index 60c8e6fc..ed6e51a8 100644
--- a/NadekoBot/Commands/CopyCommand.cs
+++ b/NadekoBot/Commands/CopyCommand.cs
@@ -20,7 +20,7 @@ namespace NadekoBot
private async void Client_MessageReceived(object sender, Discord.MessageEventArgs e)
{
if (CopiedUsers.Contains(e.User.Id)) {
- await client.SendMessage(e.Channel, e.Message.Text);
+ await e.Send( e.Message.Text);
}
}
@@ -31,7 +31,7 @@ namespace NadekoBot
if (CopiedUsers.Contains(e.User.Id)) return;
CopiedUsers.Add(e.User.Id);
- await client.SendMessage(e.Channel, " I'll start copying you now.");
+ await e.Send( " I'll start copying you now.");
return;
};
}
@@ -56,7 +56,7 @@ namespace NadekoBot
if (!CopiedUsers.Contains(e.User.Id)) return;
CopiedUsers.Remove(e.User.Id);
- await client.SendMessage(e.Channel, " I wont copy anymore.");
+ await e.Send( " I wont copy anymore.");
return;
};
}
diff --git a/NadekoBot/Commands/DiceRollCommand.cs b/NadekoBot/Commands/DiceRollCommand.cs
index ad343f55..5b6dfca4 100644
--- a/NadekoBot/Commands/DiceRollCommand.cs
+++ b/NadekoBot/Commands/DiceRollCommand.cs
@@ -49,7 +49,7 @@ namespace NadekoBot
if (num < 1) num = 1;
if (num > 30)
{
- await client.SendMessage(e.Channel, "You can roll up to 30 dies at a time.");
+ await e.Send( "You can roll up to 30 dies at a time.");
num = 30;
}
List dices = new List(num);
@@ -73,12 +73,12 @@ namespace NadekoBot
}
Bitmap bitmap = ImageHandler.MergeImages(dices.ToArray());
- await client.SendMessage(e.Channel, values.Count + " Dies rolled. Total: **"+values.Sum()+"** Average: **"+(values.Sum()/(1.0f*values.Count)).ToString("N2")+"**");
+ await e.Send( values.Count + " Dies rolled. Total: **"+values.Sum()+"** Average: **"+(values.Sum()/(1.0f*values.Count)).ToString("N2")+"**");
await client.SendFile(e.Channel, "dices.png", ImageHandler.ImageToStream(bitmap, ImageFormat.Png));
}
catch (Exception)
{
- await client.SendMessage(e.Channel, "Please enter a number of dices to roll.");
+ await e.Send( "Please enter a number of dices to roll.");
return;
}
}
diff --git a/NadekoBot/Commands/DrawCommand.cs b/NadekoBot/Commands/DrawCommand.cs
index 289d1e55..7fa0498b 100644
--- a/NadekoBot/Commands/DrawCommand.cs
+++ b/NadekoBot/Commands/DrawCommand.cs
@@ -18,7 +18,7 @@ namespace NadekoBot
if (cards == null)
{
cards = new Cards();
- await client.SendMessage(e.Channel, "Shuffling cards...");
+ await e.Send( "Shuffling cards...");
}
try
@@ -38,7 +38,7 @@ namespace NadekoBot
{
if (cards.CardPool.Count == 0)
{
- await client.SendMessage(e.Channel, "No more cards in a deck...\nGetting a new deck...\nShuffling cards...");
+ await e.Send( "No more cards in a deck...\nGetting a new deck...\nShuffling cards...");
}
images[i] = Image.FromFile(cards.DrawACard().Path);
}
diff --git a/NadekoBot/Modules/Administration.cs b/NadekoBot/Modules/Administration.cs
index d0562609..30ccbb60 100644
--- a/NadekoBot/Modules/Administration.cs
+++ b/NadekoBot/Modules/Administration.cs
@@ -28,26 +28,26 @@ namespace NadekoBot.Modules
if (!e.User.ServerPermissions.ManageRoles) return;
var usr = client.FindUsers(e.Server, e.GetArg("user_name")).FirstOrDefault();
if (usr == null) {
- await client.SendMessage(e.Channel, "You failed to supply a valid username");
+ await e.Send( "You failed to supply a valid username");
return;
}
var role = client.FindRoles(e.Server, e.GetArg("role_name")).FirstOrDefault();
if (role == null) {
- await client.SendMessage(e.Channel, "You failed to supply a valid role");
+ await e.Send( "You failed to supply a valid role");
return;
}
try
{
await client.EditUser(usr, null, null, new Discord.Role[] { role }, Discord.EditMode.Add);
- await client.SendMessage(e.Channel, $"Successfully added role **{role.Name}** to user **{usr.Mention}**");
+ await e.Send( $"Successfully added role **{role.Name}** to user **{usr.Mention}**");
}
catch (InvalidOperationException) { //fkin voltana and his shenanigans, fix role.Mention pl0x
}
catch (Exception ex)
{
- await client.SendMessage(e.Channel, "Failed to add roles. Most likely reason: Insufficient permissions.\n");
+ await e.Send( "Failed to add roles. Most likely reason: Insufficient permissions.\n");
Console.WriteLine(ex.ToString());
}
});
@@ -62,27 +62,27 @@ namespace NadekoBot.Modules
var usr = client.FindUsers(e.Server, e.GetArg("user_name")).FirstOrDefault();
if (usr == null)
{
- await client.SendMessage(e.Channel, "You failed to supply a valid username");
+ await e.Send( "You failed to supply a valid username");
return;
}
var role = client.FindRoles(e.Server, e.GetArg("role_name")).FirstOrDefault();
if (role == null)
{
- await client.SendMessage(e.Channel, "You failed to supply a valid role");
+ await e.Send( "You failed to supply a valid role");
return;
}
try
{
await client.EditUser(usr, null, null, new Discord.Role[]{ role }, Discord.EditMode.Remove);
- await client.SendMessage(e.Channel, $"Successfully removed role **{role.Name}** from user **{usr.Mention}**");
+ await e.Send( $"Successfully removed role **{role.Name}** from user **{usr.Mention}**");
}
catch (InvalidOperationException) {
}
catch (Exception)
{
- await client.SendMessage(e.Channel, "Failed to remove roles. Most likely reason: Insufficient permissions.");
+ await e.Send( "Failed to remove roles. Most likely reason: Insufficient permissions.");
}
});
@@ -105,7 +105,7 @@ namespace NadekoBot.Modules
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
- await client.SendMessage(e.Channel, "Please supply a proper color.\n Example: DarkBlue, Orange, Teal");
+ await e.Send( "Please supply a proper color.\n Example: DarkBlue, Orange, Teal");
return;
}
}
@@ -113,11 +113,11 @@ namespace NadekoBot.Modules
{
var r = await client.CreateRole(e.Server, e.GetArg("role_name"));
await client.EditRole(r, null,null, color);
- await client.SendMessage(e.Channel, $"Successfully created role **{r.Mention}**.");
+ await e.Send( $"Successfully created role **{r.Mention}**.");
}
catch (Exception)
{
- await client.SendMessage(e.Channel, "No sufficient permissions.");
+ await e.Send( "No sufficient permissions.");
}
return;
});
@@ -132,12 +132,12 @@ namespace NadekoBot.Modules
{
var usr = e.Message.MentionedUsers.First();
await client.BanUser(e.Message.MentionedUsers.First());
- await client.SendMessage(e.Channel, "Banned user " + usr.Name + " Id: " + usr.Id);
+ await e.Send( "Banned user " + usr.Name + " Id: " + usr.Id);
}
}
catch (Exception)
{
- await client.SendMessage(e.Channel, "No sufficient permissions.");
+ await e.Send( "No sufficient permissions.");
}
});
@@ -152,12 +152,12 @@ namespace NadekoBot.Modules
{
var usr = e.Message.MentionedUsers.First();
await client.KickUser(e.Message.MentionedUsers.First());
- await client.SendMessage(e.Channel,"Kicked user " + usr.Name+" Id: "+usr.Id);
+ await e.Send("Kicked user " + usr.Name+" Id: "+usr.Id);
}
}
catch (Exception)
{
- await client.SendMessage(e.Channel, "No sufficient permissions.");
+ await e.Send( "No sufficient permissions.");
}
});
@@ -171,12 +171,12 @@ namespace NadekoBot.Modules
if (e.User.ServerPermissions.ManageChannels)
{
await client.DeleteChannel(client.FindChannels(e.Server,e.GetArg("channel_name"),Discord.ChannelType.Voice).FirstOrDefault());
- await client.SendMessage(e.Channel, $"Removed channel **{e.GetArg("channel_name")}**.");
+ await e.Send( $"Removed channel **{e.GetArg("channel_name")}**.");
}
}
catch (Exception)
{
- await client.SendMessage(e.Channel, "No sufficient permissions.");
+ await e.Send( "No sufficient permissions.");
}
});
@@ -190,12 +190,12 @@ namespace NadekoBot.Modules
if (e.User.ServerPermissions.ManageChannels)
{
await client.CreateChannel(e.Server, e.GetArg("channel_name"), Discord.ChannelType.Voice);
- await client.SendMessage(e.Channel, $"Created voice channel **{e.GetArg("channel_name")}**.");
+ await e.Send( $"Created voice channel **{e.GetArg("channel_name")}**.");
}
}
catch (Exception)
{
- await client.SendMessage(e.Channel, "No sufficient permissions.");
+ await e.Send( "No sufficient permissions.");
}
});
@@ -209,12 +209,12 @@ namespace NadekoBot.Modules
if (e.User.ServerPermissions.ManageChannels)
{
await client.DeleteChannel(client.FindChannels(e.Server, e.GetArg("channel_name"), Discord.ChannelType.Text).FirstOrDefault());
- await client.SendMessage(e.Channel, $"Removed text channel **{e.GetArg("channel_name")}**.");
+ await e.Send( $"Removed text channel **{e.GetArg("channel_name")}**.");
}
}
catch (Exception)
{
- await client.SendMessage(e.Channel, "No sufficient permissions.");
+ await e.Send( "No sufficient permissions.");
}
});
@@ -228,11 +228,11 @@ namespace NadekoBot.Modules
if (e.User.ServerPermissions.ManageChannels)
{
await client.CreateChannel(e.Server, e.GetArg("channel_name"), Discord.ChannelType.Text);
- await client.SendMessage(e.Channel, $"Added text channel **{e.GetArg("channel_name")}**.");
+ await e.Send( $"Added text channel **{e.GetArg("channel_name")}**.");
}
}
catch (Exception) {
- await client.SendMessage(e.Channel, "No sufficient permissions.");
+ await e.Send( "No sufficient permissions.");
}
});
@@ -242,23 +242,23 @@ namespace NadekoBot.Modules
.Do(async e =>
{
if (e.Message.MentionedUsers.Any())
- await client.SendMessage(e.Channel, "Id of the user " + e.Message.MentionedUsers.First().Mention + " is " + e.Message.MentionedUsers.First().Id);
+ await e.Send( "Id of the user " + e.Message.MentionedUsers.First().Mention + " is " + e.Message.MentionedUsers.First().Id);
else
- await client.SendMessage(e.Channel, "You must mention a user.");
+ await e.Send( "You must mention a user.");
});
cgb.CreateCommand(".cid").Alias(".channelid")
.Description("Shows current channel id")
.Do(async e =>
{
- await client.SendMessage(e.Channel, "This channel's id is " + e.Channel.Id);
+ await e.Send( "This channel's id is " + e.Channel.Id);
});
cgb.CreateCommand(".sid").Alias(".serverid")
.Description("Shows current server id")
.Do(async e =>
{
- await client.SendMessage(e.Channel, "This server's id is " + e.Server.Id);
+ await e.Send( "This server's id is " + e.Server.Id);
});
cgb.CreateCommand(".stats")
@@ -270,7 +270,7 @@ namespace NadekoBot.Modules
var time = (DateTime.Now - Process.GetCurrentProcess().StartTime);
string uptime = " " + time.Days + " days, " + time.Hours + " hours, and " + time.Minutes + " minutes.";
- await client.SendMessage(e.Channel, String.Format("```Servers: {0}\nUnique Users: {1}\nUptime: {2}\nMy id is: {3}```", serverCount, uniqueUserCount, uptime, client.CurrentUser.Id));
+ await e.Send( String.Format("```Servers: {0}\nUnique Users: {1}\nUptime: {2}\nMy id is: {3}```", serverCount, uniqueUserCount, uptime, client.CurrentUser.Id));
});
});
diff --git a/NadekoBot/Modules/Conversations.cs b/NadekoBot/Modules/Conversations.cs
index cdd8edd2..b1c6b373 100644
--- a/NadekoBot/Modules/Conversations.cs
+++ b/NadekoBot/Modules/Conversations.cs
@@ -45,14 +45,14 @@ namespace NadekoBot.Modules
.Description("Nadeko replies with /o/")
.Do(async e =>
{
- await client.SendMessage(e.Channel, e.User.Mention + "/o/");
+ await e.Send( e.User.Mention + "/o/");
});
cgb.CreateCommand("/o/")
.Description("Nadeko replies with \\o\\")
.Do(async e =>
{
- await client.SendMessage(e.Channel, e.User.Mention + "\\o\\");
+ await e.Send( e.User.Mention + "\\o\\");
});
});
@@ -67,9 +67,9 @@ namespace NadekoBot.Modules
.Do(async e =>
{
if (e.User.Id == NadekoBot.OwnerID)
- await client.SendMessage(e.Channel, e.User.Mention + ", Of course I do, my Master.");
+ await e.Send( e.User.Mention + ", Of course I do, my Master.");
else
- await client.SendMessage(e.Channel, e.User.Mention + ", Don't be silly.");
+ await e.Send( e.User.Mention + ", Don't be silly.");
});
CreateCommand(cgb, "die")
@@ -82,10 +82,10 @@ namespace NadekoBot.Modules
t.Interval = 2000;
t.Elapsed += (s, ev) => { Environment.Exit(0); };
t.Start();
- await client.SendMessage(e.Channel, e.User.Mention + ", Yes, my love.");
+ await e.Send( e.User.Mention + ", Yes, my love.");
}
else
- await client.SendMessage(e.Channel, e.User.Mention + ", No.");
+ await e.Send( e.User.Mention + ", No.");
});
CreateCommand(cgb, "how are you")
@@ -94,18 +94,18 @@ namespace NadekoBot.Modules
{
if (e.User.Id == NadekoBot.OwnerID)
{
- await client.SendMessage(e.Channel, e.User.Mention + " I am great as long as you are here.");
+ await e.Send( e.User.Mention + " I am great as long as you are here.");
}
else
{
var kw = client.GetUser(e.Server, NadekoBot.OwnerID);
if (kw != null && kw.Status == UserStatus.Online)
{
- await client.SendMessage(e.Channel, e.User.Mention + " I am great as long as " + Mention.User(kw) + " is with me.");
+ await e.Send( e.User.Mention + " I am great as long as " + kw.Mention + " is with me.");
}
else
{
- await client.SendMessage(e.Channel, e.User.Mention + " I am sad. My Master is not with me.");
+ await e.Send( e.User.Mention + " I am sad. My Master is not with me.");
}
}
});
@@ -117,18 +117,24 @@ namespace NadekoBot.Modules
{
List insults = new List { " you are a poop.", " you jerk.", " i will eat you when i get my powers back." };
Random r = new Random();
- var u = e.Message.MentionedUsers.Last();
+ var u = client.FindUsers(e.Channel,e.GetArg("mention")).FirstOrDefault();
+
+ if (u == null) {
+ await e.Send("Invalid user specified.");
+ return;
+ }
+
if (u.Id == NadekoBot.OwnerID)
{
- await client.SendMessage(e.Channel, "I would never insult my master <3");
+ await e.Send( "I would never insult my master <3");
}
else if (e.User.Id == NadekoBot.OwnerID)
{
- await client.SendMessage(e.Channel, Mention.User(u) + insults[r.Next(0, insults.Count)]);
+ await e.Send( e.User.Mention + insults[r.Next(0, insults.Count)]);
}
else
{
- await client.SendMessage(e.Channel, e.User.Mention + " Eww, why would i do that for you ?!");
+ await e.Send( e.User.Mention + " Eww, why would i do that for you ?!");
}
});
@@ -139,25 +145,32 @@ namespace NadekoBot.Modules
{
List praises = new List { " You are cool.", " You are nice... But don't get any wrong ideas.", " You did a good job." };
Random r = new Random();
- var u = e.Message.MentionedUsers.First();
+ var u = client.FindUsers(e.Channel, e.GetArg("mention")).FirstOrDefault();
+
+ if (u == null)
+ {
+ await e.Send("Invalid user specified.");
+ return;
+ }
+
if (e.User.Id == NadekoBot.OwnerID)
{
if (u.Id != NadekoBot.OwnerID)
- await client.SendMessage(e.Channel, Mention.User(u) + praises[r.Next(0, praises.Count)]);
+ await e.Send( u.Mention + praises[r.Next(0, praises.Count)]);
else
{
- await client.SendMessage(e.Channel, Mention.User(u) + " No need, you know I love you <3");
+ await e.Send( u.Mention + " No need, you know I love you <3");
}
}
else
{
if (u.Id == NadekoBot.OwnerID)
{
- await client.SendMessage(e.Channel, e.User.Mention + " I don't need your permission to praise my beloved Master <3");
+ await e.Send( e.User.Mention + " I don't need your permission to praise my beloved Master <3");
}
else
{
- await client.SendMessage(e.Channel, e.User.Mention + " Yeah... No.");
+ await e.Send( e.User.Mention + " Yeah... No.");
}
}
});
@@ -166,7 +179,7 @@ namespace NadekoBot.Modules
.Description("Useless.")
.Do(async e =>
{
- await client.SendMessage(e.Channel, e.User.Mention + " I will be soon.");
+ await e.Send( e.User.Mention + " I will be soon.");
});
cgb.CreateCommand("are you there")
@@ -178,7 +191,7 @@ namespace NadekoBot.Modules
.Description("Nadeko instructs you to type $draw. Gambling functions start with $")
.Do(async e =>
{
- await client.SendMessage(e.Channel, "Sorry i dont gamble, type $draw for that function.");
+ await e.Send( "Sorry i dont gamble, type $draw for that function.");
});
CreateCommand(cgb, "uptime")
@@ -187,7 +200,7 @@ namespace NadekoBot.Modules
{
var time = (DateTime.Now - Process.GetCurrentProcess().StartTime);
string str = "I am online for " + time.Days + " days, " + time.Hours + " hours, and " + time.Minutes + " minutes.";
- await client.SendMessage(e.Channel, str);
+ await e.Send( str);
});
CreateCommand(cgb, "fire")
.Description("Shows a unicode fire message. Optional parameter [x] tells her how many times to repeat the fire.\n**Usage**: @NadekoBot fire [x]")
@@ -207,7 +220,7 @@ namespace NadekoBot.Modules
{
str += firestr;
}
- await client.SendMessage(e.Channel, str);
+ await e.Send( str);
});
CreateCommand(cgb, "rip")
@@ -239,11 +252,11 @@ namespace NadekoBot.Modules
try
{
await client.AcceptInvite(client.GetInvite(e.Args[0]).Result);
- await client.SendMessage(e.Channel, "I got in!");
+ await e.Send( "I got in!");
}
catch (Exception)
{
- await client.SendMessage(e.Channel, "Invalid code.");
+ await e.Send( "Invalid code.");
}
});
@@ -261,11 +274,11 @@ namespace NadekoBot.Modules
dynamic obj = JObject.Parse(r.Content.ReadAsStringAsync().Result);
if (obj.responseData.results.Count == 0)
{
- await client.SendMessage(e.Channel, "No results found for that keyword :\\");
+ await e.Send( "No results found for that keyword :\\");
return;
}
string s = Searches.ShortenUrl(obj.responseData.results[0].url.ToString());
- await client.SendMessage(e.Channel, s);
+ await e.Send( s);
});
cgb.CreateCommand("ir")
@@ -281,12 +294,12 @@ namespace NadekoBot.Modules
dynamic obj = JObject.Parse(r.Content.ReadAsStringAsync().Result);
if (obj.responseData.results.Count == 0)
{
- await client.SendMessage(e.Channel, "No results found for that keyword :\\");
+ await e.Send( "No results found for that keyword :\\");
return;
}
int rnd = rng.Next(0, obj.responseData.results.Count);
string s = Searches.ShortenUrl(obj.responseData.results[rnd].url.ToString());
- await client.SendMessage(e.Channel, s);
+ await e.Send( s);
});
@@ -309,14 +322,14 @@ namespace NadekoBot.Modules
}
catch (Exception)
{
- await client.SendMessage(e.Channel, "Error saving. Sorry :(");
+ await e.Send( "Error saving. Sorry :(");
}
if (m.Length > 0)
- await client.SendMessage(e.Channel, "I saved this for you: " + Environment.NewLine + "```" + m + "```");
+ await e.Send( "I saved this for you: " + Environment.NewLine + "```" + m + "```");
else
- await client.SendMessage(e.Channel, "No point in saving empty message...");
+ await e.Send( "No point in saving empty message...");
}
- else await client.SendMessage(e.Channel, "Not for you, only my Master <3");
+ else await e.Send( "Not for you, only my Master <3");
});
CreateCommand(cgb, "ls")
@@ -326,7 +339,7 @@ namespace NadekoBot.Modules
FileStream f = File.OpenRead("saves.txt");
if (f.Length == 0)
{
- await client.SendMessage(e.Channel, "Saves are empty.");
+ await e.Send( "Saves are empty.");
return;
}
byte[] b = new byte[f.Length / sizeof(byte)];
@@ -341,7 +354,7 @@ namespace NadekoBot.Modules
.Do(async e =>
{
File.Delete("saves.txt");
- await client.SendMessage(e.Channel, "Cleared all saves.");
+ await e.Send( "Cleared all saves.");
});
CreateCommand(cgb, "bb")
@@ -354,7 +367,7 @@ namespace NadekoBot.Modules
{
str += " " + Mention.User(u);
}
- await client.SendMessage(e.Channel, str);
+ await e.Send( str);
});
AliasCommand(CreateCommand(cgb, "req"), "request")
@@ -370,10 +383,10 @@ namespace NadekoBot.Modules
}
catch (Exception)
{
- await client.SendMessage(e.Channel, "Something went wrong.");
+ await e.Send( "Something went wrong.");
return;
}
- await client.SendMessage(e.Channel, "Thank you for your request.");
+ await e.Send( "Thank you for your request.");
});
CreateCommand(cgb, "lr")
@@ -398,19 +411,19 @@ namespace NadekoBot.Modules
{
if (StatsCollector.DeleteRequest(int.Parse(e.Args[0])))
{
- await client.SendMessage(e.Channel, e.User.Mention + " Request deleted.");
+ await e.Send( e.User.Mention + " Request deleted.");
}
else
{
- await client.SendMessage(e.Channel, "No request on that number.");
+ await e.Send( "No request on that number.");
}
}
catch
{
- await client.SendMessage(e.Channel, "Error deleting request, probably NaN error.");
+ await e.Send( "Error deleting request, probably NaN error.");
}
}
- else await client.SendMessage(e.Channel, "You don't have permission to do that.");
+ else await e.Send( "You don't have permission to do that.");
});
CreateCommand(cgb, "rr")
@@ -425,20 +438,20 @@ namespace NadekoBot.Modules
var sc = StatsCollector.ResolveRequest(int.Parse(e.Args[0]));
if (sc != null)
{
- await client.SendMessage(e.Channel, e.User.Mention + " Request resolved, notice sent.");
+ await e.Send( e.User.Mention + " Request resolved, notice sent.");
await client.SendPrivateMessage(client.GetUser(client.GetServer(sc.ServerId), sc.Id), "**This request of yours has been resolved:**\n" + sc.Text);
}
else
{
- await client.SendMessage(e.Channel, "No request on that number.");
+ await e.Send( "No request on that number.");
}
}
catch
{
- await client.SendMessage(e.Channel, "Error resolving request, probably NaN error.");
+ await e.Send( "Error resolving request, probably NaN error.");
}
}
- else await client.SendMessage(e.Channel, "You don't have permission to do that.");
+ else await e.Send( "You don't have permission to do that.");
});
CreateCommand(cgb, "clr")
@@ -457,7 +470,7 @@ namespace NadekoBot.Modules
}
catch (Exception)
{
- await client.SendMessage(e.Channel, "I cant do it :(");
+ await e.Send( "I cant do it :(");
}
});
@@ -466,7 +479,7 @@ namespace NadekoBot.Modules
.Parameter("who", ParameterType.Required)
.Do(async e =>
{
- await client.SendMessage(e.Channel, "Calling " + e.Args[0] + "...");
+ await e.Send( "Calling " + e.Args[0] + "...");
});
CreateCommand(cgb, "hide")
.Description("Hides nadeko in plain sight!11!!")
@@ -481,7 +494,7 @@ namespace NadekoBot.Modules
await client.EditProfile("", null, null, null, ms, ImageType.Png);
}
- await client.SendMessage(e.Channel, "*hides*");
+ await e.Send( "*hides*");
}
catch (Exception ex)
{
@@ -502,7 +515,7 @@ namespace NadekoBot.Modules
await client.EditProfile("", null, null, null,ms, ImageType.Jpeg);
}
- await client.SendMessage(e.Channel, "*unhides*");
+ await e.Send( "*unhides*");
}
catch (Exception ex)
{
@@ -520,7 +533,7 @@ namespace NadekoBot.Modules
if (e.Message.User.Id == NadekoBot.OwnerId)
{
var result = await CSharpScript.EvaluateAsync(e.Args[0]);
- await client.SendMessage(e.Channel, result?.ToString() ?? "null");
+ await e.Send( result?.ToString() ?? "null");
return;
}
});*/
diff --git a/NadekoBot/Modules/Music.cs b/NadekoBot/Modules/Music.cs
index 361c0805..71726be9 100644
--- a/NadekoBot/Modules/Music.cs
+++ b/NadekoBot/Modules/Music.cs
@@ -86,11 +86,11 @@ namespace NadekoBot.Modules
Pause = !Pause;
if (Pause)
{
- await client.SendMessage(e.Channel, "Pausing. Run the command again to resume.");
+ await e.Send( "Pausing. Run the command again to resume.");
}
else
{
- await client.SendMessage(e.Channel, "Resuming...");
+ await e.Send( "Resuming...");
}
}
});
@@ -109,7 +109,7 @@ namespace NadekoBot.Modules
if (video?.Uri != "" && video.Uri != null)
{
SongQueue.Add(video);
- await client.SendMessage(e.Channel, "**Queued** " + video.FullName);
+ await e.Send( "**Queued** " + video.FullName);
}
});
@@ -118,8 +118,8 @@ namespace NadekoBot.Modules
.Description("Lists up to 10 currently queued songs.")
.Do(async e =>
{
- await client.SendMessage(e.Channel, SongQueue.Count + " videos currently queued.");
- await client.SendMessage(e.Channel, string.Join("\n", SongQueue.Select(v => v.FullName).Take(10)));
+ await e.Send( SongQueue.Count + " videos currently queued.");
+ await e.Send( string.Join("\n", SongQueue.Select(v => v.FullName).Take(10)));
});
cgb.CreateCommand("sh")
@@ -128,12 +128,12 @@ namespace NadekoBot.Modules
{
if (SongQueue.Count < 2)
{
- await client.SendMessage(e.Channel, "Not enough songs in order to perform the shuffle.");
+ await e.Send( "Not enough songs in order to perform the shuffle.");
return;
}
SongQueue.Shuffle();
- await client.SendMessage(e.Channel, "Songs shuffled!");
+ await e.Send( "Songs shuffled!");
});
cgb.CreateCommand("radio")
@@ -162,14 +162,14 @@ namespace NadekoBot.Modules
{
Voice = null;
Exit = false;
- await client.SendMessage(e.Channel, "Exiting...");
+ await e.Send( "Exiting...");
return;
}
int blockSize = 1920;
byte[] buffer = new byte[1920];
//float multiplier = 1.0f / 48000 / 2;
- var msg = await client.SendMessage(e.Channel, "Playing " + Music.CurrentSong.FullName + " [00:00]");
+ var msg = await e.Send( "Playing " + Music.CurrentSong.FullName + " [00:00]");
int counter = 0;
int byteCount;
using (var stream = GetAudioFileStream(Music.CurrentSong.Uri))
diff --git a/NadekoBot/Modules/Searches.cs b/NadekoBot/Modules/Searches.cs
index 562126d0..08ae033b 100644
--- a/NadekoBot/Modules/Searches.cs
+++ b/NadekoBot/Modules/Searches.cs
@@ -34,11 +34,11 @@ namespace NadekoBot.Modules
.Do(async e =>
{
if (e.Message.MentionedUsers.Count() == 0) {
- await client.SendMessage(e.Channel, "You need to mention a person");
+ await e.Send( "You need to mention a person");
return;
}
string av = e.Message.MentionedUsers.First().AvatarUrl;
- await client.SendMessage(e.Channel, ShortenUrl("http://www.discordapp.com/api/" + av));
+ await e.Send( ShortenUrl("http://www.discordapp.com/api/" + av));
});
cgb.CreateCommand("~yt")
@@ -51,10 +51,10 @@ namespace NadekoBot.Modules
var str = ShortenUrl(FindYoutubeUrlByKeywords(e.GetArg("query")));
if (str == null || str.Trim().Length < 5)
{
- await client.SendMessage(e.Channel, "Query failed");
+ await e.Send( "Query failed");
return;
}
- await client.SendMessage(e.Channel, str);
+ await e.Send( str);
});
cgb.CreateCommand("~ani")
@@ -67,11 +67,11 @@ namespace NadekoBot.Modules
var result = GetAnimeQueryResultLink(e.GetArg("query"));
if (result == null) {
- await client.SendMessage(e.Channel, "Failed to find that anime.");
+ await e.Send( "Failed to find that anime.");
return;
}
- await client.SendMessage(e.Channel,result.ToString());
+ await e.Send(result.ToString());
});
cgb.CreateCommand("~mang")
@@ -85,10 +85,10 @@ namespace NadekoBot.Modules
var result = GetMangaQueryResultLink(e.GetArg("query"));
if (result == null)
{
- await client.SendMessage(e.Channel, "Failed to find that anime.");
+ await e.Send( "Failed to find that anime.");
return;
}
- await client.SendMessage(e.Channel, result.ToString());
+ await e.Send( result.ToString());
});
});
}