TypeError: Cannot read properties of undefined (reading 'isChatInputCommand')

idk what happened, it was working fine, then I added client parameter what it was:
module.exports = {
name: Events.InteractionCreate,
once: false,
async execute(interaction) {
if(!interaction.isChatInputCommand()) return;
........
module.exports = {
name: Events.InteractionCreate,
once: false,
async execute(interaction) {
if(!interaction.isChatInputCommand()) return;
........
what it's now:
module.exports = {
name: Events.InteractionCreate,
once: false,
async execute(client, interaction) {
if(!interaction.isChatInputCommand()) return;
....
module.exports = {
name: Events.InteractionCreate,
once: false,
async execute(client, interaction) {
if(!interaction.isChatInputCommand()) return;
....
3 Replies
d.js toolkit
d.js toolkit11mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
JerZ
JerZ11mo ago
ah okay, but if I want to add it as a parameter, how do I do that? I already have this code above the module.exports:
const Client = require("../Structures/Client")
/**
* @param {Client} client
*/
const Client = require("../Structures/Client")
/**
* @param {Client} client
*/
bcuz for some reason the code doesnt work, idk why. im kinda stupid it's not discordjs another npm package but uses discordjs code in index:
client.distube = new DisTube.DisTube(client, {
leaveOnEmpty: true,
leaveOnFinish: true,
emptyCooldown: 20,
emitNewSongOnly: false,
youtubeCookie: COOKIE
});
client.distube = new DisTube.DisTube(client, {
leaveOnEmpty: true,
leaveOnFinish: true,
emptyCooldown: 20,
emitNewSongOnly: false,
youtubeCookie: COOKIE
});
code in play.js:
const { SlashCommandBuilder } = require('discord.js');
const Discord = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('play')
.setDescription('Play a song!')
.addStringOption(option =>
option.setName("query")
.setDescription("what song are you thinking?")
.setRequired(true)),
async execute(interaction) {
const Vchat = interaction.member.voice.channel;
if(!Vchat) return interaction.reply("You need to be in a voice channel");

const queue = interaction.client.distube.getQueue(interaction);
if(queue) {
if(queue.songs.length === 30) return interaction.reply("You can only add up to 30 songs in the queue");
}


const string = interaction.options.getString("Query");

interaction.reply("Searching Song!");
interaction.client.distube.play(Vchat, string);
},
};
const { SlashCommandBuilder } = require('discord.js');
const Discord = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('play')
.setDescription('Play a song!')
.addStringOption(option =>
option.setName("query")
.setDescription("what song are you thinking?")
.setRequired(true)),
async execute(interaction) {
const Vchat = interaction.member.voice.channel;
if(!Vchat) return interaction.reply("You need to be in a voice channel");

const queue = interaction.client.distube.getQueue(interaction);
if(queue) {
if(queue.songs.length === 30) return interaction.reply("You can only add up to 30 songs in the queue");
}


const string = interaction.options.getString("Query");

interaction.reply("Searching Song!");
interaction.client.distube.play(Vchat, string);
},
};
the client in the constructor is Discord.Client type which tos? fine, ill figure it out myself ig it's private anyways
JerZ
JerZ11mo ago
their bot is literally verified and on 66k servers :V