removed useless ,fuc, trimming whitespace on calls, changed e.send to original

This commit is contained in:
Master Kwoth 2016-02-22 00:11:07 +01:00
parent c364dab600
commit e5ebdb6de0
21 changed files with 287 additions and 288 deletions

View File

@ -111,7 +111,7 @@ namespace NadekoBot.Extensions {
/// <returns></returns> /// <returns></returns>
public static async Task Reply(this CommandEventArgs e, string message) public static async Task Reply(this CommandEventArgs e, string message)
{ {
await e.Send(e.User.Mention + " " + message); await e.Channel.SendMessage(e.User.Mention + " " + message);
} }
/// <summary> /// <summary>
@ -122,7 +122,7 @@ namespace NadekoBot.Extensions {
/// <returns></returns> /// <returns></returns>
public static async Task Reply(this MessageEventArgs e, string message) public static async Task Reply(this MessageEventArgs e, string message)
{ {
await e.Send(e.User.Mention + " " + message); await e.Channel.SendMessage(e.User.Mention + " " + message);
} }
/// <summary> /// <summary>

View File

@ -354,19 +354,15 @@ namespace NadekoBot.Classes.Music {
} }
public override int Read(byte[] buffer, int offset, int count) { public override int Read(byte[] buffer, int offset, int count) {
lock (this) { Position = readPos;
Position = readPos; int read = base.Read(buffer, offset, count);
int read = base.Read(buffer, offset, count); readPos = Position;
readPos = Position; return read;
return read;
}
} }
public override void Write(byte[] buffer, int offset, int count) { public override void Write(byte[] buffer, int offset, int count) {
lock (this) { Position = writePos;
Position = writePos; base.Write(buffer, offset, count);
base.Write(buffer, offset, count); writePos = Position;
writePos = Position;
}
} }
} }
} }

View File

@ -198,7 +198,7 @@ namespace NadekoBot.Commands {
await e.Channel.SendMessage($"💢🔰 {ex.Message}"); await e.Channel.SendMessage($"💢🔰 {ex.Message}");
} }
}); });
/*
cgb.CreateCommand(prefix + "forceunclaim") cgb.CreateCommand(prefix + "forceunclaim")
.Alias(prefix + "forceuncall") .Alias(prefix + "forceuncall")
.Alias(prefix + "fuc") .Alias(prefix + "fuc")
@ -214,7 +214,7 @@ namespace NadekoBot.Commands {
string usr = string usr =
string.IsNullOrWhiteSpace(e.GetArg("other_name")) ? string.IsNullOrWhiteSpace(e.GetArg("other_name")) ?
e.User.Name : e.User.Name :
e.GetArg("other_name"); e.GetArg("other_name").Trim();
try { try {
var war = warsInfo.Item1[warsInfo.Item2]; var war = warsInfo.Item1[warsInfo.Item2];
int baseNumber = war.Uncall(usr); int baseNumber = war.Uncall(usr);
@ -224,6 +224,7 @@ namespace NadekoBot.Commands {
await e.Channel.SendMessage($"💢🔰 {ex.Message}"); await e.Channel.SendMessage($"💢🔰 {ex.Message}");
} }
}); });
*/
cgb.CreateCommand(prefix + "endwar") cgb.CreateCommand(prefix + "endwar")
.Alias(prefix + "ew") .Alias(prefix + "ew")
@ -323,7 +324,7 @@ namespace NadekoBot.Commands {
throw new ArgumentException($"@{u} You already claimed a base #{i + 1}. You can't claim a new one."); throw new ArgumentException($"@{u} You already claimed a base #{i + 1}. You can't claim a new one.");
} }
bases[baseNumber] = new Caller { CallUser = u, TimeAdded = DateTime.Now, BaseDestroyed = false }; bases[baseNumber] = new Caller { CallUser = u.Trim(), TimeAdded = DateTime.Now, BaseDestroyed = false };
} }
internal async void Start() { internal async void Start() {
@ -344,6 +345,7 @@ namespace NadekoBot.Commands {
} }
} }
internal int Uncall(string user) { internal int Uncall(string user) {
user = user.Trim();
for (int i = 0; i < bases.Length; i++) { for (int i = 0; i < bases.Length; i++) {
if (bases[i]?.CallUser == user) { if (bases[i]?.CallUser == user) {
bases[i] = null; bases[i] = null;
@ -397,6 +399,7 @@ namespace NadekoBot.Commands {
} }
internal int FinishClaim(string user) { internal int FinishClaim(string user) {
user = user.Trim();
for (int i = 0; i < bases.Length; i++) { for (int i = 0; i < bases.Length; i++) {
if (bases[i]?.BaseDestroyed == false && bases[i]?.CallUser == user) { if (bases[i]?.BaseDestroyed == false && bases[i]?.CallUser == user) {
bases[i].BaseDestroyed = true; bases[i].BaseDestroyed = true;

View File

@ -21,7 +21,7 @@ namespace NadekoBot
if (string.IsNullOrWhiteSpace(e.Message.Text)) if (string.IsNullOrWhiteSpace(e.Message.Text))
return; return;
if (CopiedUsers.Contains(e.User.Id)) { if (CopiedUsers.Contains(e.User.Id)) {
await e.Send( e.Message.Text.Replace("@everyone","@everryone")); await e.Channel.SendMessage( e.Message.Text.Replace("@everyone","@everryone"));
} }
} }
@ -30,7 +30,7 @@ namespace NadekoBot
if (CopiedUsers.Contains(e.User.Id)) return; if (CopiedUsers.Contains(e.User.Id)) return;
CopiedUsers.Add(e.User.Id); CopiedUsers.Add(e.User.Id);
await e.Send(" I'll start copying you now."); await e.Channel.SendMessage(" I'll start copying you now.");
return; return;
}; };
@ -52,7 +52,7 @@ namespace NadekoBot
if (!CopiedUsers.Contains(e.User.Id)) return; if (!CopiedUsers.Contains(e.User.Id)) return;
CopiedUsers.Remove(e.User.Id); CopiedUsers.Remove(e.User.Id);
await e.Send(" I wont copy anymore."); await e.Channel.SendMessage(" I wont copy anymore.");
return; return;
}; };
} }

View File

@ -34,7 +34,7 @@ namespace NadekoBot {
int num = int.Parse(e.Args[0]); int num = int.Parse(e.Args[0]);
if (num < 1) num = 1; if (num < 1) num = 1;
if (num > 30) { if (num > 30) {
await e.Send("You can roll up to 30 dies at a time."); await e.Channel.SendMessage("You can roll up to 30 dies at a time.");
num = 30; num = 30;
} }
List<Image> dices = new List<Image>(num); List<Image> dices = new List<Image>(num);
@ -56,10 +56,10 @@ namespace NadekoBot {
} }
Bitmap bitmap = dices.Merge(); Bitmap bitmap = dices.Merge();
await e.Send(values.Count + " Dies rolled. Total: **" + values.Sum() + "** Average: **" + (values.Sum() / (1.0f * values.Count)).ToString("N2") + "**"); await e.Channel.SendMessage(values.Count + " Dies rolled. Total: **" + values.Sum() + "** Average: **" + (values.Sum() / (1.0f * values.Count)).ToString("N2") + "**");
await e.Channel.SendFile("dices.png", bitmap.ToStream(ImageFormat.Png)); await e.Channel.SendFile("dices.png", bitmap.ToStream(ImageFormat.Png));
} catch { } catch {
await e.Send("Please enter a number of dices to roll."); await e.Channel.SendMessage("Please enter a number of dices to roll.");
return; return;
} }
} }
@ -95,9 +95,9 @@ namespace NadekoBot {
rolled = new Random().Next(0, int.Parse(e.GetArg("range"))+1); rolled = new Random().Next(0, int.Parse(e.GetArg("range"))+1);
} }
await e.Send($"{e.User.Mention} rolled **{rolled}**."); await e.Channel.SendMessage($"{e.User.Mention} rolled **{rolled}**.");
} catch (Exception ex) { } catch (Exception ex) {
await e.Send($":anger: {ex.Message}"); await e.Channel.SendMessage($":anger: {ex.Message}");
} }
}; };

View File

@ -16,7 +16,7 @@ namespace NadekoBot {
public override Func<CommandEventArgs, Task> DoFunc() => async (e) => { public override Func<CommandEventArgs, Task> DoFunc() => async (e) => {
if (!AllDecks.ContainsKey(e.Server)) { if (!AllDecks.ContainsKey(e.Server)) {
await e.Send("Shuffling cards..."); await e.Channel.SendMessage("Shuffling cards...");
AllDecks.TryAdd(e.Server, new Cards()); AllDecks.TryAdd(e.Server, new Cards());
} }
@ -36,7 +36,7 @@ namespace NadekoBot {
List<Cards.Card> cardObjects = new List<Cards.Card>(); List<Cards.Card> cardObjects = new List<Cards.Card>();
for (int i = 0; i < num; i++) { for (int i = 0; i < num; i++) {
if (cards.CardPool.Count == 0 && i != 0) { if (cards.CardPool.Count == 0 && i != 0) {
await e.Send("No more cards in a deck."); await e.Channel.SendMessage("No more cards in a deck.");
break; break;
} }
var currentCard = cards.DrawACard(); var currentCard = cards.DrawACard();
@ -46,7 +46,7 @@ namespace NadekoBot {
Bitmap bitmap = images.Merge(); Bitmap bitmap = images.Merge();
await e.Channel.SendFile(images.Count + " cards.jpg", bitmap.ToStream()); await e.Channel.SendFile(images.Count + " cards.jpg", bitmap.ToStream());
if (cardObjects.Count == 5) { if (cardObjects.Count == 5) {
await e.Send(Cards.GetHandValue(cardObjects)); await e.Channel.SendMessage(Cards.GetHandValue(cardObjects));
} }
} catch (Exception ex) { } catch (Exception ex) {
Console.WriteLine("Error drawing (a) card(s) " + ex.ToString()); Console.WriteLine("Error drawing (a) card(s) " + ex.ToString());
@ -66,7 +66,7 @@ namespace NadekoBot {
if (!AllDecks.ContainsKey(e.Server)) if (!AllDecks.ContainsKey(e.Server))
AllDecks.TryAdd(e.Server, new Cards()); AllDecks.TryAdd(e.Server, new Cards());
AllDecks[e.Server].Restart(); AllDecks[e.Server].Restart();
await e.Send("Deck reshuffled."); await e.Channel.SendMessage("Deck reshuffled.");
}); });
} }

View File

@ -35,7 +35,7 @@ namespace NadekoBot {
return; return;
} }
await e.Send("Invalid number"); await e.Channel.SendMessage("Invalid number");
} }
}; };

View File

@ -73,7 +73,7 @@ namespace NadekoBot
.Alias("-guide") .Alias("-guide")
.Description("Sends a readme and a guide links to the channel.") .Description("Sends a readme and a guide links to the channel.")
.Do(async e => .Do(async e =>
await e.Send( await e.Channel.SendMessage(
@"**FULL README**: <https://github.com/Kwoth/NadekoBot/blob/master/README.md> @"**FULL README**: <https://github.com/Kwoth/NadekoBot/blob/master/README.md>
**GUIDE ONLY**: <https://github.com/Kwoth/NadekoBot/blob/master/ComprehensiveGuide.md> **GUIDE ONLY**: <https://github.com/Kwoth/NadekoBot/blob/master/ComprehensiveGuide.md>
@ -84,7 +84,7 @@ namespace NadekoBot
.Alias("~donate") .Alias("~donate")
.Description("Instructions for helping the project!") .Description("Instructions for helping the project!")
.Do(async e => { .Do(async e => {
await e.Send( await e.Channel.SendMessage(
@"I've created a **paypal** email for nadeko, so if you wish to support the project, you can send your donations to `nadekodiscordbot@gmail.com` @"I've created a **paypal** email for nadeko, so if you wish to support the project, you can send your donations to `nadekodiscordbot@gmail.com`
Don't forget to leave your discord name or id in the message, so that I can reward people who help out. Don't forget to leave your discord name or id in the message, so that I can reward people who help out.
You can join nadekobot server by simply private messaging NadekoBot, and you will get an invite. You can join nadekobot server by simply private messaging NadekoBot, and you will get an invite.

View File

@ -53,10 +53,10 @@ namespace NadekoBot.Commands {
try { try {
SaveRequest(e, str); SaveRequest(e, str);
} catch { } catch {
await e.Send("Something went wrong."); await e.Channel.SendMessage("Something went wrong.");
return; return;
} }
await e.Send("Thank you for your request."); await e.Channel.SendMessage("Thank you for your request.");
}); });
cgb.CreateCommand("lr") cgb.CreateCommand("lr")
@ -76,14 +76,14 @@ namespace NadekoBot.Commands {
if (e.User.Id == NadekoBot.OwnerID) { if (e.User.Id == NadekoBot.OwnerID) {
try { try {
if (DeleteRequest(int.Parse(e.Args[0]))) { if (DeleteRequest(int.Parse(e.Args[0]))) {
await e.Send(e.User.Mention + " Request deleted."); await e.Channel.SendMessage(e.User.Mention + " Request deleted.");
} else { } else {
await e.Send("No request on that number."); await e.Channel.SendMessage("No request on that number.");
} }
} catch { } catch {
await e.Send("Error deleting request, probably NaN error."); await e.Channel.SendMessage("Error deleting request, probably NaN error.");
} }
} else await e.Send("You don't have permission to do that."); } else await e.Channel.SendMessage("You don't have permission to do that.");
}); });
cgb.CreateCommand("rr") cgb.CreateCommand("rr")
@ -94,15 +94,15 @@ namespace NadekoBot.Commands {
try { try {
var sc = ResolveRequest(int.Parse(e.Args[0])); var sc = ResolveRequest(int.Parse(e.Args[0]));
if (sc != null) { if (sc != null) {
await e.Send(e.User.Mention + " Request resolved, notice sent."); await e.Channel.SendMessage(e.User.Mention + " Request resolved, notice sent.");
await client.GetServer((ulong)sc.ServerId).GetUser((ulong)sc.UserId).Send("**This request of yours has been resolved:**\n" + sc.RequestText); await client.GetServer((ulong)sc.ServerId).GetUser((ulong)sc.UserId).Send("**This request of yours has been resolved:**\n" + sc.RequestText);
} else { } else {
await e.Send("No request on that number."); await e.Channel.SendMessage("No request on that number.");
} }
} catch { } catch {
await e.Send("Error resolving request, probably NaN error."); await e.Channel.SendMessage("Error resolving request, probably NaN error.");
} }
} else await e.Send("You don't have permission to do that."); } else await e.Channel.SendMessage("You don't have permission to do that.");
}); });
} }
} }

