Add info about min and max chars to interview message
This commit is contained in:
parent
be44de1eb3
commit
491293947d
2 changed files with 15 additions and 3 deletions
Interviews
|
@ -93,6 +93,9 @@ public class ReferencedInterviewStep
|
|||
// The entire interview tree is serialized and stored in the database to record responses as they are made.
|
||||
public class InterviewStep
|
||||
{
|
||||
public const int DEFAULT_MAX_FIELD_LENGTH = 1024;
|
||||
public const int DEFAULT_MIN_FIELD_LENGTH = 0;
|
||||
|
||||
// Title of the message embed.
|
||||
[JsonProperty("heading")]
|
||||
public string heading;
|
||||
|
|
|
@ -289,7 +289,7 @@ public static class Interviewer
|
|||
}
|
||||
|
||||
// The length requirement is less than 1024 characters, and must be less than the configurable limit if it is set.
|
||||
int maxLength = Math.Min(currentStep.maxLength ?? 1024, 1024);
|
||||
int maxLength = Math.Min(currentStep.maxLength ?? InterviewStep.DEFAULT_MAX_FIELD_LENGTH, InterviewStep.DEFAULT_MAX_FIELD_LENGTH);
|
||||
|
||||
if (answerMessage.Content.Length > maxLength)
|
||||
{
|
||||
|
@ -303,7 +303,7 @@ public static class Interviewer
|
|||
return;
|
||||
}
|
||||
|
||||
if (answerMessage.Content.Length < (currentStep.minLength ?? 0))
|
||||
if (answerMessage.Content.Length < (currentStep.minLength ?? InterviewStep.DEFAULT_MIN_FIELD_LENGTH))
|
||||
{
|
||||
DiscordMessage lengthMessage = await answerMessage.RespondAsync(new DiscordEmbedBuilder
|
||||
{
|
||||
|
@ -597,7 +597,16 @@ public static class Interviewer
|
|||
string.IsNullOrWhiteSpace(step.selectorPlaceholder) ? "Select a user or role..." : step.selectorPlaceholder));
|
||||
break;
|
||||
case StepType.TEXT_INPUT:
|
||||
embed.WithFooter("Reply to this message with your answer. You cannot include images or files.");
|
||||
string lengthInfo;
|
||||
if (step.minLength != null)
|
||||
{
|
||||
lengthInfo = " (" + step.minLength + "-" + (step.maxLength ?? InterviewStep.DEFAULT_MAX_FIELD_LENGTH) + " characters)";
|
||||
}
|
||||
else
|
||||
{
|
||||
lengthInfo = " (Maximum " + (step?.maxLength ?? InterviewStep.DEFAULT_MAX_FIELD_LENGTH) + " characters)";
|
||||
}
|
||||
embed.WithFooter("Reply to this message with your answer" + lengthInfo + ". You cannot include images or files.");
|
||||
break;
|
||||
case StepType.INTERVIEW_END:
|
||||
case StepType.ERROR:
|
||||
|
|
Loading…
Add table
Reference in a new issue