mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-04 22:16:08 +00:00
fix: message command choices
This commit is contained in:
parent
c6bd0f77e2
commit
6a63178846
@ -322,7 +322,7 @@ async function parseOptions(
|
||||
{
|
||||
value = args[i.name];
|
||||
const option = i as SeyfertStringOption;
|
||||
if (value) {
|
||||
if (!value) break;
|
||||
if (option.min_length) {
|
||||
if (value.length < option.min_length) {
|
||||
value = undefined;
|
||||
@ -344,7 +344,8 @@ async function parseOptions(
|
||||
}
|
||||
}
|
||||
if (option.choices?.length) {
|
||||
if (!option.choices.some(x => x.name === value)) {
|
||||
const choice = option.choices.find(x => x.name === value);
|
||||
if (!choice) {
|
||||
value = undefined;
|
||||
errors.push({
|
||||
name: i.name,
|
||||
@ -354,14 +355,15 @@ async function parseOptions(
|
||||
});
|
||||
break;
|
||||
}
|
||||
value = option.choices.find(x => x.name === value)!.value;
|
||||
}
|
||||
value = choice.value;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ApplicationCommandOptionType.Number:
|
||||
case ApplicationCommandOptionType.Integer:
|
||||
{
|
||||
const option = i as SeyfertNumberOption | SeyfertIntegerOption;
|
||||
if (!option.choices?.length) {
|
||||
value = Number(args[i.name]);
|
||||
if (args[i.name] === undefined) {
|
||||
value = undefined;
|
||||
@ -375,7 +377,6 @@ async function parseOptions(
|
||||
});
|
||||
break;
|
||||
}
|
||||
const option = i as SeyfertNumberOption | SeyfertIntegerOption;
|
||||
if (option.min_value) {
|
||||
if (value < option.min_value) {
|
||||
value = undefined;
|
||||
@ -396,8 +397,10 @@ async function parseOptions(
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (option.choices?.length) {
|
||||
if (!option.choices.some(x => x.name === value)) {
|
||||
break;
|
||||
}
|
||||
const choice = option.choices.find(x => x.name === args[i.name]);
|
||||
if (!choice) {
|
||||
value = undefined;
|
||||
errors.push({
|
||||
name: i.name,
|
||||
@ -407,8 +410,7 @@ async function parseOptions(
|
||||
});
|
||||
break;
|
||||
}
|
||||
value = option.choices.find(x => x.name === value)!.value;
|
||||
}
|
||||
value = choice.value;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
Loading…
x
Reference in New Issue
Block a user