polls work now
This commit is contained in:
parent
b7e7d89d24
commit
3c1155c883
|
@ -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
|
||||
|
|
|
@ -9,20 +9,20 @@ namespace dotbot.Services
|
|||
{
|
||||
public class PollService
|
||||
{
|
||||
private readonly ulong _selfId;
|
||||
private DiscordSocketClient _discord;
|
||||
public Dictionary<ulong, Poll> currentPolls;
|
||||
|
||||
public PollService(DiscordSocketClient discord)
|
||||
{
|
||||
currentPolls = new Dictionary<ulong, Poll>();
|
||||
|
||||
discord.ReactionAdded += OnReactionAddedAsync;
|
||||
_selfId = discord.CurrentUser.Id;
|
||||
_discord = discord;
|
||||
_discord.ReactionAdded += OnReactionAddedAsync;
|
||||
}
|
||||
|
||||
private Task OnReactionAddedAsync(Cacheable<IUserMessage, ulong> 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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue