dostendite
dostendite
DIAdiscord.js - Imagine an app
Created by dostendite on 4/22/2024 in #djs-questions
TypeError // Text mirror command not working
Hello, so I'm trying to create a command that mirrors the text the user inputs, the only problem I have is I can't find a way to create an option for the user to input text in, and I get this error message when I run the command:
this.ephemeral = options.ephemeral ?? false;
^

TypeError: Cannot read properties of null (reading 'ephemeral')
this.ephemeral = options.ephemeral ?? false;
^

TypeError: Cannot read properties of null (reading 'ephemeral')
Relevant index.js code
client.on('interactionCreate', (interaction) => {
if (!interaction.isChatInputCommand()) return;

const interactionChannel = interaction.channel;

if (interaction.commandName === 'mirror') {
const mirrorMessage = interaction.options.get('mirror-message');
interaction.reply(mirrorMessage);
}
client.on('interactionCreate', (interaction) => {
if (!interaction.isChatInputCommand()) return;

const interactionChannel = interaction.channel;

if (interaction.commandName === 'mirror') {
const mirrorMessage = interaction.options.get('mirror-message');
interaction.reply(mirrorMessage);
}
Relevant register-commands.js code
{
name: 'mirror',
description: 'mirrors your text',
options: [
{
name: 'mirror-message',
description: 'テキスト',
type: ApplicationCommandOptionType.String,
required: true,
},
]
},
{
name: 'mirror',
description: 'mirrors your text',
options: [
{
name: 'mirror-message',
description: 'テキスト',
type: ApplicationCommandOptionType.String,
required: true,
},
]
},
I have tried to research in the Discord.JS documentation, but it's really cryptic and hard to understand (as I'm a beginner), thank you in advance.
19 replies