tycoonlover1359
tycoonlover1359
DIAdiscord.js - Imagine an app
Created by tycoonlover1359 on 7/30/2023 in #djs-questions
`MissingPropertyError` when making a select menu
I'm having a problem with making a StringSelectMenu; discord.js seems to insist that the menu I'm making is missing the label and value properties required of select menu options, but based on the builder, both of these should be there. My Code:
// DenyReasonMenuSelect.ts
import { StringSelectMenuBuilder } from "@discordjs/builders";
import { ISelectMenu } from "../interfaces/ISelectMenu.js";
import { AnySelectMenuInteraction, StringSelectMenuOptionBuilder } from "discord.js";


export class DenyReasonMenuSelect implements ISelectMenu {
public name = "deny_reason";

public menu: StringSelectMenuBuilder;

constructor(menuData?: string, valueData?: string) {
const menuId = "deny_reason" + (menuData ? `/${menuData}` : "");
const optionData = valueData ? `/${valueData}` : "";

this.menu = new StringSelectMenuBuilder()
.setCustomId(menuId)
.setPlaceholder("Reason for Denial")
.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel("Locked")
.setDescription("The book cannot be accessed pubicily.")
.setValue("locked" + optionData),
);
}

public async execute(interaction: AnySelectMenuInteraction): Promise<void> {
interaction.reply("hello from deny reason menu select!");
}
}
// DenyReasonMenuSelect.ts
import { StringSelectMenuBuilder } from "@discordjs/builders";
import { ISelectMenu } from "../interfaces/ISelectMenu.js";
import { AnySelectMenuInteraction, StringSelectMenuOptionBuilder } from "discord.js";


export class DenyReasonMenuSelect implements ISelectMenu {
public name = "deny_reason";

public menu: StringSelectMenuBuilder;

constructor(menuData?: string, valueData?: string) {
const menuId = "deny_reason" + (menuData ? `/${menuData}` : "");
const optionData = valueData ? `/${valueData}` : "";

this.menu = new StringSelectMenuBuilder()
.setCustomId(menuId)
.setPlaceholder("Reason for Denial")
.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel("Locked")
.setDescription("The book cannot be accessed pubicily.")
.setValue("locked" + optionData),
);
}

public async execute(interaction: AnySelectMenuInteraction): Promise<void> {
interaction.reply("hello from deny reason menu select!");
}
}
The error it gives: (see attached file)
6 replies