View File

@ -180,9 +180,9 @@ namespace NadekoBot.Commands {
var controls = AnnouncementsDictionary[e.Server.Id]; var controls = AnnouncementsDictionary[e.Server.Id];
if (controls.ToggleGreet(e.Channel.Id)) if (controls.ToggleGreet(e.Channel.Id))
await e.Send("Greet announcements enabled on this channel."); await e.Channel.SendMessage("Greet announcements enabled on this channel.");
else else
await e.Send("Greet announcements disabled."); await e.Channel.SendMessage("Greet announcements disabled.");
}); });
cgb.CreateCommand(".greetmsg") cgb.CreateCommand(".greetmsg")
@ -195,9 +195,9 @@ namespace NadekoBot.Commands {
AnnouncementsDictionary.TryAdd(e.Server.Id, new AnnounceControls(e.Server.Id)); AnnouncementsDictionary.TryAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
AnnouncementsDictionary[e.Server.Id].GreetText = e.GetArg("msg"); AnnouncementsDictionary[e.Server.Id].GreetText = e.GetArg("msg");
await e.Send("New greet message set."); await e.Channel.SendMessage("New greet message set.");
if (!AnnouncementsDictionary[e.Server.Id].Greet) if (!AnnouncementsDictionary[e.Server.Id].Greet)
await e.Send("Enable greet messsages by typing `.greet`"); await e.Channel.SendMessage("Enable greet messsages by typing `.greet`");
}); });
cgb.CreateCommand(".bye") cgb.CreateCommand(".bye")
@ -210,9 +210,9 @@ namespace NadekoBot.Commands {
var controls = AnnouncementsDictionary[e.Server.Id]; var controls = AnnouncementsDictionary[e.Server.Id];
if (controls.ToggleBye(e.Channel.Id)) if (controls.ToggleBye(e.Channel.Id))
await e.Send("Bye announcements enabled on this channel."); await e.Channel.SendMessage("Bye announcements enabled on this channel.");
else else
await e.Send("Bye announcements disabled."); await e.Channel.SendMessage("Bye announcements disabled.");
}); });
cgb.CreateCommand(".byemsg") cgb.CreateCommand(".byemsg")
@ -225,9 +225,9 @@ namespace NadekoBot.Commands {
AnnouncementsDictionary.TryAdd(e.Server.Id, new AnnounceControls(e.Server.Id)); AnnouncementsDictionary.TryAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
AnnouncementsDictionary[e.Server.Id].ByeText = e.GetArg("msg"); AnnouncementsDictionary[e.Server.Id].ByeText = e.GetArg("msg");
await e.Send("New bye message set."); await e.Channel.SendMessage("New bye message set.");
if (!AnnouncementsDictionary[e.Server.Id].Bye) if (!AnnouncementsDictionary[e.Server.Id].Bye)
await e.Send("Enable bye messsages by typing `.bye`."); await e.Channel.SendMessage("Enable bye messsages by typing `.bye`.");
}); });
cgb.CreateCommand(".byepm") cgb.CreateCommand(".byepm")
@ -239,11 +239,11 @@ namespace NadekoBot.Commands {
AnnouncementsDictionary[e.Server.Id].ToggleByePM(); AnnouncementsDictionary[e.Server.Id].ToggleByePM();
if (AnnouncementsDictionary[e.Server.Id].ByePM) if (AnnouncementsDictionary[e.Server.Id].ByePM)
await e.Send("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."); await e.Channel.SendMessage("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.");
else else
await e.Send("Bye messages will be sent in a bound channel from now on."); await e.Channel.SendMessage("Bye messages will be sent in a bound channel from now on.");
if (!AnnouncementsDictionary[e.Server.Id].Bye) if (!AnnouncementsDictionary[e.Server.Id].Bye)
await e.Send("Enable bye messsages by typing `.bye`, and set the bye message using `.byemsg`"); await e.Channel.SendMessage("Enable bye messsages by typing `.bye`, and set the bye message using `.byemsg`");
}); });
cgb.CreateCommand(".greetpm") cgb.CreateCommand(".greetpm")
@ -255,11 +255,11 @@ namespace NadekoBot.Commands {
AnnouncementsDictionary[e.Server.Id].ToggleGreetPM(); AnnouncementsDictionary[e.Server.Id].ToggleGreetPM();
if (AnnouncementsDictionary[e.Server.Id].GreetPM) if (AnnouncementsDictionary[e.Server.Id].GreetPM)
await e.Send("Greet messages will be sent in a PM from now on."); await e.Channel.SendMessage("Greet messages will be sent in a PM from now on.");
else else
await e.Send("Greet messages will be sent in a bound channel from now on."); await e.Channel.SendMessage("Greet messages will be sent in a bound channel from now on.");
if (!AnnouncementsDictionary[e.Server.Id].Greet) if (!AnnouncementsDictionary[e.Server.Id].Greet)
await e.Send("Enable greet messsages by typing `.greet`, and set the greet message using `.greetmsg`"); await e.Channel.SendMessage("Enable greet messsages by typing `.greet`, and set the greet message using `.greetmsg`");
}); });
} }
} }

View File

@ -92,7 +92,7 @@ namespace NadekoBot.Commands {
finishedUserIds.Add(e.User.Id); finishedUserIds.Add(e.User.Id);
await channel.Send($"{e.User.Mention} finished in **{sw.Elapsed.Seconds}** seconds with { distance } errors, **{ currentSentence.Length / TypingGame.WORD_VALUE / sw.Elapsed.Seconds * 60 }** WPM!"); await channel.Send($"{e.User.Mention} finished in **{sw.Elapsed.Seconds}** seconds with { distance } errors, **{ currentSentence.Length / TypingGame.WORD_VALUE / sw.Elapsed.Seconds * 60 }** WPM!");
if (finishedUserIds.Count % 2 == 0) { if (finishedUserIds.Count % 2 == 0) {
await e.Send($":exclamation: `A lot of people finished, here is the text for those still typing:`\n\n:book:**{currentSentence}**:book:"); await e.Channel.SendMessage($":exclamation: `A lot of people finished, here is the text for those still typing:`\n\n:book:**{currentSentence}**:book:");
} }
} }
@ -113,7 +113,7 @@ namespace NadekoBot.Commands {
public override Func<CommandEventArgs, Task> DoFunc() => public override Func<CommandEventArgs, Task> DoFunc() =>
async e => { async e => {
if (runningContests.ContainsKey(e.User.Server.Id) && runningContests[e.User.Server.Id].IsActive) { if (runningContests.ContainsKey(e.User.Server.Id) && runningContests[e.User.Server.Id].IsActive) {
await e.Send($"Contest already running in { runningContests[e.User.Server.Id].Channell.Mention } channel."); await e.Channel.SendMessage($"Contest already running in { runningContests[e.User.Server.Id].Channell.Mention } channel.");
return; return;
} }
if (runningContests.ContainsKey(e.User.Server.Id) && !runningContests[e.User.Server.Id].IsActive) { if (runningContests.ContainsKey(e.User.Server.Id) && !runningContests[e.User.Server.Id].IsActive) {
@ -132,7 +132,7 @@ namespace NadekoBot.Commands {
runningContests.Remove(e.User.Server.Id); runningContests.Remove(e.User.Server.Id);
return; return;
} }
await e.Send("No contest to stop on this channel."); await e.Channel.SendMessage("No contest to stop on this channel.");
}; };
public override void Init(CommandGroupBuilder cgb) { public override void Init(CommandGroupBuilder cgb) {
@ -155,7 +155,7 @@ namespace NadekoBot.Commands {
DateAdded = DateTime.Now DateAdded = DateTime.Now
}); });
await e.Send("Added new article for typing game."); await e.Channel.SendMessage("Added new article for typing game.");
}); });
//todo add user submissions //todo add user submissions

View File

@ -13,9 +13,9 @@ namespace NadekoBot.Commands {
public override Func<CommandEventArgs, Task> DoFunc() => async e => { public override Func<CommandEventArgs, Task> DoFunc() => async e => {
if (!runningTrivias.ContainsKey(e.Server)) { if (!runningTrivias.ContainsKey(e.Server)) {
runningTrivias.TryAdd(e.Server, new TriviaGame(e)); runningTrivias.TryAdd(e.Server, new TriviaGame(e));
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.**"); await e.Channel.SendMessage("**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.**");
} else } else
await e.Send("Trivia game is already running on this server.\n" + runningTrivias[e.Server].CurrentQuestion); await e.Channel.SendMessage("Trivia game is already running on this server.\n" + runningTrivias[e.Server].CurrentQuestion);
}; };
public override void Init(CommandGroupBuilder cgb) { public override void Init(CommandGroupBuilder cgb) {
@ -31,9 +31,9 @@ namespace NadekoBot.Commands {
.Alias("-tlb") .Alias("-tlb")
.Do(async e=> { .Do(async e=> {
if (runningTrivias.ContainsKey(e.Server)) if (runningTrivias.ContainsKey(e.Server))
await e.Send(runningTrivias[e.Server].GetLeaderboard()); await e.Channel.SendMessage(runningTrivias[e.Server].GetLeaderboard());
else else
await e.Send("No trivia is running on this server."); await e.Channel.SendMessage("No trivia is running on this server.");
}); });
cgb.CreateCommand("tq") cgb.CreateCommand("tq")
@ -43,7 +43,7 @@ namespace NadekoBot.Commands {
if (runningTrivias.ContainsKey(e.Server)) { if (runningTrivias.ContainsKey(e.Server)) {
runningTrivias[e.Server].StopGame(); runningTrivias[e.Server].StopGame();
} else } else
await e.Send("No trivia is running on this server."); await e.Channel.SendMessage("No trivia is running on this server.");
}); });
} }
} }

View File

@ -41,21 +41,21 @@ namespace NadekoBot.Modules {
string.IsNullOrWhiteSpace(e.GetArg("role_name"))) return; string.IsNullOrWhiteSpace(e.GetArg("role_name"))) return;
var usr = e.Server.FindUsers(e.GetArg("user_name")).FirstOrDefault(); var usr = e.Server.FindUsers(e.GetArg("user_name")).FirstOrDefault();
if (usr == null) { if (usr == null) {
await e.Send("You failed to supply a valid username"); await e.Channel.SendMessage("You failed to supply a valid username");
return; return;
} }
var role = e.Server.FindRoles(e.GetArg("role_name")).FirstOrDefault(); var role = e.Server.FindRoles(e.GetArg("role_name")).FirstOrDefault();
if (role == null) { if (role == null) {
await e.Send("You failed to supply a valid role"); await e.Channel.SendMessage("You failed to supply a valid role");
return; return;
} }
try { try {
await usr.AddRoles(new Role[] { role }); await usr.AddRoles(new Role[] { role });
await e.Send($"Successfully added role **{role.Name}** to user **{usr.Name}**"); await e.Channel.SendMessage($"Successfully added role **{role.Name}** to user **{usr.Name}**");
} catch (Exception ex) { } catch (Exception ex) {
await e.Send("Failed to add roles. Most likely reason: Insufficient permissions.\n"); await e.Channel.SendMessage("Failed to add roles. Most likely reason: Insufficient permissions.\n");
Console.WriteLine(ex.ToString()); Console.WriteLine(ex.ToString());
} }
}); });
@ -70,21 +70,21 @@ namespace NadekoBot.Modules {
var usr = e.Server.FindUsers(e.GetArg("user_name")).FirstOrDefault(); var usr = e.Server.FindUsers(e.GetArg("user_name")).FirstOrDefault();
if (usr == null) { if (usr == null) {
await e.Send("You failed to supply a valid username"); await e.Channel.SendMessage("You failed to supply a valid username");
return; return;
} }
var role = e.Server.FindRoles(e.GetArg("role_name")).FirstOrDefault(); var role = e.Server.FindRoles(e.GetArg("role_name")).FirstOrDefault();
if (role == null) { if (role == null) {
await e.Send("You failed to supply a valid role"); await e.Channel.SendMessage("You failed to supply a valid role");
return; return;
} }
try { try {
await usr.RemoveRoles(new Role[] { role }); await usr.RemoveRoles(new Role[] { role });
await e.Send($"Successfully removed role **{role.Name}** from user **{usr.Name}**"); await e.Channel.SendMessage($"Successfully removed role **{role.Name}** from user **{usr.Name}**");
} catch (InvalidOperationException) { } catch (InvalidOperationException) {
} catch { } catch {
await e.Send("Failed to remove roles. Most likely reason: Insufficient permissions."); await e.Channel.SendMessage("Failed to remove roles. Most likely reason: Insufficient permissions.");
} }
}); });
@ -97,9 +97,9 @@ namespace NadekoBot.Modules {
return; return;
try { try {
var r = await e.Server.CreateRole(e.GetArg("role_name")); var r = await e.Server.CreateRole(e.GetArg("role_name"));
await e.Send($"Successfully created role **{r.Name}**."); await e.Channel.SendMessage($"Successfully created role **{r.Name}**.");
} catch (Exception ex) { } catch (Exception ex) {
await e.Send(":warning: Unspecified error."); await e.Channel.SendMessage(":warning: Unspecified error.");
} }
}); });
@ -118,14 +118,14 @@ namespace NadekoBot.Modules {
var args = e.Args.Where(s => s != String.Empty); var args = e.Args.Where(s => s != String.Empty);
if (args.Count() != 2 && args.Count() != 4) { if (args.Count() != 2 && args.Count() != 4) {
await e.Send("The parameters are invalid."); await e.Channel.SendMessage("The parameters are invalid.");
return; return;
} }
Role role = e.Server.FindRoles(e.Args[0]).FirstOrDefault(); Role role = e.Server.FindRoles(e.Args[0]).FirstOrDefault();
if (role == null) { if (role == null) {
await e.Send("That role does not exist."); await e.Channel.SendMessage("That role does not exist.");
return; return;
} }
try { try {
@ -138,7 +138,7 @@ namespace NadekoBot.Modules {
await role.Edit(color: new Color(red, green, blue)); await role.Edit(color: new Color(red, green, blue));
await e.Channel.SendMessage($"Role {role.Name}'s color has been changed."); await e.Channel.SendMessage($"Role {role.Name}'s color has been changed.");
} catch (Exception ex) { } catch (Exception ex) {
await e.Send(":warning: Unspecified error, please report this."); await e.Channel.SendMessage(":warning: Unspecified error, please report this.");
Console.WriteLine($".rolecolor error: {ex}"); Console.WriteLine($".rolecolor error: {ex}");
} }
@ -152,17 +152,17 @@ namespace NadekoBot.Modules {
if (!string.IsNullOrWhiteSpace(e.GetArg("user"))) { if (!string.IsNullOrWhiteSpace(e.GetArg("user"))) {
var usr = e.Server.FindUsers(e.GetArg("user")).FirstOrDefault(); var usr = e.Server.FindUsers(e.GetArg("user")).FirstOrDefault();
if (usr != null) { if (usr != null) {
await e.Send($"`List of roles for **{usr.Name}**:` \n• " + string.Join("\n• ", usr.Roles).Replace("@everyone", "මeveryone")); await e.Channel.SendMessage($"`List of roles for **{usr.Name}**:` \n• " + string.Join("\n• ", usr.Roles).Replace("@everyone", "මeveryone"));
return; return;
} }
} }
await e.Send("`List of roles:` \n• " + string.Join("\n• ", e.Server.Roles).Replace("@everyone", "මeveryone")); await e.Channel.SendMessage("`List of roles:` \n• " + string.Join("\n• ", e.Server.Roles).Replace("@everyone", "මeveryone"));
}); });
cgb.CreateCommand(".modules") cgb.CreateCommand(".modules")
.Description("List all bot modules") .Description("List all bot modules")
.Do(async e => { .Do(async e => {
await e.Send("`List of modules:` \n• " + string.Join("\n• ", NadekoBot.client.GetService<ModuleService>().Modules.Select(m => m.Name))); await e.Channel.SendMessage("`List of modules:` \n• " + string.Join("\n• ", NadekoBot.client.GetService<ModuleService>().Modules.Select(m => m.Name)));
}); });
cgb.CreateCommand(".commands") cgb.CreateCommand(".commands")
@ -172,10 +172,10 @@ namespace NadekoBot.Modules {
var commands = NadekoBot.client.GetService<CommandService>().AllCommands var commands = NadekoBot.client.GetService<CommandService>().AllCommands
.Where(c => c.Category.ToLower() == e.GetArg("module").Trim().ToLower()); .Where(c => c.Category.ToLower() == e.GetArg("module").Trim().ToLower());
if (commands == null || commands.Count() == 0) { if (commands == null || commands.Count() == 0) {
await e.Send("That module does not exist."); await e.Channel.SendMessage("That module does not exist.");
return; return;
} }
await e.Send("`List of commands:` \n• " + string.Join("\n• ", commands.Select(c => c.Text))); await e.Channel.SendMessage("`List of commands:` \n• " + string.Join("\n• ", commands.Select(c => c.Text)));
}); });
cgb.CreateCommand(".b").Alias(".ban") cgb.CreateCommand(".b").Alias(".ban")
@ -186,7 +186,7 @@ namespace NadekoBot.Modules {
if (e.User.ServerPermissions.BanMembers && e.Message.MentionedUsers.Any()) { if (e.User.ServerPermissions.BanMembers && e.Message.MentionedUsers.Any()) {
var usr = e.Message.MentionedUsers.First(); var usr = e.Message.MentionedUsers.First();
await usr.Server.Ban(usr); await usr.Server.Ban(usr);
await e.Send("Banned user " + usr.Name + " Id: " + usr.Id); await e.Channel.SendMessage("Banned user " + usr.Name + " Id: " + usr.Id);
} }
} catch (Exception ex) { } } catch (Exception ex) { }
}); });
@ -199,7 +199,7 @@ namespace NadekoBot.Modules {
if (e.User.ServerPermissions.BanMembers && e.Message.MentionedUsers.Any()) { if (e.User.ServerPermissions.BanMembers && e.Message.MentionedUsers.Any()) {
var usr = e.Message.MentionedUsers.First(); var usr = e.Message.MentionedUsers.First();
await usr.Server.Unban(usr); await usr.Server.Unban(usr);
await e.Send("Unbanned user " + usr.Name + " Id: " + usr.Id); await e.Channel.SendMessage("Unbanned user " + usr.Name + " Id: " + usr.Id);
} }
} catch { } } catch { }
}); });
@ -212,10 +212,10 @@ namespace NadekoBot.Modules {
if (e.User.ServerPermissions.KickMembers && e.Message.MentionedUsers.Any()) { if (e.User.ServerPermissions.KickMembers && e.Message.MentionedUsers.Any()) {
var usr = e.Message.MentionedUsers.First(); var usr = e.Message.MentionedUsers.First();
await e.Message.MentionedUsers.First().Kick(); await e.Message.MentionedUsers.First().Kick();
await e.Send("Kicked user " + usr.Name + " Id: " + usr.Id); await e.Channel.SendMessage("Kicked user " + usr.Name + " Id: " + usr.Id);
} }
} catch { } catch {
await e.Send("No sufficient permissions."); await e.Channel.SendMessage("No sufficient permissions.");
} }
}); });
cgb.CreateCommand(".mute") cgb.CreateCommand(".mute")
@ -223,7 +223,7 @@ namespace NadekoBot.Modules {
.Parameter("throwaway", ParameterType.Unparsed) .Parameter("throwaway", ParameterType.Unparsed)
.Do(async e => { .Do(async e => {
if (!e.User.ServerPermissions.MuteMembers) { if (!e.User.ServerPermissions.MuteMembers) {
await e.Send("You do not have permission to do that."); await e.Channel.SendMessage("You do not have permission to do that.");
return; return;
} }
if (e.Message.MentionedUsers.Count() == 0) if (e.Message.MentionedUsers.Count() == 0)
@ -232,9 +232,9 @@ namespace NadekoBot.Modules {
foreach (var u in e.Message.MentionedUsers) { foreach (var u in e.Message.MentionedUsers) {
await u.Edit(isMuted: true); await u.Edit(isMuted: true);
} }
await e.Send("Mute successful"); await e.Channel.SendMessage("Mute successful");
} catch { } catch {
await e.Send("I do not have permission to do that most likely."); await e.Channel.SendMessage("I do not have permission to do that most likely.");
} }
}); });
@ -243,7 +243,7 @@ namespace NadekoBot.Modules {
.Parameter("throwaway", ParameterType.Unparsed) .Parameter("throwaway", ParameterType.Unparsed)
.Do(async e => { .Do(async e => {
if (!e.User.ServerPermissions.MuteMembers) { if (!e.User.ServerPermissions.MuteMembers) {
await e.Send("You do not have permission to do that."); await e.Channel.SendMessage("You do not have permission to do that.");
return; return;
} }
if (e.Message.MentionedUsers.Count() == 0) if (e.Message.MentionedUsers.Count() == 0)
@ -252,9 +252,9 @@ namespace NadekoBot.Modules {
foreach (var u in e.Message.MentionedUsers) { foreach (var u in e.Message.MentionedUsers) {
await u.Edit(isMuted: false); await u.Edit(isMuted: false);
} }
await e.Send("Unmute successful"); await e.Channel.SendMessage("Unmute successful");
} catch { } catch {
await e.Send("I do not have permission to do that most likely."); await e.Channel.SendMessage("I do not have permission to do that most likely.");
} }
}); });
@ -264,7 +264,7 @@ namespace NadekoBot.Modules {
.Parameter("throwaway", ParameterType.Unparsed) .Parameter("throwaway", ParameterType.Unparsed)
.Do(async e => { .Do(async e => {
if (!e.User.ServerPermissions.DeafenMembers) { if (!e.User.ServerPermissions.DeafenMembers) {
await e.Send("You do not have permission to do that."); await e.Channel.SendMessage("You do not have permission to do that.");
return; return;
} }
if (e.Message.MentionedUsers.Count() == 0) if (e.Message.MentionedUsers.Count() == 0)
@ -273,9 +273,9 @@ namespace NadekoBot.Modules {
foreach (var u in e.Message.MentionedUsers) { foreach (var u in e.Message.MentionedUsers) {
await u.Edit(isDeafened: true); await u.Edit(isDeafened: true);
} }
await e.Send("Deafen successful"); await e.Channel.SendMessage("Deafen successful");
} catch { } catch {
await e.Send("I do not have permission to do that most likely."); await e.Channel.SendMessage("I do not have permission to do that most likely.");
} }
}); });
@ -285,7 +285,7 @@ namespace NadekoBot.Modules {
.Parameter("throwaway", ParameterType.Unparsed) .Parameter("throwaway", ParameterType.Unparsed)
.Do(async e => { .Do(async e => {
if (!e.User.ServerPermissions.DeafenMembers) { if (!e.User.ServerPermissions.DeafenMembers) {
await e.Send("You do not have permission to do that."); await e.Channel.SendMessage("You do not have permission to do that.");
return; return;
} }
if (e.Message.MentionedUsers.Count() == 0) if (e.Message.MentionedUsers.Count() == 0)
@ -294,9 +294,9 @@ namespace NadekoBot.Modules {
foreach (var u in e.Message.MentionedUsers) { foreach (var u in e.Message.MentionedUsers) {
await u.Edit(isDeafened: false); await u.Edit(isDeafened: false);
} }
await e.Send("Undeafen successful"); await e.Channel.SendMessage("Undeafen successful");
} catch { } catch {
await e.Send("I do not have permission to do that most likely."); await e.Channel.SendMessage("I do not have permission to do that most likely.");
} }
}); });
@ -307,10 +307,10 @@ namespace NadekoBot.Modules {
try { try {
if (e.User.ServerPermissions.ManageChannels) { if (e.User.ServerPermissions.ManageChannels) {
await e.Server.FindChannels(e.GetArg("channel_name"), ChannelType.Voice).FirstOrDefault()?.Delete(); await e.Server.FindChannels(e.GetArg("channel_name"), ChannelType.Voice).FirstOrDefault()?.Delete();
await e.Send($"Removed channel **{e.GetArg("channel_name")}**."); await e.Channel.SendMessage($"Removed channel **{e.GetArg("channel_name")}**.");
} }
} catch { } catch {
await e.Send("No sufficient permissions."); await e.Channel.SendMessage("No sufficient permissions.");
} }
}); });
@ -321,10 +321,10 @@ namespace NadekoBot.Modules {
try { try {
if (e.User.ServerPermissions.ManageChannels) { if (e.User.ServerPermissions.ManageChannels) {
await e.Server.CreateChannel(e.GetArg("channel_name"), ChannelType.Voice); await e.Server.CreateChannel(e.GetArg("channel_name"), ChannelType.Voice);
await e.Send($"Created voice channel **{e.GetArg("channel_name")}**."); await e.Channel.SendMessage($"Created voice channel **{e.GetArg("channel_name")}**.");
} }
} catch { } catch {
await e.Send("No sufficient permissions."); await e.Channel.SendMessage("No sufficient permissions.");
} }
}); });
@ -335,10 +335,10 @@ namespace NadekoBot.Modules {
try { try {
if (e.User.ServerPermissions.ManageChannels) { if (e.User.ServerPermissions.ManageChannels) {
await e.Server.FindChannels(e.GetArg("channel_name"), ChannelType.Text).FirstOrDefault()?.Delete(); await e.Server.FindChannels(e.GetArg("channel_name"), ChannelType.Text).FirstOrDefault()?.Delete();
await e.Send($"Removed text channel **{e.GetArg("channel_name")}**."); await e.Channel.SendMessage($"Removed text channel **{e.GetArg("channel_name")}**.");
} }
} catch { } catch {
await e.Send("No sufficient permissions."); await e.Channel.SendMessage("No sufficient permissions.");
} }
}); });
@ -349,10 +349,10 @@ namespace NadekoBot.Modules {
try { try {
if (e.User.ServerPermissions.ManageChannels) { if (e.User.ServerPermissions.ManageChannels) {
await e.Server.CreateChannel(e.GetArg("channel_name"), ChannelType.Text); await e.Server.CreateChannel(e.GetArg("channel_name"), ChannelType.Text);
await e.Send($"Added text channel **{e.GetArg("channel_name")}**."); await e.Channel.SendMessage($"Added text channel **{e.GetArg("channel_name")}**.");
} }
} catch { } catch {
await e.Send("No sufficient permissions."); await e.Channel.SendMessage("No sufficient permissions.");
} }
}); });
@ -372,16 +372,16 @@ namespace NadekoBot.Modules {
.Do(async e => { .Do(async e => {
var usr = e.User; var usr = e.User;
if (e.GetArg("user") != null) usr = e.Channel.FindUsers(e.GetArg("user")).FirstOrDefault(); if (e.GetArg("user") != null) usr = e.Channel.FindUsers(e.GetArg("user")).FirstOrDefault();
await e.Send($"Id of the user { usr.Name } is { usr.Id }"); await e.Channel.SendMessage($"Id of the user { usr.Name } is { usr.Id }");
}); });
cgb.CreateCommand(".cid").Alias(".channelid") cgb.CreateCommand(".cid").Alias(".channelid")
.Description("Shows current channel id") .Description("Shows current channel id")
.Do(async e => await e.Send("This channel's id is " + e.Channel.Id)); .Do(async e => await e.Channel.SendMessage("This channel's id is " + e.Channel.Id));
cgb.CreateCommand(".sid").Alias(".serverid") cgb.CreateCommand(".sid").Alias(".serverid")
.Description("Shows current server id") .Description("Shows current server id")
.Do(async e => await e.Send("This server's id is " + e.Server.Id)); .Do(async e => await e.Channel.SendMessage("This server's id is " + e.Server.Id));
cgb.CreateCommand(".stats") cgb.CreateCommand(".stats")
.Description("Shows some basic stats for nadeko") .Description("Shows some basic stats for nadeko")
@ -390,7 +390,7 @@ namespace NadekoBot.Modules {
return NadekoStats.Instance.GetStats() + "`" + Music.GetMusicStats() + "`"; return NadekoStats.Instance.GetStats() + "`" + Music.GetMusicStats() + "`";
}); });
await e.Send(await t); await e.Channel.SendMessage(await t);
}); });
@ -425,7 +425,7 @@ namespace NadekoBot.Modules {
t.Interval = 2000; t.Interval = 2000;
t.Elapsed += (s, ev) => { Environment.Exit(0); }; t.Elapsed += (s, ev) => { Environment.Exit(0); };
t.Start(); t.Start();
await e.Send("`Shutting down.`"); await e.Channel.SendMessage("`Shutting down.`");
} }
}); });
@ -484,7 +484,7 @@ namespace NadekoBot.Modules {
image.Save("data/avatar.png", System.Drawing.Imaging.ImageFormat.Png); image.Save("data/avatar.png", System.Drawing.Imaging.ImageFormat.Png);
await client.CurrentUser.Edit(NadekoBot.password, avatar: image.ToStream()); await client.CurrentUser.Edit(NadekoBot.password, avatar: image.ToStream());
// Send confirm. // Send confirm.
await e.Send("New avatar set."); await e.Channel.SendMessage("New avatar set.");
}); });
cgb.CreateCommand(".setgame") cgb.CreateCommand(".setgame")
@ -519,9 +519,9 @@ namespace NadekoBot.Modules {
commsUser = commsServer?.FindUsers(e.GetArg("name")).FirstOrDefault(); commsUser = commsServer?.FindUsers(e.GetArg("name")).FirstOrDefault();
if (commsUser != null) { if (commsUser != null) {
commsChannel = null; commsChannel = null;
await e.Send("User for comms set."); await e.Channel.SendMessage("User for comms set.");
} else } else
await e.Send("No server specified or user."); await e.Channel.SendMessage("No server specified or user.");
}); });
cgb.CreateCommand(".commsserver") cgb.CreateCommand(".commsserver")
@ -531,9 +531,9 @@ namespace NadekoBot.Modules {
if (e.User.Id != NadekoBot.OwnerID) return; if (e.User.Id != NadekoBot.OwnerID) return;
commsServer = client.FindServers(e.GetArg("server")).FirstOrDefault(); commsServer = client.FindServers(e.GetArg("server")).FirstOrDefault();
if (commsServer != null) if (commsServer != null)
await e.Send("Server for comms set."); await e.Channel.SendMessage("Server for comms set.");
else else
await e.Send("No such server."); await e.Channel.SendMessage("No such server.");
}); });
cgb.CreateCommand(".commschannel") cgb.CreateCommand(".commschannel")
@ -544,9 +544,9 @@ namespace NadekoBot.Modules {
commsChannel = commsServer?.FindChannels(e.GetArg("ch"), ChannelType.Text).FirstOrDefault(); commsChannel = commsServer?.FindChannels(e.GetArg("ch"), ChannelType.Text).FirstOrDefault();
if (commsChannel != null) { if (commsChannel != null) {
commsUser = null; commsUser = null;
await e.Send("Server for comms set."); await e.Channel.SendMessage("Server for comms set.");
} else } else
await e.Send("No server specified or channel is invalid."); await e.Channel.SendMessage("No server specified or channel is invalid.");
}); });
cgb.CreateCommand(".send") cgb.CreateCommand(".send")
@ -559,7 +559,7 @@ namespace NadekoBot.Modules {
else if (commsChannel != null) else if (commsChannel != null)
await commsChannel.SendMessage(e.GetArg("msg")); await commsChannel.SendMessage(e.GetArg("msg"));
else else
await e.Send("Failed. Make sure you've specified server and [channel or user]"); await e.Channel.SendMessage("Failed. Make sure you've specified server and [channel or user]");
}); });
cgb.CreateCommand(".menrole") cgb.CreateCommand(".menrole")

View File

@ -34,13 +34,13 @@ namespace NadekoBot.Modules {
cgb.CreateCommand("\\o\\") cgb.CreateCommand("\\o\\")
.Description("Nadeko replies with /o/") .Description("Nadeko replies with /o/")
.Do(async e => { .Do(async e => {
await e.Send(e.User.Mention + "/o/"); await e.Channel.SendMessage(e.User.Mention + "/o/");
}); });
cgb.CreateCommand("/o/") cgb.CreateCommand("/o/")
.Description("Nadeko replies with \\o\\") .Description("Nadeko replies with \\o\\")
.Do(async e => { .Do(async e => {
await e.Send(e.User.Mention + "\\o\\"); await e.Channel.SendMessage(e.User.Mention + "\\o\\");
}); });
}); });
@ -56,7 +56,7 @@ namespace NadekoBot.Modules {
.Do(async e => { .Do(async e => {
var time = (DateTime.Now - Process.GetCurrentProcess().StartTime); var time = (DateTime.Now - Process.GetCurrentProcess().StartTime);
string str = "I am online for " + time.Days + " days, " + time.Hours + " hours, and " + time.Minutes + " minutes."; string str = "I am online for " + time.Days + " days, " + time.Hours + " hours, and " + time.Minutes + " minutes.";
await e.Send(str); await e.Channel.SendMessage(str);
}); });
cgb.CreateCommand("die") cgb.CreateCommand("die")
@ -67,9 +67,9 @@ namespace NadekoBot.Modules {
t.Interval = 2000; t.Interval = 2000;
t.Elapsed += (s, ev) => { Environment.Exit(0); }; t.Elapsed += (s, ev) => { Environment.Exit(0); };
t.Start(); t.Start();
await e.Send(e.User.Mention + ", Yes, my love."); await e.Channel.SendMessage(e.User.Mention + ", Yes, my love.");
} else } else
await e.Send(e.User.Mention + ", No."); await e.Channel.SendMessage(e.User.Mention + ", No.");
}); });
Stopwatch randServerSW = new Stopwatch(); Stopwatch randServerSW = new Stopwatch();
@ -79,12 +79,12 @@ namespace NadekoBot.Modules {
.Description("Generates an invite to a random server and prints some stats.") .Description("Generates an invite to a random server and prints some stats.")
.Do(async e => { .Do(async e => {
if (client.Servers.Count() < 10) { if (client.Servers.Count() < 10) {
await e.Send("I need to be connected to at least 10 servers for this command to work."); await e.Channel.SendMessage("I need to be connected to at least 10 servers for this command to work.");
return; return;
} }
if (randServerSW.Elapsed.Seconds < 1800) { if (randServerSW.Elapsed.Seconds < 1800) {
await e.Send("You have to wait " + (1800 - randServerSW.Elapsed.Seconds) + " more seconds to use this function."); await e.Channel.SendMessage("You have to wait " + (1800 - randServerSW.Elapsed.Seconds) + " more seconds to use this function.");
return; return;
} }
randServerSW.Restart(); randServerSW.Restart();
@ -94,7 +94,7 @@ namespace NadekoBot.Modules {
continue; continue;
try { try {
var inv = await server.CreateInvite(100, 5); var inv = await server.CreateInvite(100, 5);
await e.Send("**Server:** " + server.Name + await e.Channel.SendMessage("**Server:** " + server.Name +
"\n**Owner:** " + server.Owner.Name + "\n**Owner:** " + server.Owner.Name +
"\n**Channels:** " + server.AllChannels.Count() + "\n**Channels:** " + server.AllChannels.Count() +
"\n**Total Members:** " + server.Users.Count() + "\n**Total Members:** " + server.Users.Count() +
@ -125,22 +125,22 @@ namespace NadekoBot.Modules {
.Description("Replies with positive answer only to the bot owner.") .Description("Replies with positive answer only to the bot owner.")
.Do(async e => { .Do(async e => {
if (e.User.Id == NadekoBot.OwnerID) if (e.User.Id == NadekoBot.OwnerID)
await e.Send(e.User.Mention + ", Of course I do, my Master."); await e.Channel.SendMessage(e.User.Mention + ", Of course I do, my Master.");
else else
await e.Send(e.User.Mention + ", Don't be silly."); await e.Channel.SendMessage(e.User.Mention + ", Don't be silly.");
}); });
cgb.CreateCommand("how are you") cgb.CreateCommand("how are you")
.Description("Replies positive only if bot owner is online.") .Description("Replies positive only if bot owner is online.")
.Do(async e => { .Do(async e => {
if (e.User.Id == NadekoBot.OwnerID) { if (e.User.Id == NadekoBot.OwnerID) {
await e.Send(e.User.Mention + " I am great as long as you are here."); await e.Channel.SendMessage(e.User.Mention + " I am great as long as you are here.");
} else { } else {
var kw = e.Server.GetUser(NadekoBot.OwnerID); var kw = e.Server.GetUser(NadekoBot.OwnerID);
if (kw != null && kw.Status == UserStatus.Online) { if (kw != null && kw.Status == UserStatus.Online) {
await e.Send(e.User.Mention + " I am great as long as " + kw.Mention + " is with me."); await e.Channel.SendMessage(e.User.Mention + " I am great as long as " + kw.Mention + " is with me.");
} else { } else {
await e.Send(e.User.Mention + " I am sad. My Master is not with me."); await e.Channel.SendMessage(e.User.Mention + " I am sad. My Master is not with me.");
} }
} }
}); });
@ -153,15 +153,15 @@ namespace NadekoBot.Modules {
Random r = new Random(); Random r = new Random();
var u = e.Channel.FindUsers(e.GetArg("mention")).FirstOrDefault(); var u = e.Channel.FindUsers(e.GetArg("mention")).FirstOrDefault();
if (u == null) { if (u == null) {
await e.Send("Invalid user specified."); await e.Channel.SendMessage("Invalid user specified.");
return; return;
} }
if (u.Id == NadekoBot.OwnerID) { if (u.Id == NadekoBot.OwnerID) {
await e.Send("I would never insult my master <3"); await e.Channel.SendMessage("I would never insult my master <3");
return; return;
} }
await e.Send(u.Mention + insults[r.Next(0, insults.Count)]); await e.Channel.SendMessage(u.Mention + insults[r.Next(0, insults.Count)]);
}); });
cgb.CreateCommand("praise") cgb.CreateCommand("praise")
@ -179,15 +179,15 @@ namespace NadekoBot.Modules {
var u = e.Channel.FindUsers(e.GetArg("mention")).FirstOrDefault(); var u = e.Channel.FindUsers(e.GetArg("mention")).FirstOrDefault();
if (u == null) { if (u == null) {
await e.Send("Invalid user specified."); await e.Channel.SendMessage("Invalid user specified.");
return; return;
} }
if (u.Id == NadekoBot.OwnerID) { if (u.Id == NadekoBot.OwnerID) {
await e.Send(e.User.Mention + " I don't need your permission to praise my beloved Master <3"); await e.Channel.SendMessage(e.User.Mention + " I don't need your permission to praise my beloved Master <3");
return; return;
} }
await e.Send(u.Mention + praises[r.Next(0, praises.Count)]); await e.Channel.SendMessage(u.Mention + praises[r.Next(0, praises.Count)]);
}); });
cgb.CreateCommand("pat") cgb.CreateCommand("pat")
@ -206,7 +206,7 @@ namespace NadekoBot.Modules {
"http://gallery1.anivide.com/_full/65030_1382582341.gif", "http://gallery1.anivide.com/_full/65030_1382582341.gif",
"https://49.media.tumblr.com/8e8a099c4eba22abd3ec0f70fd087cce/tumblr_nxovj9oY861ur1mffo1_500.gif ", "https://49.media.tumblr.com/8e8a099c4eba22abd3ec0f70fd087cce/tumblr_nxovj9oY861ur1mffo1_500.gif ",
}; };
await e.Send($"{e.Message.MentionedUsers.First().Mention} {pats[new Random().Next(0, pats.Length)]}"); await e.Channel.SendMessage($"{e.Message.MentionedUsers.First().Mention} {pats[new Random().Next(0, pats.Length)]}");
}); });
cgb.CreateCommand("cry") cgb.CreateCommand("cry")
@ -216,13 +216,13 @@ namespace NadekoBot.Modules {
"http://i.imgur.com/3K8DRrU.gif", "http://i.imgur.com/3K8DRrU.gif",
"http://i.imgur.com/k58BcAv.gif", "http://i.imgur.com/k58BcAv.gif",
"http://i.imgur.com/I2fLXwo.gif" }; "http://i.imgur.com/I2fLXwo.gif" };
await e.Send($"(•̥́ _•ૅ。)\n{pats[new Random().Next(0, pats.Length)]}"); await e.Channel.SendMessage($"(•̥́ _•ૅ。)\n{pats[new Random().Next(0, pats.Length)]}");
}); });
cgb.CreateCommand("are you real") cgb.CreateCommand("are you real")
.Description("Useless.") .Description("Useless.")
.Do(async e => { .Do(async e => {
await e.Send(e.User.Mention + " I will be soon."); await e.Channel.SendMessage(e.User.Mention + " I will be soon.");
}); });
cgb.CreateCommand("are you there") cgb.CreateCommand("are you there")
@ -233,7 +233,7 @@ namespace NadekoBot.Modules {
cgb.CreateCommand("draw") cgb.CreateCommand("draw")
.Description("Nadeko instructs you to type $draw. Gambling functions start with $") .Description("Nadeko instructs you to type $draw. Gambling functions start with $")
.Do(async e => { .Do(async e => {
await e.Send("Sorry, I don't gamble, type $draw for that function."); await e.Channel.SendMessage("Sorry, I don't gamble, type $draw for that function.");
}); });
cgb.CreateCommand("fire") cgb.CreateCommand("fire")
.Description("Shows a unicode fire message. Optional parameter [x] tells her how many times to repeat the fire.\n**Usage**: @NadekoBot fire [x]") .Description("Shows a unicode fire message. Optional parameter [x] tells her how many times to repeat the fire.\n**Usage**: @NadekoBot fire [x]")
@ -251,7 +251,7 @@ namespace NadekoBot.Modules {
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
str += firestr; str += firestr;
} }
await e.Send(str); await e.Channel.SendMessage(str);
}); });
cgb.CreateCommand("rip") cgb.CreateCommand("rip")
@ -271,10 +271,10 @@ namespace NadekoBot.Modules {
.Do(async e => { .Do(async e => {
try { try {
await (await client.GetInvite(e.Args[0])).Accept(); await (await client.GetInvite(e.Args[0])).Accept();
await e.Send("I got in!"); await e.Channel.SendMessage("I got in!");
} }
catch { catch {
await e.Send("Invalid code."); await e.Channel.SendMessage("Invalid code.");
} }
}); });
} }
@ -302,9 +302,9 @@ namespace NadekoBot.Modules {
} }
} }
if (msg != null) if (msg != null)
await e.Send($"Last message mentioning you was at {msg.Timestamp}\n**Message from {msg.User.Name}:** {msg.RawText.Replace("@everyone", "@everryone")}"); await e.Channel.SendMessage($"Last message mentioning you was at {msg.Timestamp}\n**Message from {msg.User.Name}:** {msg.RawText.Replace("@everyone", "@everryone")}");
else else
await e.Send("I can't find a message mentioning you."); await e.Channel.SendMessage("I can't find a message mentioning you.");
}); });
cgb.CreateCommand("bb") cgb.CreateCommand("bb")
@ -316,14 +316,14 @@ namespace NadekoBot.Modules {
if (u.Id != NadekoBot.client.CurrentUser.Id) if (u.Id != NadekoBot.client.CurrentUser.Id)
str += " " + u.Mention; str += " " + u.Mention;
} }
await e.Send(str); await e.Channel.SendMessage(str);
}); });
cgb.CreateCommand("call") cgb.CreateCommand("call")
.Description("Useless. Writes calling @X to chat.\n**Usage**: @NadekoBot call @X ") .Description("Useless. Writes calling @X to chat.\n**Usage**: @NadekoBot call @X ")
.Parameter("who", ParameterType.Required) .Parameter("who", ParameterType.Required)
.Do(async e => { .Do(async e => {
await e.Send("Calling " + e.Args[0].Replace("@everyone", "[everyone]") + "..."); await e.Channel.SendMessage("Calling " + e.Args[0].Replace("@everyone", "[everyone]") + "...");
}); });
cgb.CreateCommand("hide") cgb.CreateCommand("hide")
.Description("Hides nadeko in plain sight!11!!") .Description("Hides nadeko in plain sight!11!!")
@ -331,7 +331,7 @@ namespace NadekoBot.Modules {
using (Stream ms = Resources.hidden.ToStream(ImageFormat.Png)) { using (Stream ms = Resources.hidden.ToStream(ImageFormat.Png)) {
await client.CurrentUser.Edit(NadekoBot.password, avatar: ms); await client.CurrentUser.Edit(NadekoBot.password, avatar: ms);
} }
await e.Send("*hides*"); await e.Channel.SendMessage("*hides*");
}); });
cgb.CreateCommand("unhide") cgb.CreateCommand("unhide")
@ -340,7 +340,7 @@ namespace NadekoBot.Modules {
using (FileStream fs = new FileStream("data/avatar.png", FileMode.Open)) { using (FileStream fs = new FileStream("data/avatar.png", FileMode.Open)) {
await client.CurrentUser.Edit(NadekoBot.password, avatar: fs); await client.CurrentUser.Edit(NadekoBot.password, avatar: fs);
} }
await e.Send("*unhides*"); await e.Channel.SendMessage("*unhides*");
}); });
cgb.CreateCommand("dump") cgb.CreateCommand("dump")
@ -361,7 +361,7 @@ namespace NadekoBot.Modules {
} }
} }
File.WriteAllText("dump.txt", invites); File.WriteAllText("dump.txt", invites);
await e.Send($"Got invites for {i} servers and failed to get invites for {j} servers"); await e.Channel.SendMessage($"Got invites for {i} servers and failed to get invites for {j} servers");
}); });
cgb.CreateCommand("ab") cgb.CreateCommand("ab")
@ -373,7 +373,7 @@ namespace NadekoBot.Modules {
while (cnt-- > 0) { while (cnt-- > 0) {
construct += strings[rng.Next(0, strings.Length)]; construct += strings[rng.Next(0, strings.Length)];
} }
await e.Send(construct); await e.Channel.SendMessage(construct);
}); });
cgb.CreateCommand("av").Alias("avatar") cgb.CreateCommand("av").Alias("avatar")
@ -382,10 +382,10 @@ namespace NadekoBot.Modules {
.Do(async e => { .Do(async e => {
var usr = e.Channel.FindUsers(e.GetArg("mention")).FirstOrDefault(); var usr = e.Channel.FindUsers(e.GetArg("mention")).FirstOrDefault();
if (usr == null) { if (usr == null) {
await e.Send("Invalid user specified."); await e.Channel.SendMessage("Invalid user specified.");
return; return;
} }
await e.Send(await usr.AvatarUrl.ShortenUrl()); await e.Channel.SendMessage(await usr.AvatarUrl.ShortenUrl());
}); });
/* /*
string saved = ""; string saved = "";
@ -405,7 +405,7 @@ namespace NadekoBot.Modules {
.Parameter("arg", ParameterType.Required) .Parameter("arg", ParameterType.Required)
.Do(async e => { .Do(async e => {
var arg = e.GetArg("arg"); var arg = e.GetArg("arg");
await e.Send("```"+saved+"```"); await e.Channel.SendMessage("```"+saved+"```");
}); });
*/ */
//TODO add eval //TODO add eval
@ -417,7 +417,7 @@ namespace NadekoBot.Modules {
if (e.Message.User.Id == NadekoBot.OwnerId) if (e.Message.User.Id == NadekoBot.OwnerId)
{ {
var result = await CSharpScript.EvaluateAsync(e.Args[0]); var result = await CSharpScript.EvaluateAsync(e.Args[0]);
await e.Send( result?.ToString() ?? "null"); await e.Channel.SendMessage( result?.ToString() ?? "null");
return; return;
} }
});*/ });*/
@ -446,6 +446,6 @@ namespace NadekoBot.Modules {
} }
private Func<CommandEventArgs, Task> SayYes() private Func<CommandEventArgs, Task> SayYes()
=> async e => await e.Send("Yes. :)"); => async e => await e.Channel.SendMessage("Yes. :)");
} }
} }

