refactor, new api
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
||||
using System.Security.Cryptography;
|
||||
using Discord.Commands;
|
||||
using Discord;
|
||||
using Discord.Legacy;
|
||||
|
||||
namespace NadekoBot
|
||||
{
|
||||
@@ -33,7 +34,7 @@ namespace NadekoBot
|
||||
/// <param name="message">Message to be sent</param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Message> Send(this CommandEventArgs e, string message)
|
||||
=> await NadekoBot.client.SendMessage(e.Channel, message);
|
||||
=> await e.Channel.SendMessage(message);
|
||||
|
||||
/// <summary>
|
||||
/// Sends a message to the channel from which MessageEventArg came.
|
||||
@@ -43,7 +44,7 @@ namespace NadekoBot
|
||||
/// <returns></returns>
|
||||
public static async Task Send(this MessageEventArgs e, string message)
|
||||
{
|
||||
await NadekoBot.client.SendMessage(e.Channel, message);
|
||||
await e.Channel.SendMessage(message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -54,7 +55,7 @@ namespace NadekoBot
|
||||
/// <returns></returns>
|
||||
public static async Task Send(this Channel c, string message)
|
||||
{
|
||||
await NadekoBot.client.SendMessage(c, message);
|
||||
await c.SendMessage(message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -65,7 +66,7 @@ namespace NadekoBot
|
||||
/// <returns></returns>
|
||||
public static async Task Send(this User u, string message)
|
||||
{
|
||||
await NadekoBot.client.SendMessage(u, message);
|
||||
await u.SendMessage(message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -111,5 +112,11 @@ namespace NadekoBot
|
||||
list[n] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ForEach<T>(this IEnumerable<T> source, Action<T> action) {
|
||||
foreach (T element in source) {
|
||||
action(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
using Discord.Legacy;
|
||||
|
||||
namespace NadekoBot
|
||||
{
|
||||
@@ -196,7 +197,9 @@ namespace NadekoBot
|
||||
|
||||
if (currentQuestion == null || isQuit)
|
||||
{
|
||||
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
ch.Send("Trivia bot stopping. :\\\n" + GetLeaderboard());
|
||||
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
FinishGame();
|
||||
return;
|
||||
}
|
||||
@@ -242,7 +245,7 @@ namespace NadekoBot
|
||||
|
||||
foreach (var KeyValuePair in users)
|
||||
{
|
||||
str += "**" + client.GetUser(client.GetServer(_serverId), KeyValuePair.Key).Name + "** has " +KeyValuePair.Value + (KeyValuePair.Value == 1 ? "point." : "points.") + Environment.NewLine;
|
||||
str += "**" + client.GetServer(_serverId).GetUser(KeyValuePair.Key).Name + "** has " +KeyValuePair.Value + (KeyValuePair.Value == 1 ? "point." : "points.") + Environment.NewLine;
|
||||
}
|
||||
|
||||
return str;
|
||||
|
Reference in New Issue
Block a user