# ModalFields

`class` in `http` · v0.5.1

<https://docs.seedcord.org/packages/http/0.5.1/classes/modal-fields>

The fields a modal carries, read by custom id.

Every getter throws when no field in the modal has that custom id. It also throws when the field holds a kind that getter does not read. The message names the getter that does.

A select getter resolves the ids its field picked against the interaction's `resolved` data and returns a `Map` keyed by id. A field that picked nothing returns null. Pass `required` to throw there instead.

```ts
class ModalFields
```

## Constructors

### constructor

```ts
ModalFields(data: APIModalSubmission)
```

Constructs a new instance of the `ModalFields` class

## Methods

### getCheckbox

```ts
public getCheckbox(customId: string): boolean
```

### getCheckboxGroup

```ts
public getCheckboxGroup(customId: string): string[]
```

### getField

```ts
public getField<Kind>(
    customId: string,
    kind: Kind
): Extract<ModalSubmitComponent, { type: Kind }>
```

```ts
public getField(customId: string): ModalSubmitComponent
```

Returns the field with this custom id, as Discord sent it. Use it for a component type the typed getters do not cover.

Pass a component type to get that exact type back. It throws when the field holds a different one.

### getRadioGroup

```ts
public getRadioGroup(
    customId: string,
    required: true
): string
```

```ts
public getRadioGroup(
    customId: string,
    required?: boolean
): string | null
```

### getSelectedChannels

```ts
public getSelectedChannels(
    customId: string,
    required: true,
    channelTypes?: readonly ChannelType[]
): Map<string, APIInteractionDataResolvedChannel>
```

```ts
public getSelectedChannels(
    customId: string,
    required?: boolean,
    channelTypes?: readonly ChannelType[]
): Map<string, APIInteractionDataResolvedChannel> | null
```

Pass `channelTypes` to throw when a pick falls outside those types.

### getSelectedMembers

```ts
public getSelectedMembers(
    customId: string
): Map<string, APIInteractionDataResolvedGuildMember> | null
```

The guild members behind the picked users. Discord resolves these only inside a guild.

### getSelectedMentionables

```ts
public getSelectedMentionables(
    customId: string,
    required: true
): SelectedMentionables
```

```ts
public getSelectedMentionables(
    customId: string,
    required?: boolean
): SelectedMentionables | null
```

### getSelectedRoles

```ts
public getSelectedRoles(
    customId: string,
    required: true
): Map<string, APIRole>
```

```ts
public getSelectedRoles(
    customId: string,
    required?: boolean
): Map<string, APIRole> | null
```

### getSelectedUsers

```ts
public getSelectedUsers(
    customId: string,
    required: true
): Map<string, APIUser>
```

```ts
public getSelectedUsers(
    customId: string,
    required?: boolean
): Map<string, APIUser> | null
```

### getStringSelectValues

```ts
public getStringSelectValues(
    customId: string
): string[]
```

### getTextInputValue

```ts
public getTextInputValue(customId: string): string
```

### getUploadedFiles

```ts
public getUploadedFiles(
    customId: string,
    required: true
): Map<string, APIAttachment>
```

```ts
public getUploadedFiles(
    customId: string,
    required?: boolean
): Map<string, APIAttachment> | null
```
