#Issue With Modal Form.

1 messages · Page 1 of 1 (latest)

young abyss
#

so i am not so sure but, it's more of a question. is it a bug or intended behavior?
Here is a form:

const form = new ModalFormData()
      .title("Ban Info")
      .label("§eFill one of the following fields§c*")
      .divider()
      .textField("Reason§c*", "Required")
      .divider()
      .label("Ban Duration§c*")
      .toggle("Permanent ban", { defaultValue: false })
      .textField("Duration (e.g. 1w 2d 3h 4m)", "Optional")
      .submitButton("Confirm Ban");

so i show it using a force show. here:

const res = await player.show(form);
if (res.canceled) return;

const filteredRes = filterRes(res);```

and now in that function:
```ts
function filterRes(res: ModalFormResponse): FilteredRes | null {
  if (!res.formValues) return null;

  let msg = '';
  for (let i = 0; i < res.formValues.length; i++) {
    msg += `\n${i}:${res.formValues[i]}`;
  }
  console.log(msg);

  const reason = String(res.formValues[0]).trim();
  const isPermanent = Boolean(res.formValues[2]);
  const durationStr = String(res.formValues[3] || "").trim();

  if (!reason) return null;
  let expiresAt: number | false = false;

  if (!isPermanent) {
    const ms = parseDuration(durationStr);
    if (ms <= 0) return null;
    expiresAt = Date.now() + ms;
  }

  return { isPermanent, expiresAt, reason };
}```

now:

[Scripting][inform]-
0:undefined
1:undefined
2:bug
3:undefined
4:undefined
5:true
6:44d```
i am absolutely baffled.

errant orbit
errant orbit
#

so you have to account for that too

young abyss
#

ok

#

thanks

cobalt widget
#

And div

errant orbit
#

i see

#

wait

#

that makes it WORSE

#

😭

young abyss
#

why'd moyang even do this tho

#

like what value am i gonna read off the label??

cobalt widget
errant orbit
#

ah alright, that makes it more sane

#

at least

cobalt widget
#

But still stupid ngl

young abyss
#

well, thank you both gentlemen.

#

have a great afternoon!