Added selector placeholders to template

This commit is contained in:
Toastie 2024-12-26 22:24:42 +13:00
parent f03473ba14
commit 2553ad5c69
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4

View file

@ -46,7 +46,6 @@ public static class Interviewer
// The entire interview tree is serialized and stored in the database in order to record responses as they are made. // The entire interview tree is serialized and stored in the database in order to record responses as they are made.
public class InterviewQuestion public class InterviewQuestion
{ {
// TODO: Add selector placeholder
// Title of the message embed. // Title of the message embed.
[JsonProperty("title")] [JsonProperty("title")]
public string title; public string title;
@ -73,9 +72,15 @@ public static class Interviewer
[JsonProperty("button-style")] [JsonProperty("button-style")]
public ButtonType buttonStyle; public ButtonType buttonStyle;
// If this question is on a selector, give it this placeholder.
[JsonProperty("selector-placeholder")]
public string selectorPlaceholder;
// The maximum length of a text input.
[JsonProperty("max-length")] [JsonProperty("max-length")]
public int maxLength; public int maxLength;
// The minimum length of a text input.
[JsonProperty("min-length", Required = Required.Default)] [JsonProperty("min-length", Required = Required.Default)]
public int minLength; public int minLength;
@ -220,6 +225,9 @@ public static class Interviewer
[JsonProperty("button-style", Required = Required.Default)] [JsonProperty("button-style", Required = Required.Default)]
public ButtonType buttonStyle; public ButtonType buttonStyle;
[JsonProperty("selector-placeholder", Required = Required.Default)]
public string selectorPlaceholder;
[JsonProperty("max-length", Required = Required.Default)] [JsonProperty("max-length", Required = Required.Default)]
public int maxLength; public int maxLength;
@ -603,8 +611,8 @@ public static class Interviewer
private static async Task CreateQuestion(DiscordChannel channel, InterviewQuestion question) private static async Task CreateQuestion(DiscordChannel channel, InterviewQuestion question)
{ {
DiscordMessageBuilder msgBuilder = new DiscordMessageBuilder(); DiscordMessageBuilder msgBuilder = new();
DiscordEmbedBuilder embed = new DiscordEmbedBuilder() DiscordEmbedBuilder embed = new()
{ {
Color = Utilities.StringToColor(question.color), Color = Utilities.StringToColor(question.color),
Title = question.title, Title = question.title,
@ -637,22 +645,28 @@ public static class Interviewer
{ {
categoryOptions.Add(new DiscordSelectComponentOption(question.paths.ToArray()[selectionOptions].Key, selectionOptions.ToString())); categoryOptions.Add(new DiscordSelectComponentOption(question.paths.ToArray()[selectionOptions].Key, selectionOptions.ToString()));
} }
selectionComponents.Add(new DiscordSelectComponent("supportchild_interviewselector " + selectionBoxes, "Select an option...", categoryOptions));
selectionComponents.Add(new DiscordSelectComponent("supportchild_interviewselector " + selectionBoxes, string.IsNullOrWhiteSpace(question.selectorPlaceholder)
? "Select an option..." : question.selectorPlaceholder, categoryOptions));
} }
msgBuilder.AddComponents(selectionComponents); msgBuilder.AddComponents(selectionComponents);
break; break;
case QuestionType.ROLE_SELECTOR: case QuestionType.ROLE_SELECTOR:
msgBuilder.AddComponents(new DiscordRoleSelectComponent("supportchild_interviewroleselector", "Select a role...")); msgBuilder.AddComponents(new DiscordRoleSelectComponent("supportchild_interviewroleselector", string.IsNullOrWhiteSpace(question.selectorPlaceholder)
? "Select a role..." : question.selectorPlaceholder));
break; break;
case QuestionType.USER_SELECTOR: case QuestionType.USER_SELECTOR:
msgBuilder.AddComponents(new DiscordUserSelectComponent("supportchild_interviewuserselector", "Select a user...")); msgBuilder.AddComponents(new DiscordUserSelectComponent("supportchild_interviewuserselector", string.IsNullOrWhiteSpace(question.selectorPlaceholder)
? "Select a user..." : question.selectorPlaceholder));
break; break;
case QuestionType.CHANNEL_SELECTOR: case QuestionType.CHANNEL_SELECTOR:
msgBuilder.AddComponents(new DiscordChannelSelectComponent("supportchild_interviewchannelselector", "Select a channel...")); msgBuilder.AddComponents(new DiscordChannelSelectComponent("supportchild_interviewchannelselector", string.IsNullOrWhiteSpace(question.selectorPlaceholder)
? "Select a channel..." : question.selectorPlaceholder));
break; break;
case QuestionType.MENTIONABLE_SELECTOR: case QuestionType.MENTIONABLE_SELECTOR:
msgBuilder.AddComponents(new DiscordMentionableSelectComponent("supportchild_interviewmentionableselector", "Select a mentionable...")); msgBuilder.AddComponents(new DiscordMentionableSelectComponent("supportchild_interviewmentionableselector", string.IsNullOrWhiteSpace(question.selectorPlaceholder)
? "Select a user or role..." : question.selectorPlaceholder));
break; break;
case QuestionType.TEXT_INPUT: case QuestionType.TEXT_INPUT:
embed.WithFooter("Reply to this message with your answer. You cannot include images or files."); embed.WithFooter("Reply to this message with your answer. You cannot include images or files.");