View File

@ -41,7 +41,7 @@ namespace NadekoBot.Modules
var list = arg.Split(';'); var list = arg.Split(';');
if (list.Count() < 2) if (list.Count() < 2)
return; return;
await e.Send(list[new Random().Next(0, list.Length)]); await e.Channel.SendMessage(list[new Random().Next(0, list.Length)]);
}); });
cgb.CreateCommand(">8ball") cgb.CreateCommand(">8ball")
@ -73,7 +73,7 @@ namespace NadekoBot.Modules
else if (dmg <= 35) { else if (dmg <= 35) {
response += "Ineffective!"; response += "Ineffective!";
} }
await e.Send($"{ e.User.Mention }{GetImage(GetType(e.User.Id))} {response}"); await e.Channel.SendMessage($"{ e.User.Mention }{GetImage(GetType(e.User.Id))} {response}");
}); });
cgb.CreateCommand("poketype") cgb.CreateCommand("poketype")
@ -83,10 +83,10 @@ namespace NadekoBot.Modules
{ {
var usr = e.Server.FindUsers(e.GetArg("target")).FirstOrDefault(); var usr = e.Server.FindUsers(e.GetArg("target")).FirstOrDefault();
if (usr == null) { if (usr == null) {
await e.Send("No such person."); await e.Channel.SendMessage("No such person.");
} }
var t = GetType(usr.Id); var t = GetType(usr.Id);
await e.Send($"{usr.Name}'s type is {GetImage(t)} {t}"); await e.Channel.SendMessage($"{usr.Name}'s type is {GetImage(t)} {t}");
}); });
}); });
} }

View File

@ -58,9 +58,9 @@ namespace NadekoBot.Modules {
.Do(async e => { .Do(async e => {
if (musicPlayers.ContainsKey(e.Server) == false) return; if (musicPlayers.ContainsKey(e.Server) == false) return;
if (musicPlayers[e.Server].TogglePause()) if (musicPlayers[e.Server].TogglePause())
await e.Send("🎵`Music player paused.`"); await e.Channel.SendMessage("🎵`Music player paused.`");
else else
await e.Send("🎵`Music player unpaused.`"); await e.Channel.SendMessage("🎵`Music player unpaused.`");
}); });
cgb.CreateCommand("q") cgb.CreateCommand("q")
@ -74,16 +74,16 @@ namespace NadekoBot.Modules {
.Description("Lists up to 10 currently queued songs.") .Description("Lists up to 10 currently queued songs.")
.Do(async e => { .Do(async e => {
if (musicPlayers.ContainsKey(e.Server) == false) { if (musicPlayers.ContainsKey(e.Server) == false) {
await e.Send("🎵 No active music player."); await e.Channel.SendMessage("🎵 No active music player.");
return; return;
} }
var player = musicPlayers[e.Server]; var player = musicPlayers[e.Server];
string toSend = "🎵 **" + player.SongQueue.Count + "** `videos currently queued.` "; string toSend = "🎵 **" + player.SongQueue.Count + "** `videos currently queued.` ";
if (player.SongQueue.Count >= 25) if (player.SongQueue.Count >= 25)
toSend += "**Song queue is full!**\n"; toSend += "**Song queue is full!**\n";
await e.Send(toSend); await e.Channel.SendMessage(toSend);
int number = 1; int number = 1;
await e.Send(string.Join("\n", player.SongQueue.Take(10).Select(v => $"`{number++}.` {v.FullPrettyName}"))); await e.Channel.SendMessage(string.Join("\n", player.SongQueue.Take(10).Select(v => $"`{number++}.` {v.FullPrettyName}")));
}); });
cgb.CreateCommand("np") cgb.CreateCommand("np")
@ -92,7 +92,7 @@ namespace NadekoBot.Modules {
.Do(async e => { .Do(async e => {
if (musicPlayers.ContainsKey(e.Server) == false) return; if (musicPlayers.ContainsKey(e.Server) == false) return;
var player = musicPlayers[e.Server]; var player = musicPlayers[e.Server];
await e.Send($"🎵`Now Playing` {player.CurrentSong.FullPrettyName}"); await e.Channel.SendMessage($"🎵`Now Playing` {player.CurrentSong.FullPrettyName}");
}); });
cgb.CreateCommand("vol") cgb.CreateCommand("vol")
@ -104,11 +104,11 @@ namespace NadekoBot.Modules {
var arg = e.GetArg("val"); var arg = e.GetArg("val");
int volume; int volume;
if (!int.TryParse(arg, out volume)) { if (!int.TryParse(arg, out volume)) {
await e.Send("Volume number invalid."); await e.Channel.SendMessage("Volume number invalid.");
return; return;
} }
volume = player.SetVolume(volume); volume = player.SetVolume(volume);
await e.Send($"🎵 `Volume set to {volume}%`"); await e.Channel.SendMessage($"🎵 `Volume set to {volume}%`");
}); });
cgb.CreateCommand("dv") cgb.CreateCommand("dv")
@ -119,11 +119,11 @@ namespace NadekoBot.Modules {
var arg = e.GetArg("val"); var arg = e.GetArg("val");
float volume; float volume;
if (!float.TryParse(arg, out volume) || volume < 0 || volume > 100) { if (!float.TryParse(arg, out volume) || volume < 0 || volume > 100) {
await e.Send("Volume number invalid."); await e.Channel.SendMessage("Volume number invalid.");
return; return;
} }
musicVolumes.AddOrUpdate(e.Server.Id, volume / 100, (key, newval) => volume / 100); musicVolumes.AddOrUpdate(e.Server.Id, volume / 100, (key, newval) => volume / 100);
await e.Send($"🎵 `Default volume set to {volume}%`"); await e.Channel.SendMessage($"🎵 `Default volume set to {volume}%`");
}); });
cgb.CreateCommand("min").Alias("mute") cgb.CreateCommand("min").Alias("mute")
@ -156,12 +156,12 @@ namespace NadekoBot.Modules {
if (musicPlayers.ContainsKey(e.Server) == false) return; if (musicPlayers.ContainsKey(e.Server) == false) return;
var player = musicPlayers[e.Server]; var player = musicPlayers[e.Server];
if (player.SongQueue.Count < 2) { if (player.SongQueue.Count < 2) {
await e.Send("Not enough songs in order to perform the shuffle."); await e.Channel.SendMessage("Not enough songs in order to perform the shuffle.");
return; return;
} }
player.SongQueue.Shuffle(); player.SongQueue.Shuffle();
await e.Send("🎵 `Songs shuffled.`"); await e.Channel.SendMessage("🎵 `Songs shuffled.`");
}); });
bool setgameEnabled = false; bool setgameEnabled = false;
@ -182,7 +182,7 @@ namespace NadekoBot.Modules {
else else
setgameTimer.Stop(); setgameTimer.Stop();
await e.Send("`Music status " + (setgameEnabled ? "enabled`" : "disabled`")); await e.Channel.SendMessage("`Music status " + (setgameEnabled ? "enabled`" : "disabled`"));
}); });
cgb.CreateCommand("pl") cgb.CreateCommand("pl")
@ -190,12 +190,12 @@ namespace NadekoBot.Modules {
.Parameter("playlist", ParameterType.Unparsed) .Parameter("playlist", ParameterType.Unparsed)
.Do(async e => { .Do(async e => {
if (e.User.VoiceChannel?.Server != e.Server) { if (e.User.VoiceChannel?.Server != e.Server) {
await e.Send("💢 You need to be in the voice channel on this server."); await e.Channel.SendMessage("💢 You need to be in the voice channel on this server.");
return; return;
} }
var ids = await SearchHelper.GetVideoIDs(await SearchHelper.GetPlaylistIdByKeyword(e.GetArg("playlist"))); var ids = await SearchHelper.GetVideoIDs(await SearchHelper.GetPlaylistIdByKeyword(e.GetArg("playlist")));
//todo TEMPORARY SOLUTION, USE RESOLVE QUEUE IN THE FUTURE //todo TEMPORARY SOLUTION, USE RESOLVE QUEUE IN THE FUTURE
var msg = await e.Send($"🎵 `Attempting to queue **{ids.Count}** songs".SnPl(ids.Count)+"...`"); var msg = await e.Channel.SendMessage($"🎵 `Attempting to queue **{ids.Count}** songs".SnPl(ids.Count)+"...`");
foreach (var id in ids) { foreach (var id in ids) {
Task.Run(async () => await QueueSong(e, id, true)).ConfigureAwait(false); Task.Run(async () => await QueueSong(e, id, true)).ConfigureAwait(false);
await Task.Delay(150); await Task.Delay(150);
@ -208,7 +208,7 @@ namespace NadekoBot.Modules {
.Parameter("radio_link", ParameterType.Required) .Parameter("radio_link", ParameterType.Required)
.Do(async e => { .Do(async e => {
if (e.User.VoiceChannel?.Server != e.Server) { if (e.User.VoiceChannel?.Server != e.Server) {
await e.Send("💢 You need to be in the voice channel on this server."); await e.Channel.SendMessage("💢 You need to be in the voice channel on this server.");
return; return;
} }
await QueueSong(e, e.GetArg("radio_link"), radio: true); await QueueSong(e, e.GetArg("radio_link"), radio: true);
@ -235,7 +235,7 @@ namespace NadekoBot.Modules {
} }
if (arg?.ToLower() == "all") { if (arg?.ToLower() == "all") {
mc.SongQueue?.Clear(); mc.SongQueue?.Clear();
await e.Send($"🎵Queue cleared!"); await e.Channel.SendMessage($"🎵Queue cleared!");
return; return;
} }
int num; int num;
@ -246,7 +246,7 @@ namespace NadekoBot.Modules {
return; return;
mc.SongQueue.RemoveAt(num - 1); mc.SongQueue.RemoveAt(num - 1);
await e.Send($"🎵Song at position `{num}` has been removed."); await e.Channel.SendMessage($"🎵Song at position `{num}` has been removed.");
}); });
cgb.CreateCommand("debug") cgb.CreateCommand("debug")
@ -263,7 +263,7 @@ namespace NadekoBot.Modules {
private async Task QueueSong(CommandEventArgs e, string query, bool silent = false, bool radio = false) { private async Task QueueSong(CommandEventArgs e, string query, bool silent = false, bool radio = false) {
if (e.User.VoiceChannel?.Server != e.Server) { if (e.User.VoiceChannel?.Server != e.Server) {
await e.Send("💢 You need to be in the voice channel on this server."); await e.Channel.SendMessage("💢 You need to be in the voice channel on this server.");
return; return;
} }
@ -284,7 +284,7 @@ namespace NadekoBot.Modules {
vol = throwAway; vol = throwAway;
if (!musicPlayers.TryAdd(e.Server, new MusicControls(e.User.VoiceChannel, e, vol))) { if (!musicPlayers.TryAdd(e.Server, new MusicControls(e.User.VoiceChannel, e, vol))) {
await e.Send("Failed to create a music player for this server."); await e.Channel.SendMessage("Failed to create a music player for this server.");
return; return;
} }
} }
@ -316,23 +316,23 @@ namespace NadekoBot.Modules {
if (mc.SongQueue.Count == 0) if (mc.SongQueue.Count == 0)
mc.Stop(); mc.Stop();
} }
await e.Send($"🎵`Finished`{sr.FullPrettyName}"); await e.Channel.SendMessage($"🎵`Finished`{sr.FullPrettyName}");
}; };
sr.OnStarted += async () => { sr.OnStarted += async () => {
var msgTxt = $"🎵`Playing`{sr.FullPrettyName} `Vol: {(int)(player.Volume * 100)}%`"; var msgTxt = $"🎵`Playing`{sr.FullPrettyName} `Vol: {(int)(player.Volume * 100)}%`";
if (msg == null) if (msg == null)
await e.Send(msgTxt); await e.Channel.SendMessage(msgTxt);
else else
await msg.Edit(msgTxt); await msg.Edit(msgTxt);
qmsg?.Delete(); qmsg?.Delete();
}; };
sr.OnBuffering += async () => { sr.OnBuffering += async () => {
msg = await e.Send($"🎵`Buffering...`{sr.FullPrettyName}"); msg = await e.Channel.SendMessage($"🎵`Buffering...`{sr.FullPrettyName}");
}; };
await sr.Resolve(); await sr.Resolve();
} catch (Exception ex) { } catch (Exception ex) {
Console.WriteLine(); Console.WriteLine();
await e.Send($"💢 {ex.Message}"); await e.Channel.SendMessage($"💢 {ex.Message}");
return; return;
} }
} }

View File

@ -26,8 +26,8 @@ namespace NadekoBot.Modules {
string tag = e.GetArg("tag"); string tag = e.GetArg("tag");
if (tag == null) if (tag == null)
tag = ""; tag = "";
await e.Send(":heart: Gelbooru: " + await SearchHelper.GetGelbooruImageLink(tag)); await e.Channel.SendMessage(":heart: Gelbooru: " + await SearchHelper.GetGelbooruImageLink(tag));
await e.Send(":heart: Danbooru: " + await SearchHelper.GetDanbooruImageLink(tag)); await e.Channel.SendMessage(":heart: Danbooru: " + await SearchHelper.GetDanbooruImageLink(tag));
}); });
cgb.CreateCommand("~danbooru") cgb.CreateCommand("~danbooru")
.Description("Shows a random hentai image from danbooru with a given tag. Tag is optional but preffered. (multiple tags are appended with +)\n**Usage**: ~danbooru yuri+kissing") .Description("Shows a random hentai image from danbooru with a given tag. Tag is optional but preffered. (multiple tags are appended with +)\n**Usage**: ~danbooru yuri+kissing")
@ -36,7 +36,7 @@ namespace NadekoBot.Modules {
string tag = e.GetArg("tag"); string tag = e.GetArg("tag");
if (tag == null) if (tag == null)
tag = ""; tag = "";
await e.Send(await SearchHelper.GetDanbooruImageLink(tag)); await e.Channel.SendMessage(await SearchHelper.GetDanbooruImageLink(tag));
}); });
cgb.CreateCommand("~gelbooru") cgb.CreateCommand("~gelbooru")
.Description("Shows a random hentai image from gelbooru with a given tag. Tag is optional but preffered. (multiple tags are appended with +)\n**Usage**: ~gelbooru yuri+kissing") .Description("Shows a random hentai image from gelbooru with a given tag. Tag is optional but preffered. (multiple tags are appended with +)\n**Usage**: ~gelbooru yuri+kissing")
@ -45,7 +45,7 @@ namespace NadekoBot.Modules {
string tag = e.GetArg("tag"); string tag = e.GetArg("tag");
if (tag == null) if (tag == null)
tag = ""; tag = "";
await e.Send(await SearchHelper.GetGelbooruImageLink(tag)); await e.Channel.SendMessage(await SearchHelper.GetGelbooruImageLink(tag));
}); });
cgb.CreateCommand("~e621") cgb.CreateCommand("~e621")
.Description("Shows a random hentai image from e621.net with a given tag. Tag is optional but preffered. Use spaces for multiple tags.\n**Usage**: ~e621 yuri kissing") .Description("Shows a random hentai image from e621.net with a given tag. Tag is optional but preffered. Use spaces for multiple tags.\n**Usage**: ~e621 yuri kissing")
@ -54,22 +54,22 @@ namespace NadekoBot.Modules {
string tag = e.GetArg("tag"); string tag = e.GetArg("tag");
if (tag == null) if (tag == null)
tag = ""; tag = "";
await e.Send(await SearchHelper.GetE621ImageLink(tag)); await e.Channel.SendMessage(await SearchHelper.GetE621ImageLink(tag));
}); });
cgb.CreateCommand("~cp") cgb.CreateCommand("~cp")
.Description("We all know where this will lead you to.") .Description("We all know where this will lead you to.")
.Parameter("anything", ParameterType.Unparsed) .Parameter("anything", ParameterType.Unparsed)
.Do(async e => { .Do(async e => {
await e.Send("http://i.imgur.com/MZkY1md.jpg"); await e.Channel.SendMessage("http://i.imgur.com/MZkY1md.jpg");
}); });
cgb.CreateCommand("~boobs") cgb.CreateCommand("~boobs")
.Description("Real adult content.") .Description("Real adult content.")
.Do(async e => { .Do(async e => {
try { try {
var obj = JArray.Parse(await SearchHelper.GetResponseAsync($"http://api.oboobs.ru/boobs/{_r.Next(0, 9304)}"))[0]; var obj = JArray.Parse(await SearchHelper.GetResponseAsync($"http://api.oboobs.ru/boobs/{_r.Next(0, 9304)}"))[0];
await e.Send($"http://media.oboobs.ru/{ obj["preview"].ToString() }"); await e.Channel.SendMessage($"http://media.oboobs.ru/{ obj["preview"].ToString() }");
} catch (Exception ex) { } catch (Exception ex) {
await e.Send($"💢 {ex.Message}"); await e.Channel.SendMessage($"💢 {ex.Message}");
} }
}); });
}); });

View File

