From 3c1155c88372c6986fe4f8f1be5626d847683572 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Mon, 18 Dec 2017 22:07:45 -0500 Subject: [PATCH] polls work now --- Commands/Polls.cs | 2 -- Services/PollService.cs | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Commands/Polls.cs b/Commands/Polls.cs index bb223ac..d07af82 100644 --- a/Commands/Polls.cs +++ b/Commands/Polls.cs @@ -27,9 +27,7 @@ namespace dotbot.Commands { var pollId = Context.Channel.Id; if (_polls.ContainsKey(pollId)) - { await ReplyAsync($"respond with some more options or start the poll with `{_config["prefix"]}poll start`"); - } else { _polls[pollId] = new Poll diff --git a/Services/PollService.cs b/Services/PollService.cs index bf8f2e3..ef9fc60 100644 --- a/Services/PollService.cs +++ b/Services/PollService.cs @@ -9,20 +9,20 @@ namespace dotbot.Services { public class PollService { - private readonly ulong _selfId; + private DiscordSocketClient _discord; public Dictionary currentPolls; public PollService(DiscordSocketClient discord) { currentPolls = new Dictionary(); - discord.ReactionAdded += OnReactionAddedAsync; - _selfId = discord.CurrentUser.Id; + _discord = discord; + _discord.ReactionAdded += OnReactionAddedAsync; } private Task OnReactionAddedAsync(Cacheable CachedMessage, ISocketMessageChannel Channel, SocketReaction Reaction) { - if (currentPolls.ContainsKey(Channel.Id) && Reaction.UserId != _selfId) + if (currentPolls.ContainsKey(Channel.Id) && Reaction.UserId != _discord.CurrentUser.Id) currentPolls[Channel.Id].Options.First(o => o.MessageId == Reaction.MessageId).Votes++; return Task.CompletedTask; }