mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-05 06:26: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];
|
value = args[i.name];
|
||||||
const option = i as SeyfertStringOption;
|
const option = i as SeyfertStringOption;
|
||||||
if (value) {
|
if (!value) break;
|
||||||
if (option.min_length) {
|
if (option.min_length) {
|
||||||
if (value.length < option.min_length) {
|
if (value.length < option.min_length) {
|
||||||
value = undefined;
|
value = undefined;
|
||||||
@ -344,7 +344,8 @@ async function parseOptions(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (option.choices?.length) {
|
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;
|
value = undefined;
|
||||||
errors.push({
|
errors.push({
|
||||||
name: i.name,
|
name: i.name,
|
||||||
@ -354,14 +355,15 @@ async function parseOptions(
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
value = option.choices.find(x => x.name === value)!.value;
|
value = choice.value;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ApplicationCommandOptionType.Number:
|
case ApplicationCommandOptionType.Number:
|
||||||
case ApplicationCommandOptionType.Integer:
|
case ApplicationCommandOptionType.Integer:
|
||||||
{
|
{
|
||||||
|
const option = i as SeyfertNumberOption | SeyfertIntegerOption;
|
||||||
|
if (!option.choices?.length) {
|
||||||
value = Number(args[i.name]);
|
value = Number(args[i.name]);
|
||||||
if (args[i.name] === undefined) {
|
if (args[i.name] === undefined) {
|
||||||
value = undefined;
|
value = undefined;
|
||||||
@ -375,7 +377,6 @@ async function parseOptions(
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const option = i as SeyfertNumberOption | SeyfertIntegerOption;
|
|
||||||
if (option.min_value) {
|
if (option.min_value) {
|
||||||
if (value < option.min_value) {
|
if (value < option.min_value) {
|
||||||
value = undefined;
|
value = undefined;
|
||||||
@ -396,8 +397,10 @@ async function parseOptions(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (option.choices?.length) {
|
break;
|
||||||
if (!option.choices.some(x => x.name === value)) {
|
}
|
||||||
|
const choice = option.choices.find(x => x.name === args[i.name]);
|
||||||
|
if (!choice) {
|
||||||
value = undefined;
|
value = undefined;
|
||||||
errors.push({
|
errors.push({
|
||||||
name: i.name,
|
name: i.name,
|
||||||
@ -407,8 +410,7 @@ async function parseOptions(
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
value = option.choices.find(x => x.name === value)!.value;
|
value = choice.value;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user