implemented polls in the discord bot

This commit is contained in:
Sarah Faey 2023-01-14 16:44:18 +01:00
parent 1d999e89bf
commit 715b14ecc5
13 changed files with 277 additions and 6 deletions

View file

@ -64,6 +64,22 @@ namespace DiscordBot.CommandHandlers
await component.RespondAsync("Opting out failed, please try again later or change the setting on the website.");
}
break;
case Constants.ComponentIds.POLL_ANSWER_BUTTON:
PollMessage.Parameters pollAnswerParameters = PollMessage.ParseId(component.Data.CustomId);
ApiPollAnswer answer = new ApiPollAnswer()
{
Answer = string.Empty,
OptionId = pollAnswerParameters.OptionId,
PollId = pollAnswerParameters.PollId,
UserId = component.User.Id
};
await _httpService.AnswerPoll(answer);
await component.RespondAsync("Answer sent.", ephemeral: true);
break;
case Constants.ComponentIds.POLL_CUSTOM_ANSWER_BUTTON:
PollMessage.Parameters pollCustomParameters = PollMessage.ParseId(component.Data.CustomId);
await component.RespondWithModalAsync(PollCustomModal.buildMessage(pollCustomParameters.PollId, component.Message.Content));
break;
}
}