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 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! - Marked as resolved by OP
montur
monturOP11mo ago
treble/luna
treble/luna11mo ago
wdym no reliable output
montur
monturOP11mo 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/luna11mo ago
do yu have the GuildVoiceStates intent
montur
monturOP11mo 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/luna11mo ago
...no
montur
monturOP11mo ago
oh
d.js docs
d.js docs11mo ago
:dtypes: v10: GatewayIntentBits read more
montur
monturOP11mo 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/luna11mo ago
should yes might also wanna enable GuildMembers shouldnt need to force fetch then
montur
monturOP11mo ago
thx!
Want results from more Discord servers?
Add your server