polls work now
This commit is contained in:
parent
b7e7d89d24
commit
3c1155c883
|
@ -27,9 +27,7 @@ namespace dotbot.Commands
|
||||||
{
|
{
|
||||||
var pollId = Context.Channel.Id;
|
var pollId = Context.Channel.Id;
|
||||||
if (_polls.ContainsKey(pollId))
|
if (_polls.ContainsKey(pollId))
|
||||||
{
|
|
||||||
await ReplyAsync($"respond with some more options or start the poll with `{_config["prefix"]}poll start`");
|
await ReplyAsync($"respond with some more options or start the poll with `{_config["prefix"]}poll start`");
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_polls[pollId] = new Poll
|
_polls[pollId] = new Poll
|
||||||
|
|
|
@ -9,20 +9,20 @@ namespace dotbot.Services
|
||||||
{
|
{
|
||||||
public class PollService
|
public class PollService
|
||||||
{
|
{
|
||||||
private readonly ulong _selfId;
|
private DiscordSocketClient _discord;
|
||||||
public Dictionary<ulong, Poll> currentPolls;
|
public Dictionary<ulong, Poll> currentPolls;
|
||||||
|
|
||||||
public PollService(DiscordSocketClient discord)
|
public PollService(DiscordSocketClient discord)
|
||||||
{
|
{
|
||||||
currentPolls = new Dictionary<ulong, Poll>();
|
currentPolls = new Dictionary<ulong, Poll>();
|
||||||
|
|
||||||
discord.ReactionAdded += OnReactionAddedAsync;
|
_discord = discord;
|
||||||
_selfId = discord.CurrentUser.Id;
|
_discord.ReactionAdded += OnReactionAddedAsync;
|
||||||
}
|
}
|
||||||
|
|
||||||
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) && Reaction.UserId != _selfId)
|
if (currentPolls.ContainsKey(Channel.Id) && Reaction.UserId != _discord.CurrentUser.Id)
|
||||||
currentPolls[Channel.Id].Options.First(o => o.MessageId == Reaction.MessageId).Votes++;
|
currentPolls[Channel.Id].Options.First(o => o.MessageId == Reaction.MessageId).Votes++;
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue