Fixed raffle

This commit is contained in:
Kwoth 2016-08-21 03:35:28 +02:00
parent e7b6f110a3
commit 57a2caef84
4 changed files with 7 additions and 7 deletions

View File

@ -30,7 +30,7 @@ namespace NadekoBot.Modules.Administration
{ {
var channel = imsg.Channel as ITextChannel; var channel = imsg.Channel as ITextChannel;
if (channel == null || await imsg.IsAuthor(_client)) if (channel == null || await imsg.IsAuthor())
return; return;
ConcurrentDictionary<ulong, DateTime> userTimePair; ConcurrentDictionary<ulong, DateTime> userTimePair;
if (!RatelimitingChannels.TryGetValue(channel.Id, out userTimePair)) return; if (!RatelimitingChannels.TryGetValue(channel.Id, out userTimePair)) return;

View File

@ -196,7 +196,7 @@ namespace NadekoBot.Modules.Gambling
private async Task Client_MessageReceived(IMessage imsg) private async Task Client_MessageReceived(IMessage imsg)
{ {
if (await imsg.IsAuthor(NadekoBot.Client) || !(imsg.Channel is ITextChannel) || imsg.Channel != raceChannel) if (await imsg.IsAuthor() || !(imsg.Channel is ITextChannel) || imsg.Channel != raceChannel)
return; return;
messagesSinceGameStarted++; messagesSinceGameStarted++;
} }

View File

@ -27,7 +27,7 @@ namespace NadekoBot.Modules.Gambling
role = role ?? channel.Guild.EveryoneRole; role = role ?? channel.Guild.EveryoneRole;
var members = (await role.Members()).Where(u => u.Status == UserStatus.Online); var members = role.Members().Where(u => u.Status == UserStatus.Online);
var membersArray = members as IUser[] ?? members.ToArray(); var membersArray = members as IUser[] ?? members.ToArray();
var usr = membersArray[new Random().Next(0, membersArray.Length)]; var usr = membersArray[new Random().Next(0, membersArray.Length)];
await channel.SendMessageAsync($"**Raffled user:** {usr.Username} (id: {usr.Id})").ConfigureAwait(false); await channel.SendMessageAsync($"**Raffled user:** {usr.Username} (id: {usr.Id})").ConfigureAwait(false);

View File

@ -26,11 +26,11 @@ namespace NadekoBot.Extensions
public static async Task<IMessage> Reply(this IMessage msg, string content) => public static async Task<IMessage> Reply(this IMessage msg, string content) =>
await msg.Channel.SendMessageAsync(content).ConfigureAwait(false); await msg.Channel.SendMessageAsync(content).ConfigureAwait(false);
public static Task<bool> IsAuthor(this IMessage msg, DiscordSocketClient client) => public static Task<bool> IsAuthor(this IMessage msg) =>
Task.FromResult(client.GetCurrentUser().Id == msg.Author.Id); Task.FromResult(NadekoBot.Client.GetCurrentUser().Id == msg.Author.Id);
public static async Task<IEnumerable<IUser>> Members(this IRole role) => public static IEnumerable<IUser> Members(this IRole role) =>
await role.Members(); NadekoBot.Client.GetGuilds().Where(g => g.Id == role.GuildId).FirstOrDefault()?.GetUsers().Where(u => u.Roles.Contains(role)) ?? Enumerable.Empty<IUser>();
public static async Task<IMessage[]> ReplyLong(this IMessage msg, string content, string breakOn = "\n", string addToEnd = "", string addToStart = "") public static async Task<IMessage[]> ReplyLong(this IMessage msg, string content, string breakOn = "\n", string addToEnd = "", string addToStart = "")
{ {