no reliable output and i dont know why:

const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('user')
.setDescription('Provides information about the user.'),
async execute(interaction) {
// Fetch fresh data to ensure accuracy
await interaction.member.fetch(true);
// Check if the user is in a voice channel
if (interaction.member.voice.channel) {
await interaction.reply(`You are currently in the voice channel: ${interaction.member.voice.channel.name}`);
} else {
await interaction.reply('You are not currently in a voice channel.');
}
},
};
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('user')
.setDescription('Provides information about the user.'),
async execute(interaction) {
// Fetch fresh data to ensure accuracy
await interaction.member.fetch(true);
// Check if the user is in a voice channel
if (interaction.member.voice.channel) {
await interaction.reply(`You are currently in the voice channel: ${interaction.member.voice.channel.name}`);
} else {
await interaction.reply('You are not currently in a voice channel.');
}
},
};
12 Replies
d.js toolkit
d.js toolkit10mo 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! - Marked as resolved by OP
montur
monturOP10mo ago
treble/luna
treble/luna10mo ago
wdym no reliable output
montur
monturOP10mo ago
this command only works the first time i use it and when i run it a 2nd time it gives the same output even when i changed vc or even when i left the vc
treble/luna
treble/luna10mo ago
do yu have the GuildVoiceStates intent
montur
monturOP10mo ago
const client = new Client({
intents: [
GatewayIntentBits.Guilds
] });
const client = new Client({
intents: [
GatewayIntentBits.Guilds
] });
i only have 1 intent but guilds is for everything right?
treble/luna
treble/luna10mo ago
...no
montur
monturOP10mo ago
oh
d.js docs
d.js docs10mo ago
:dtypes: v10: GatewayIntentBits read more
montur
monturOP10mo ago
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates
] });
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates
] });
that should fix it?
treble/luna
treble/luna10mo ago
should yes might also wanna enable GuildMembers shouldnt need to force fetch then
montur
monturOP10mo ago
thx!
Want results from more Discord servers?
Add your server