@ -1,7 +1,7 @@
using System; using System;
using Discord.Modules; using Discord.Modules;
using Discord.Commands; using Discord.Commands;
using NadekoBot.Extensions; using NadekoBot.Extensions;
using NadekoBot.Classes; using NadekoBot.Classes;
using PermsHandler = NadekoBot.Classes.Permissions.PermissionsHandler; using PermsHandler = NadekoBot.Classes.Permissions.PermissionsHandler;
using System.Linq; using System.Linq;
@ -28,7 +28,7 @@ namespace NadekoBot.Modules {
.Parameter("role", ParameterType.Unparsed) .Parameter("role", ParameterType.Unparsed)
.Do(async e => { .Do(async e => {
if (string.IsNullOrWhiteSpace(e.GetArg("role"))) { if (string.IsNullOrWhiteSpace(e.GetArg("role"))) {
await e.Send($"Current permissions role is `{PermsHandler.GetServerPermissionsRoleName(e.Server)}`"); await e.Channel.SendMessage($"Current permissions role is `{PermsHandler.GetServerPermissionsRoleName(e.Server)}`");
return; return;
} }
@ -39,11 +39,11 @@ namespace NadekoBot.Modules {
} }
catch (Exception ex) { catch (Exception ex) {
Console.WriteLine(ex.Message); Console.WriteLine(ex.Message);
await e.Send($"Role `{arg}` probably doesn't exist. Create the role with that name first."); await e.Channel.SendMessage($"Role `{arg}` probably doesn't exist. Create the role with that name first.");
return; return;
} }
PermsHandler.SetPermissionsRole(e.Server, role.Name); PermsHandler.SetPermissionsRole(e.Server, role.Name);
await e.Send($"Role `{role.Name}` is now required in order to change permissions."); await e.Channel.SendMessage($"Role `{role.Name}` is now required in order to change permissions.");
}); });
cgb.CreateCommand(prefix + "verbose") cgb.CreateCommand(prefix + "verbose")
@ -54,7 +54,7 @@ namespace NadekoBot.Modules {
var arg = e.GetArg("arg"); var arg = e.GetArg("arg");
bool val = PermissionHelper.ValidateBool(arg); bool val = PermissionHelper.ValidateBool(arg);
PermsHandler.SetVerbosity(e.Server, val); PermsHandler.SetVerbosity(e.Server, val);
await e.Send($"Verbosity set to {val}."); await e.Channel.SendMessage($"Verbosity set to {val}.");
}); });
cgb.CreateCommand(prefix + "serverperms") cgb.CreateCommand(prefix + "serverperms")
@ -63,8 +63,8 @@ namespace NadekoBot.Modules {
.Do(async e => { .Do(async e => {
var perms = PermsHandler.GetServerPermissions(e.Server); var perms = PermsHandler.GetServerPermissions(e.Server);
if (string.IsNullOrWhiteSpace(perms?.ToString())) if (string.IsNullOrWhiteSpace(perms?.ToString()))
await e.Send("No permissions set for this server."); await e.Channel.SendMessage("No permissions set for this server.");
await e.Send(perms.ToString()); await e.Channel.SendMessage(perms.ToString());
}); });
cgb.CreateCommand(prefix + "roleperms") cgb.CreateCommand(prefix + "roleperms")
@ -79,15 +79,15 @@ namespace NadekoBot.Modules {
role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role")); role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role"));
} }
catch (Exception ex) { catch (Exception ex) {
await e.Send("💢 Error: " + ex.Message); await e.Channel.SendMessage("💢 Error: " + ex.Message);
return; return;
} }
var perms = PermsHandler.GetRolePermissionsById(e.Server, role.Id); var perms = PermsHandler.GetRolePermissionsById(e.Server, role.Id);
if (string.IsNullOrWhiteSpace(perms?.ToString())) if (string.IsNullOrWhiteSpace(perms?.ToString()))
await e.Send($"No permissions set for **{role.Name}** role."); await e.Channel.SendMessage($"No permissions set for **{role.Name}** role.");
await e.Send(perms.ToString()); await e.Channel.SendMessage(perms.ToString());
}); });
cgb.CreateCommand(prefix + "channelperms") cgb.CreateCommand(prefix + "channelperms")
@ -102,14 +102,14 @@ namespace NadekoBot.Modules {
channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel")); channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel"));
} }
catch (Exception ex) { catch (Exception ex) {
await e.Send("💢 Error: " + ex.Message); await e.Channel.SendMessage("💢 Error: " + ex.Message);
return; return;
} }
var perms = PermsHandler.GetChannelPermissionsById(e.Server, channel.Id); var perms = PermsHandler.GetChannelPermissionsById(e.Server, channel.Id);
if (string.IsNullOrWhiteSpace(perms?.ToString())) if (string.IsNullOrWhiteSpace(perms?.ToString()))
await e.Send($"No permissions set for **{channel.Name}** channel."); await e.Channel.SendMessage($"No permissions set for **{channel.Name}** channel.");
await e.Send(perms.ToString()); await e.Channel.SendMessage(perms.ToString());
}); });
cgb.CreateCommand(prefix + "userperms") cgb.CreateCommand(prefix + "userperms")
@ -124,14 +124,14 @@ namespace NadekoBot.Modules {
user = PermissionHelper.ValidateUser(e.Server, e.GetArg("user")); user = PermissionHelper.ValidateUser(e.Server, e.GetArg("user"));
} }
catch (Exception ex) { catch (Exception ex) {
await e.Send("💢 Error: " + ex.Message); await e.Channel.SendMessage("💢 Error: " + ex.Message);
return; return;
} }
var perms = PermsHandler.GetUserPermissionsById(e.Server, user.Id); var perms = PermsHandler.GetUserPermissionsById(e.Server, user.Id);
if (string.IsNullOrWhiteSpace(perms?.ToString())) if (string.IsNullOrWhiteSpace(perms?.ToString()))
await e.Send($"No permissions set for user **{user.Name}**."); await e.Channel.SendMessage($"No permissions set for user **{user.Name}**.");
await e.Send(perms.ToString()); await e.Channel.SendMessage(perms.ToString());
}); });
cgb.CreateCommand(prefix + "sm").Alias(prefix + "servermodule") cgb.CreateCommand(prefix + "sm").Alias(prefix + "servermodule")
@ -144,13 +144,13 @@ namespace NadekoBot.Modules {
bool state = PermissionHelper.ValidateBool(e.GetArg("bool")); bool state = PermissionHelper.ValidateBool(e.GetArg("bool"));
PermsHandler.SetServerModulePermission(e.Server, module, state); PermsHandler.SetServerModulePermission(e.Server, module, state);
await e.Send($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** on this server."); await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** on this server.");
} }
catch (ArgumentException exArg) { catch (ArgumentException exArg) {
await e.Send(exArg.Message); await e.Channel.SendMessage(exArg.Message);
} }
catch (Exception ex) { catch (Exception ex) {
await e.Send("Something went terribly wrong - " + ex.Message); await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
} }
}); });
@ -164,13 +164,13 @@ namespace NadekoBot.Modules {
bool state = PermissionHelper.ValidateBool(e.GetArg("bool")); bool state = PermissionHelper.ValidateBool(e.GetArg("bool"));
PermsHandler.SetServerCommandPermission(e.Server, command, state); PermsHandler.SetServerCommandPermission(e.Server, command, state);
await e.Send($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** on this server."); await e.Channel.SendMessage($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** on this server.");
} }
catch (ArgumentException exArg) { catch (ArgumentException exArg) {
await e.Send(exArg.Message); await e.Channel.SendMessage(exArg.Message);
} }
catch (Exception ex) { catch (Exception ex) {
await e.Send("Something went terribly wrong - " + ex.Message); await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
} }
}); });
@ -188,20 +188,20 @@ namespace NadekoBot.Modules {
foreach (var role in e.Server.Roles) { foreach (var role in e.Server.Roles) {
PermsHandler.SetRoleModulePermission(role, module, state); PermsHandler.SetRoleModulePermission(role, module, state);
} }
await e.Send($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **ALL** roles."); await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **ALL** roles.");
} }
else { else {
Discord.Role role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role")); Discord.Role role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role"));
PermsHandler.SetRoleModulePermission(role, module, state); PermsHandler.SetRoleModulePermission(role, module, state);
await e.Send($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role."); await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.");
} }
} }
catch (ArgumentException exArg) { catch (ArgumentException exArg) {
await e.Send(exArg.Message); await e.Channel.SendMessage(exArg.Message);
} }
catch (Exception ex) { catch (Exception ex) {
await e.Send("Something went terribly wrong - " + ex.Message); await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
} }
}); });
@ -219,20 +219,20 @@ namespace NadekoBot.Modules {
foreach (var role in e.Server.Roles) { foreach (var role in e.Server.Roles) {
PermsHandler.SetRoleCommandPermission(role, command, state); PermsHandler.SetRoleCommandPermission(role, command, state);
} }
await e.Send($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **ALL** roles."); await e.Channel.SendMessage($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **ALL** roles.");
} }
else { else {
Discord.Role role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role")); Discord.Role role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role"));
PermsHandler.SetRoleCommandPermission(role, command, state); PermsHandler.SetRoleCommandPermission(role, command, state);
await e.Send($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role."); await e.Channel.SendMessage($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.");
} }
} }
catch (ArgumentException exArg) { catch (ArgumentException exArg) {
await e.Send(exArg.Message); await e.Channel.SendMessage(exArg.Message);
} }
catch (Exception ex) { catch (Exception ex) {
await e.Send("Something went terribly wrong - " + ex.Message); await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
} }
}); });
@ -250,20 +250,20 @@ namespace NadekoBot.Modules {
foreach (var channel in e.Server.TextChannels) { foreach (var channel in e.Server.TextChannels) {
PermsHandler.SetChannelModulePermission(channel, module, state); PermsHandler.SetChannelModulePermission(channel, module, state);
} }
await e.Send($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** on **ALL** channels."); await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** on **ALL** channels.");
} }
else { else {
Discord.Channel channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel")); Discord.Channel channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel"));
PermsHandler.SetChannelModulePermission(channel, module, state); PermsHandler.SetChannelModulePermission(channel, module, state);
await e.Send($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel."); await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.");
} }
} }
catch (ArgumentException exArg) { catch (ArgumentException exArg) {
await e.Send(exArg.Message); await e.Channel.SendMessage(exArg.Message);
} }
catch (Exception ex) { catch (Exception ex) {
await e.Send("Something went terribly wrong - " + ex.Message); await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
} }
}); });
@ -281,20 +281,20 @@ namespace NadekoBot.Modules {
foreach (var channel in e.Server.TextChannels) { foreach (var channel in e.Server.TextChannels) {
PermsHandler.SetChannelCommandPermission(channel, command, state); PermsHandler.SetChannelCommandPermission(channel, command, state);
} }
await e.Send($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** on **ALL** channels."); await e.Channel.SendMessage($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** on **ALL** channels.");
} }
else { else {
Discord.Channel channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel")); Discord.Channel channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel"));
PermsHandler.SetChannelCommandPermission(channel, command, state); PermsHandler.SetChannelCommandPermission(channel, command, state);
await e.Send($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel."); await e.Channel.SendMessage($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.");
} }
} }
catch (ArgumentException exArg) { catch (ArgumentException exArg) {
await e.Send(exArg.Message); await e.Channel.SendMessage(exArg.Message);
} }
catch (Exception ex) { catch (Exception ex) {
await e.Send("Something went terribly wrong - " + ex.Message); await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
} }
}); });
@ -310,13 +310,13 @@ namespace NadekoBot.Modules {
Discord.User user = PermissionHelper.ValidateUser(e.Server, e.GetArg("user")); Discord.User user = PermissionHelper.ValidateUser(e.Server, e.GetArg("user"));
PermsHandler.SetUserModulePermission(user, module, state); PermsHandler.SetUserModulePermission(user, module, state);
await e.Send($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for user **{user.Name}**."); await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for user **{user.Name}**.");
} }
catch (ArgumentException exArg) { catch (ArgumentException exArg) {
await e.Send(exArg.Message); await e.Channel.SendMessage(exArg.Message);
} }
catch (Exception ex) { catch (Exception ex) {
await e.Send("Something went terribly wrong - " + ex.Message); await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
} }
}); });
@ -332,13 +332,13 @@ namespace NadekoBot.Modules {
Discord.User user = PermissionHelper.ValidateUser(e.Server, e.GetArg("user")); Discord.User user = PermissionHelper.ValidateUser(e.Server, e.GetArg("user"));
PermsHandler.SetUserCommandPermission(user, command, state); PermsHandler.SetUserCommandPermission(user, command, state);
await e.Send($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for user **{user.Name}**."); await e.Channel.SendMessage($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for user **{user.Name}**.");
} }
catch (ArgumentException exArg) { catch (ArgumentException exArg) {
await e.Send(exArg.Message); await e.Channel.SendMessage(exArg.Message);
} }
catch (Exception ex) { catch (Exception ex) {
await e.Send("Something went terribly wrong - " + ex.Message); await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
} }
}); });
@ -352,13 +352,13 @@ namespace NadekoBot.Modules {
foreach (var module in NadekoBot.client.GetService<ModuleService>().Modules) { foreach (var module in NadekoBot.client.GetService<ModuleService>().Modules) {
PermsHandler.SetServerModulePermission(e.Server, module.Name, state); PermsHandler.SetServerModulePermission(e.Server, module.Name, state);
} }
await e.Send($"All modules have been **{(state ? "enabled" : "disabled")}** on this server."); await e.Channel.SendMessage($"All modules have been **{(state ? "enabled" : "disabled")}** on this server.");
} }
catch (ArgumentException exArg) { catch (ArgumentException exArg) {
await e.Send(exArg.Message); await e.Channel.SendMessage(exArg.Message);
} }
catch (Exception ex) { catch (Exception ex) {
await e.Send("Something went terribly wrong - " + ex.Message); await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
} }
}); });
@ -374,13 +374,13 @@ namespace NadekoBot.Modules {
foreach (var command in NadekoBot.client.GetService<CommandService>().AllCommands.Where(c => c.Category == module)) { foreach (var command in NadekoBot.client.GetService<CommandService>().AllCommands.Where(c => c.Category == module)) {
PermsHandler.SetServerCommandPermission(e.Server, command.Text, state); PermsHandler.SetServerCommandPermission(e.Server, command.Text, state);
} }
await e.Send($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** on this server."); await e.Channel.SendMessage($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** on this server.");
} }
catch (ArgumentException exArg) { catch (ArgumentException exArg) {
await e.Send(exArg.Message); await e.Channel.SendMessage(exArg.Message);
} }
catch (Exception ex) { catch (Exception ex) {
await e.Send("Something went terribly wrong - " + ex.Message); await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
} }
}); });
@ -396,13 +396,13 @@ namespace NadekoBot.Modules {
PermsHandler.SetChannelModulePermission(channel, module.Name, state); PermsHandler.SetChannelModulePermission(channel, module.Name, state);
} }
await e.Send($"All modules have been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel."); await e.Channel.SendMessage($"All modules have been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.");
} }
catch (ArgumentException exArg) { catch (ArgumentException exArg) {
await e.Send(exArg.Message); await e.Channel.SendMessage(exArg.Message);
} }
catch (Exception ex) { catch (Exception ex) {
await e.Send("Something went terribly wrong - " + ex.Message); await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
} }
}); });
@ -419,13 +419,13 @@ namespace NadekoBot.Modules {
foreach (var command in NadekoBot.client.GetService<CommandService>().AllCommands.Where(c => c.Category == module)) { foreach (var command in NadekoBot.client.GetService<CommandService>().AllCommands.Where(c => c.Category == module)) {
PermsHandler.SetChannelCommandPermission(channel, command.Text, state); PermsHandler.SetChannelCommandPermission(channel, command.Text, state);
} }
await e.Send($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel."); await e.Channel.SendMessage($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.");
} }
catch (ArgumentException exArg) { catch (ArgumentException exArg) {
await e.Send(exArg.Message); await e.Channel.SendMessage(exArg.Message);
} }
catch (Exception ex) { catch (Exception ex) {
await e.Send("Something went terribly wrong - " + ex.Message); await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
} }
}); });
@ -441,13 +441,13 @@ namespace NadekoBot.Modules {
PermsHandler.SetRoleModulePermission(role, module.Name, state); PermsHandler.SetRoleModulePermission(role, module.Name, state);
} }
await e.Send($"All modules have been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role."); await e.Channel.SendMessage($"All modules have been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.");
} }
catch (ArgumentException exArg) { catch (ArgumentException exArg) {
await e.Send(exArg.Message); await e.Channel.SendMessage(exArg.Message);
} }
catch (Exception ex) { catch (Exception ex) {
await e.Send("Something went terribly wrong - " + ex.Message); await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
} }
}); });
@ -464,13 +464,13 @@ namespace NadekoBot.Modules {
foreach (var command in NadekoBot.client.GetService<CommandService>().AllCommands.Where(c => c.Category == module)) { foreach (var command in NadekoBot.client.GetService<CommandService>().AllCommands.Where(c => c.Category == module)) {
PermsHandler.SetRoleCommandPermission(role, command.Text, state); PermsHandler.SetRoleCommandPermission(role, command.Text, state);
} }
await e.Send($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role."); await e.Channel.SendMessage($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.");
} }
catch (ArgumentException exArg) { catch (ArgumentException exArg) {
await e.Send(exArg.Message); await e.Channel.SendMessage(exArg.Message);
} }
catch (Exception ex) { catch (Exception ex) {
await e.Send("Something went terribly wrong - " + ex.Message); await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message);
} }
}); });
}); });

View File

@ -34,10 +34,10 @@ namespace NadekoBot.Modules {
var str = await SearchHelper.ShortenUrl(await SearchHelper.FindYoutubeUrlByKeywords(e.GetArg("query"))); var str = await SearchHelper.ShortenUrl(await SearchHelper.FindYoutubeUrlByKeywords(e.GetArg("query")));
if (string.IsNullOrEmpty(str.Trim())) { if (string.IsNullOrEmpty(str.Trim())) {
await e.Send("Query failed"); await e.Channel.SendMessage("Query failed");
return; return;
} }
await e.Send(str); await e.Channel.SendMessage(str);
}); });
cgb.CreateCommand("~ani") cgb.CreateCommand("~ani")
@ -49,11 +49,11 @@ namespace NadekoBot.Modules {
var result = await SearchHelper.GetAnimeQueryResultLink(e.GetArg("query")); var result = await SearchHelper.GetAnimeQueryResultLink(e.GetArg("query"));
if (result == null) { if (result == null) {
await e.Send("Failed to find that anime."); await e.Channel.SendMessage("Failed to find that anime.");
return; return;
} }
await e.Send(result.ToString()); await e.Channel.SendMessage(result.ToString());
}); });
cgb.CreateCommand("~mang") cgb.CreateCommand("~mang")
@ -65,17 +65,17 @@ namespace NadekoBot.Modules {
var result = await SearchHelper.GetMangaQueryResultLink(e.GetArg("query")); var result = await SearchHelper.GetMangaQueryResultLink(e.GetArg("query"));
if (result == null) { if (result == null) {
await e.Send("Failed to find that anime."); await e.Channel.SendMessage("Failed to find that anime.");
return; return;
} }
await e.Send(result.ToString()); await e.Channel.SendMessage(result.ToString());
}); });
cgb.CreateCommand("~randomcat") cgb.CreateCommand("~randomcat")
.Description("Shows a random cat image.") .Description("Shows a random cat image.")
.Do(async e => { .Do(async e => {
try { try {
await e.Send(JObject.Parse(new StreamReader( await e.Channel.SendMessage(JObject.Parse(new StreamReader(
WebRequest.Create("http://www.random.cat/meow") WebRequest.Create("http://www.random.cat/meow")
.GetResponse() .GetResponse()
.GetResponseStream()) .GetResponseStream())
@ -93,10 +93,10 @@ namespace NadekoBot.Modules {
try { try {
var reqString = $"https://www.googleapis.com/customsearch/v1?q={Uri.EscapeDataString(e.GetArg("query"))}&cx=018084019232060951019%3Ahs5piey28-e&num=1&searchType=image&fields=items%2Flink&key={NadekoBot.creds.GoogleAPIKey}"; var reqString = $"https://www.googleapis.com/customsearch/v1?q={Uri.EscapeDataString(e.GetArg("query"))}&cx=018084019232060951019%3Ahs5piey28-e&num=1&searchType=image&fields=items%2Flink&key={NadekoBot.creds.GoogleAPIKey}";
var obj = JObject.Parse(await SearchHelper.GetResponseAsync(reqString)); var obj = JObject.Parse(await SearchHelper.GetResponseAsync(reqString));
await e.Send(obj["items"][0]["link"].ToString()); await e.Channel.SendMessage(obj["items"][0]["link"].ToString());
} }
catch (Exception ex) { catch (Exception ex) {
await e.Send($"💢 {ex.Message}"); await e.Channel.SendMessage($"💢 {ex.Message}");
} }
}); });
@ -109,10 +109,10 @@ namespace NadekoBot.Modules {
try { try {
var reqString = $"https://www.googleapis.com/customsearch/v1?q={Uri.EscapeDataString(e.GetArg("query"))}&cx=018084019232060951019%3Ahs5piey28-e&num=1&searchType=image&start={ _r.Next(1, 150) }&fields=items%2Flink&key={NadekoBot.creds.GoogleAPIKey}"; var reqString = $"https://www.googleapis.com/customsearch/v1?q={Uri.EscapeDataString(e.GetArg("query"))}&cx=018084019232060951019%3Ahs5piey28-e&num=1&searchType=image&start={ _r.Next(1, 150) }&fields=items%2Flink&key={NadekoBot.creds.GoogleAPIKey}";
var obj = JObject.Parse(await SearchHelper.GetResponseAsync(reqString)); var obj = JObject.Parse(await SearchHelper.GetResponseAsync(reqString));
await e.Send(obj["items"][0]["link"].ToString()); await e.Channel.SendMessage(obj["items"][0]["link"].ToString());
} }
catch (Exception ex) { catch (Exception ex) {
await e.Send($"💢 {ex.Message}"); await e.Channel.SendMessage($"💢 {ex.Message}");
} }
}); });
cgb.CreateCommand("lmgtfy") cgb.CreateCommand("lmgtfy")
@ -121,7 +121,7 @@ namespace NadekoBot.Modules {
.Parameter("ffs", ParameterType.Unparsed) .Parameter("ffs", ParameterType.Unparsed)
.Do(async e => { .Do(async e => {
if (e.GetArg("ffs") == null || e.GetArg("ffs").Length < 1) return; if (e.GetArg("ffs") == null || e.GetArg("ffs").Length < 1) return;
await e.Send(await $"http://lmgtfy.com/?q={ Uri.EscapeUriString(e.GetArg("ffs").ToString()) }".ShortenUrl()); await e.Channel.SendMessage(await $"http://lmgtfy.com/?q={ Uri.EscapeUriString(e.GetArg("ffs").ToString()) }".ShortenUrl());
}); });
cgb.CreateCommand("~hs") cgb.CreateCommand("~hs")
@ -130,7 +130,7 @@ namespace NadekoBot.Modules {
.Do(async e => { .Do(async e => {
var arg = e.GetArg("name"); var arg = e.GetArg("name");
if (string.IsNullOrWhiteSpace(arg)) { if (string.IsNullOrWhiteSpace(arg)) {
await e.Send("💢 Please enter a card name to search for."); await e.Channel.SendMessage("💢 Please enter a card name to search for.");
return; return;
} }
await e.Channel.SendIsTyping(); await e.Channel.SendIsTyping();
@ -153,14 +153,14 @@ namespace NadekoBot.Modules {
images.Add(System.Drawing.Bitmap.FromStream(await SearchHelper.GetResponseStream(item["img"].ToString()))); images.Add(System.Drawing.Bitmap.FromStream(await SearchHelper.GetResponseStream(item["img"].ToString())));
} }
if (items.Count > 4) { if (items.Count > 4) {
await e.Send("⚠ Found over 4 images. Showing random 4."); await e.Channel.SendMessage("⚠ Found over 4 images. Showing random 4.");
} }
Console.WriteLine("Start"); Console.WriteLine("Start");
await e.Channel.SendFile(arg + ".png", (await images.MergeAsync()).ToStream(System.Drawing.Imaging.ImageFormat.Png)); await e.Channel.SendFile(arg + ".png", (await images.MergeAsync()).ToStream(System.Drawing.Imaging.ImageFormat.Png));
Console.WriteLine("Finish"); Console.WriteLine("Finish");
} }
catch (Exception ex) { catch (Exception ex) {
await e.Send($"💢 Error {ex.Message}"); await e.Channel.SendMessage($"💢 Error {ex.Message}");
} }
}); });
@ -179,7 +179,7 @@ namespace NadekoBot.Modules {
cl.DownloadDataCompleted += async (s, cle) => { cl.DownloadDataCompleted += async (s, cle) => {
try { try {
await e.Channel.SendFile($"{e.GetArg("usr")}.png", new MemoryStream(cle.Result)); await e.Channel.SendFile($"{e.GetArg("usr")}.png", new MemoryStream(cle.Result));
await e.Send($"`Profile Link:`https://osu.ppy.sh/u/{Uri.EscapeDataString(e.GetArg("usr"))}\n`Image provided by https://lemmmy.pw/osusig`"); await e.Channel.SendMessage($"`Profile Link:`https://osu.ppy.sh/u/{Uri.EscapeDataString(e.GetArg("usr"))}\n`Image provided by https://lemmmy.pw/osusig`");
} }
catch { } catch { }
}; };
@ -196,7 +196,7 @@ namespace NadekoBot.Modules {
.Do(async e => { .Do(async e => {
var arg = e.GetArg("query"); var arg = e.GetArg("query");
if (string.IsNullOrWhiteSpace(arg)) { if (string.IsNullOrWhiteSpace(arg)) {
await e.Send("💢 Please enter a search term."); await e.Channel.SendMessage("💢 Please enter a search term.");
return; return;
} }
await e.Channel.SendIsTyping(); await e.Channel.SendIsTyping();
@ -209,7 +209,7 @@ namespace NadekoBot.Modules {
sb.AppendLine($"`Term:` {items["list"][0]["word"].ToString()}"); sb.AppendLine($"`Term:` {items["list"][0]["word"].ToString()}");
sb.AppendLine($"`Definition:` {items["list"][0]["definition"].ToString()}"); sb.AppendLine($"`Definition:` {items["list"][0]["definition"].ToString()}");
sb.Append($"`Link:` <{await items["list"][0]["permalink"].ToString().ShortenUrl()}>"); sb.Append($"`Link:` <{await items["list"][0]["permalink"].ToString().ShortenUrl()}>");
await e.Send(sb.ToString()); await e.Channel.SendMessage(sb.ToString());
} }
catch { catch {
await e.Channel.SendMessage("💢 Failed finding a definition for that term."); await e.Channel.SendMessage("💢 Failed finding a definition for that term.");
@ -222,7 +222,7 @@ namespace NadekoBot.Modules {
.Do(async e => { .Do(async e => {
var arg = e.GetArg("query"); var arg = e.GetArg("query");
if (string.IsNullOrWhiteSpace(arg)) { if (string.IsNullOrWhiteSpace(arg)) {
await e.Send("💢 Please enter a search term."); await e.Channel.SendMessage("💢 Please enter a search term.");
return; return;
} }
await e.Channel.SendIsTyping(); await e.Channel.SendIsTyping();
@ -235,7 +235,7 @@ namespace NadekoBot.Modules {
sb.AppendLine($"`Hashtag:` {items["defs"]["def"]["hashtag"].ToString()}"); sb.AppendLine($"`Hashtag:` {items["defs"]["def"]["hashtag"].ToString()}");
sb.AppendLine($"`Definition:` {items["defs"]["def"]["text"].ToString()}"); sb.AppendLine($"`Definition:` {items["defs"]["def"]["text"].ToString()}");
sb.Append($"`Link:` <{await items["defs"]["def"]["uri"].ToString().ShortenUrl()}>"); sb.Append($"`Link:` <{await items["defs"]["def"]["uri"].ToString().ShortenUrl()}>");
await e.Send(sb.ToString()); await e.Channel.SendMessage(sb.ToString());
} }
catch { catch {
await e.Channel.SendMessage("💢 Failed finidng a definition for that tag"); await e.Channel.SendMessage("💢 Failed finidng a definition for that tag");
@ -251,7 +251,7 @@ namespace NadekoBot.Modules {
var osuName = e.GetArg("osu_name"); var osuName = e.GetArg("osu_name");
var usr = e.Server.FindUsers(userName).FirstOrDefault(); var usr = e.Server.FindUsers(userName).FirstOrDefault();
if (usr == null) { if (usr == null) {
await e.Send("Cannot find that discord user."); await e.Channel.SendMessage("Cannot find that discord user.");
return; return;
} }
}); });

View File

@ -83,7 +83,7 @@ namespace NadekoBot.Modules {
bound = e.Channel; bound = e.Channel;
board = new Board(e.GetArg("board_id").Trim()); board = new Board(e.GetArg("board_id").Trim());
board.Refresh(); board.Refresh();
await e.Send("Successfully bound to this channel and board " + board.Name); await e.Channel.SendMessage("Successfully bound to this channel and board " + board.Name);
t.Start(); t.Start();
} catch (Exception ex) { } catch (Exception ex) {
Console.WriteLine("Failed to join the board. " + ex.ToString()); Console.WriteLine("Failed to join the board. " + ex.ToString());
@ -98,7 +98,7 @@ namespace NadekoBot.Modules {
t.Stop(); t.Stop();
bound = null; bound = null;
board = null; board = null;
await e.Send("Successfully unbound trello from this channel."); await e.Channel.SendMessage("Successfully unbound trello from this channel.");
}); });
@ -108,7 +108,7 @@ namespace NadekoBot.Modules {
.Do(async e => { .Do(async e => {
if (e.User.Id != NadekoBot.OwnerID) return; if (e.User.Id != NadekoBot.OwnerID) return;
if (bound == null || board == null || bound != e.Channel) return; if (bound == null || board == null || bound != e.Channel) return;
await e.Send("Lists for a board '" + board.Name + "'\n" + string.Join("\n", board.Lists.Select(l => "**• " + l.ToString() + "**"))); await e.Channel.SendMessage("Lists for a board '" + board.Name + "'\n" + string.Join("\n", board.Lists.Select(l => "**• " + l.ToString() + "**")));
}); });
cgb.CreateCommand("cards") cgb.CreateCommand("cards")
@ -128,9 +128,9 @@ namespace NadekoBot.Modules {
if (list != null) if (list != null)
await e.Send("There are " + list.Cards.Count() + " cards in a **" + list.Name + "** list\n" + string.Join("\n", list.Cards.Select(c => "**• " + c.ToString() + "**"))); await e.Channel.SendMessage("There are " + list.Cards.Count() + " cards in a **" + list.Name + "** list\n" + string.Join("\n", list.Cards.Select(c => "**• " + c.ToString() + "**")));
else else
await e.Send("No such list."); await e.Channel.SendMessage("No such list.");
}); });
}); });
} }

View File

@ -159,12 +159,12 @@ namespace NadekoBot {
if (!NadekoBot.creds.DontJoinServers) { if (!NadekoBot.creds.DontJoinServers) {
try { try {
await (await client.GetInvite(e.Message.Text)).Accept(); await (await client.GetInvite(e.Message.Text)).Accept();
await e.Send("I got in!"); await e.Channel.SendMessage("I got in!");
return; return;
} }
catch { catch {
if (e.User.Id == 109338686889476096) { //carbonitex invite if (e.User.Id == 109338686889476096) { //carbonitex invite
await e.Send("Failed to join the server."); await e.Channel.SendMessage("Failed to join the server.");
return; return;
} }
} }
@ -175,7 +175,7 @@ namespace NadekoBot {
if (!repliedRecently) { if (!repliedRecently) {
repliedRecently = true; repliedRecently = true;
await e.Send("**FULL LIST OF COMMANDS**:\n❤ <https://gist.github.com/Kwoth/1ab3a38424f208802b74> ❤\n\n⚠**COMMANDS DO NOT WORK IN PERSONAL MESSAGES**\n\n\n**Bot Creator's server:** <https://discord.gg/0ehQwTK2RBhxEi0X>"); await e.Channel.SendMessage("**FULL LIST OF COMMANDS**:\n❤ <https://gist.github.com/Kwoth/1ab3a38424f208802b74> ❤\n\n⚠**COMMANDS DO NOT WORK IN PERSONAL MESSAGES**\n\n\n**Bot Creator's server:** <https://discord.gg/0ehQwTK2RBhxEi0X>");
Timer t = new Timer(); Timer t = new Timer();
t.Interval = 2000; t.Interval = 2000;
t.Start(); t.Start();