pollwork...
This commit is contained in:
parent
ab0f9ab821
commit
b7e7d89d24
|
@ -9,6 +9,7 @@ namespace dotbot.Services
|
||||||
{
|
{
|
||||||
public class PollService
|
public class PollService
|
||||||
{
|
{
|
||||||
|
private readonly ulong _selfId;
|
||||||
public Dictionary<ulong, Poll> currentPolls;
|
public Dictionary<ulong, Poll> currentPolls;
|
||||||
|
|
||||||
public PollService(DiscordSocketClient discord)
|
public PollService(DiscordSocketClient discord)
|
||||||
|
@ -16,15 +17,13 @@ namespace dotbot.Services
|
||||||
currentPolls = new Dictionary<ulong, Poll>();
|
currentPolls = new Dictionary<ulong, Poll>();
|
||||||
|
|
||||||
discord.ReactionAdded += OnReactionAddedAsync;
|
discord.ReactionAdded += OnReactionAddedAsync;
|
||||||
|
_selfId = discord.CurrentUser.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task OnReactionAddedAsync(Cacheable<IUserMessage, ulong> CachedMessage, ISocketMessageChannel Channel, SocketReaction Reaction)
|
private Task OnReactionAddedAsync(Cacheable<IUserMessage, ulong> CachedMessage, ISocketMessageChannel Channel, SocketReaction Reaction)
|
||||||
{
|
{
|
||||||
if (currentPolls.ContainsKey(Channel.Id))
|
if (currentPolls.ContainsKey(Channel.Id) && Reaction.UserId != _selfId)
|
||||||
{
|
currentPolls[Channel.Id].Options.First(o => o.MessageId == Reaction.MessageId).Votes++;
|
||||||
currentPolls[Channel.Id].Options.First(o => o.MessageId == CachedMessage.Id).Votes++;
|
|
||||||
}
|
|
||||||
// Console.WriteLine($"{Reaction.Emote} reaction added to {CachedMessage.Id} in {Channel.Name}");
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue