forked from Sarah/Lieb-Website
implemented polls in the discord bot
This commit is contained in:
parent
1d999e89bf
commit
715b14ecc5
13 changed files with 277 additions and 6 deletions
38
DiscordBot/Messages/PollCustomModal.cs
Normal file
38
DiscordBot/Messages/PollCustomModal.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using SharedClasses.SharedModels;
|
||||
|
||||
namespace DiscordBot.Messages
|
||||
{
|
||||
public class PollCustomModal
|
||||
{
|
||||
public static Modal buildMessage(int pollId, string question)
|
||||
{
|
||||
var mb = new ModalBuilder()
|
||||
.WithTitle(question)
|
||||
.WithCustomId($"{Constants.ComponentIds.POLL_CUSTOM_ANSWER_MODAL}-{pollId}")
|
||||
.AddTextInput("Answer", Constants.ComponentIds.POLL_CUSTOM_ANSWER_TEXT_BOX, placeholder: "Yes", required: true);
|
||||
|
||||
return mb.Build();
|
||||
}
|
||||
|
||||
public static Parameters ParseId(string customId)
|
||||
{
|
||||
Parameters parameters = new Parameters();
|
||||
|
||||
string[] ids = customId.Split('-');
|
||||
if(ids.Length > 1)
|
||||
{
|
||||
int.TryParse(ids[1],out parameters.PollId);
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public class Parameters
|
||||
{
|
||||
public int PollId;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue