More refactor, more extension methods.

Preparing to ditch this project...

I just want to reimplement image searches and then i will probably stop
working on this project.
This commit is contained in:
Kwoth
2015-12-13 03:54:21 +01:00
parent 5fb1a7fa31
commit 537595694a
7 changed files with 58 additions and 18 deletions

View File

@ -351,7 +351,7 @@ namespace NadekoBot.Modules
f.Read(b, 0, b.Length);
f.Close();
string str = Encoding.ASCII.GetString(b);
await client.SendMessage(e.User, "```" + (str.Length < 1950 ? str : str.Substring(0, 1950)) + "```");
await e.User.Send("```" + (str.Length < 1950 ? str : str.Substring(0, 1950)) + "```");
});
CreateCommand(cgb, "cs")
@ -400,9 +400,9 @@ namespace NadekoBot.Modules
{
string str = StatsCollector.GetRequests();
if (str.Trim().Length > 110)
await client.SendMessage(e.User, str);
await e.User.Send(str);
else
await client.SendMessage(e.User, "No requests atm.");
await e.User.Send("No requests atm.");
});
CreateCommand(cgb, "dr")
@ -444,7 +444,7 @@ namespace NadekoBot.Modules
if (sc != null)
{
await e.Send(e.User.Mention + " Request resolved, notice sent.");
await client.SendMessage(client.GetUser(client.GetServer(sc.ServerId), sc.Id), "**This request of yours has been resolved:**\n" + sc.Text);
await client.GetUser(client.GetServer(sc.ServerId), sc.Id).Send("**This request of yours has been resolved:**\n" + sc.Text);
}
else
{
@ -637,6 +637,6 @@ namespace NadekoBot.Modules
}
private Func<CommandEventArgs, Task> SayYes()
=> async e => await NadekoBot.client.SendMessage(e.Channel, "Yes. :)");
=> async e => await e.Send("Yes. :)");
}
}

View File

@ -20,7 +20,7 @@ namespace NadekoBot.Modules
private static bool exit = true;
public static bool NextSong = false;
public static Discord.Audio.DiscordAudioClient Voice;
public static DiscordAudioClient Voice;
public static Channel VoiceChannel;
public static bool Pause = false;
public static List<YouTubeVideo> SongQueue = new List<YouTubeVideo>();

View File

@ -36,7 +36,7 @@ namespace NadekoBot.Modules
if (!(await ValidateQuery(e.Channel, e.GetArg("query")))) return;
var str = ShortenUrl(FindYoutubeUrlByKeywords(e.GetArg("query")));
if (str == null || str.Trim().Length < 5)
if (string.IsNullOrEmpty(str.Trim()))
{
await e.Send( "Query failed");
return;
@ -140,9 +140,9 @@ namespace NadekoBot.Modules
}
private static async Task<bool> ValidateQuery(Discord.Channel ch,string query) {
if (query == null || query.Trim().Length == 0)
if (string.IsNullOrEmpty(query.Trim()))
{
await NadekoBot.client.SendMessage(ch, "Please specify search parameters.");
await ch.Send("Please specify search parameters.");
return false;
}
return true;