SturmEnte
SturmEnte
DIAdiscord.js - Imagine an app
Created by SturmEnte on 10/17/2022 in #djs-questions
How can I get the voice states of members?
It still doesnt work
10 replies
DIAdiscord.js - Imagine an app
Created by SturmEnte on 10/17/2022 in #djs-questions
How can I get the voice states of members?
It's called GuildVoiceStates and yes
10 replies
DIAdiscord.js - Imagine an app
Created by SturmEnte on 10/17/2022 in #djs-questions
How can I get the voice states of members?
Code:
import { CommandInteraction } from "discord.js";
import { joinVoiceChannel } from "@discordjs/voice";

module.exports.init = () => {};

module.exports.execute = async (interaction: CommandInteraction) => {
const member = await interaction.guild?.members.fetch(interaction.user.id);

if (!interaction.guild) {
interaction.reply("The music commands only work in guilds");
return;
}

if (!member?.voice.channelId) {
interaction.reply("You need to be in a channel to use this command");
console.log(member?.voice);
return;
}

joinVoiceChannel({
guildId: String(interaction.guild.id),
channelId: String(member.voice.channelId),
adapterCreator: interaction.guild.voiceAdapterCreator,
});

interaction.reply("Joined voice channel");
};

module.exports.command = {
name: "join",
description: "Joins your current voice channel",
};
import { CommandInteraction } from "discord.js";
import { joinVoiceChannel } from "@discordjs/voice";

module.exports.init = () => {};

module.exports.execute = async (interaction: CommandInteraction) => {
const member = await interaction.guild?.members.fetch(interaction.user.id);

if (!interaction.guild) {
interaction.reply("The music commands only work in guilds");
return;
}

if (!member?.voice.channelId) {
interaction.reply("You need to be in a channel to use this command");
console.log(member?.voice);
return;
}

joinVoiceChannel({
guildId: String(interaction.guild.id),
channelId: String(member.voice.channelId),
adapterCreator: interaction.guild.voiceAdapterCreator,
});

interaction.reply("Joined voice channel");
};

module.exports.command = {
name: "join",
description: "Joins your current voice channel",
};
Output when I execute the command before rejoining a channel
VoiceState {
guild: <ref *1> Guild {...},
id: '420225163423121418',
serverDeaf: null,
serverMute: null,
selfDeaf: null,
selfMute: null,
selfVideo: null,
sessionId: null,
streaming: null,
channelId: null,
suppress: null,
requestToSpeakTimestamp: null
}
VoiceState {
guild: <ref *1> Guild {...},
id: '420225163423121418',
serverDeaf: null,
serverMute: null,
selfDeaf: null,
selfMute: null,
selfVideo: null,
sessionId: null,
streaming: null,
channelId: null,
suppress: null,
requestToSpeakTimestamp: null
}
10 replies
DIAdiscord.js - Imagine an app
Created by SturmEnte on 10/17/2022 in #djs-questions
How can I get the voice states of members?
npm list discord.js [email protected] node -v v17.4.0
10 replies