emigrek
emigrek
DIAdiscord.js - Imagine an app
Created by emigrek on 4/14/2024 in #djs-questions
ChatInputCommandInteraction options problem
Hi, I got little type related problem with getting the ChatInputCommandInteraction options. The problem appeared when I updated discord.js to 14.14.1 from 14.11.0. Here's the code:
const getEvalMessagePayload = async (client: ExtendedClient, interaction: ChatInputCommandInteraction) => {
const code = interaction.options.getString(`code`);
const depth = interaction.options.getInteger(`depth`);

const embed = new EmbedBuilder();
try {
const result = await eval(code ?? '');
const output = await clean(result, depth ?? 0);

embed
.setTitle(i18n.__("evaluation.title"))
.setDescription(`**${i18n.__("evaluation.input")}**\n\`\`\`js\n${code}\n\`\`\`\n**${i18n.__("evaluation.output")}**\n\`\`\`js\n${output}\n\`\`\``)
.setColor('Blurple');
} catch (e) {
embed
.setTitle(i18n.__("evaluation.title"))
.setDescription(`**${i18n.__("evaluation.input")}**\n\`\`\`js\n${code}\n\`\`\`\n**${i18n.__("evaluation.output")}**\n\`\`\`js\n${e}\n\`\`\``)
.setColor('Red');
}

return {
embeds: [embed]
}
};
const getEvalMessagePayload = async (client: ExtendedClient, interaction: ChatInputCommandInteraction) => {
const code = interaction.options.getString(`code`);
const depth = interaction.options.getInteger(`depth`);

const embed = new EmbedBuilder();
try {
const result = await eval(code ?? '');
const output = await clean(result, depth ?? 0);

embed
.setTitle(i18n.__("evaluation.title"))
.setDescription(`**${i18n.__("evaluation.input")}**\n\`\`\`js\n${code}\n\`\`\`\n**${i18n.__("evaluation.output")}**\n\`\`\`js\n${output}\n\`\`\``)
.setColor('Blurple');
} catch (e) {
embed
.setTitle(i18n.__("evaluation.title"))
.setDescription(`**${i18n.__("evaluation.input")}**\n\`\`\`js\n${code}\n\`\`\`\n**${i18n.__("evaluation.output")}**\n\`\`\`js\n${e}\n\`\`\``)
.setColor('Red');
}

return {
embeds: [embed]
}
};
Here are the errors:
TS2339: Property getString does not exist on type
Omit<CommandInteractionOptionResolver<CacheType>, "getMessage" | "getFocused">
TS2339: Property getString does not exist on type
Omit<CommandInteractionOptionResolver<CacheType>, "getMessage" | "getFocused">
TS2339: Property getInteger does not exist on type
Omit<CommandInteractionOptionResolver<CacheType>, "getMessage" | "getFocused">
TS2339: Property getInteger does not exist on type
Omit<CommandInteractionOptionResolver<CacheType>, "getMessage" | "getFocused">
The code runs fine and does what it should but Typescript throws this errors that I want to get rid of.
12 replies