Added support for multiple paths in mention selectors
Not sure how this could actually be useful but no reason to lock it down really.
This commit is contained in:
parent
14724c054e
commit
b2113695f8
1 changed files with 15 additions and 8 deletions
|
@ -469,15 +469,22 @@ public static class Interviewer
|
||||||
// The different mentionable selectors provide the actual answer, while the others just return the ID.
|
// The different mentionable selectors provide the actual answer, while the others just return the ID.
|
||||||
if (componentID == "")
|
if (componentID == "")
|
||||||
{
|
{
|
||||||
// TODO: Handle multipaths
|
foreach (KeyValuePair<string, InterviewQuestion> path in currentQuestion.paths)
|
||||||
if (currentQuestion.paths.Count != 1)
|
|
||||||
{
|
{
|
||||||
Logger.Error("The interview for channel " + interaction.Channel.Id + " has a question of type " + currentQuestion.type + " and it must have exactly one subpath.");
|
// Skip to the first matching path.
|
||||||
return;
|
if (Regex.IsMatch(answer, path.Key))
|
||||||
|
{
|
||||||
|
await HandleAnswer(answer, path.Value, interviewRoot, currentQuestion, interaction.Channel);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(string _, InterviewQuestion nextQuestion) = currentQuestion.paths.First();
|
Logger.Error("The interview for channel " + interaction.Channel.Id + " reached a question of type " + currentQuestion.type + " which has no valid next question. Their selection was:\n" + answer);
|
||||||
await HandleAnswer(answer, nextQuestion, interviewRoot, currentQuestion, interaction.Channel);
|
await interaction.CreateFollowupMessageAsync(new DiscordFollowupMessageBuilder().AddEmbed(new DiscordEmbedBuilder
|
||||||
|
{
|
||||||
|
Color = DiscordColor.Red,
|
||||||
|
Description = "Error: Could not determine the next question based on your answer. Check your response and ask an admin to check the bot logs if this seems incorrect."
|
||||||
|
}).AsEphemeral());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -564,10 +571,10 @@ public static class Interviewer
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Make message configurable.
|
Logger.Error("The interview for channel " + answerMessage.Channel.Id + " reached a question of type " + currentQuestion.type + " which has no valid next question. Their message was:\n" + answerMessage.Content);
|
||||||
DiscordMessage errorMessage = await answerMessage.RespondAsync(new DiscordEmbedBuilder
|
DiscordMessage errorMessage = await answerMessage.RespondAsync(new DiscordEmbedBuilder
|
||||||
{
|
{
|
||||||
Description = "Error: Could not determine the next question based on your answer.",
|
Description = "Error: Could not determine the next question based on your answer. Check your response and ask an admin to check the bot logs if this seems incorrect.",
|
||||||
Color = DiscordColor.Red
|
Color = DiscordColor.Red
|
||||||
});
|
});
|
||||||
currentQuestion.AddRelatedMessageIDs(errorMessage.Id);
|
currentQuestion.AddRelatedMessageIDs(errorMessage.Id);
|
||||||
|
|
Loading…
Reference in a new issue