Mjicio_
Mjicio_
DIAdiscord.js - Imagine an app
Created by Mjicio_ on 9/11/2023 in #djs-voice
My bot doesn't play any sound, he has permission to speak and the intents
My bot doesn't play any sound, he has permission to speak and the intents
const { joinVoiceChannel, createAudioResource, createAudioPlayer } = require('@discordjs/voice');

const voice = require("@discordjs/voice");

client.on('voiceStateUpdate', async (oldState, newState) => {
// use the .channelID property (.voice doesn't exist)
//const newUserChannel = newState.channelID;
//const textChannel = client.channels.cache.get('1135536647627354153');

if(client.users.cache.get(oldState.id).bot) return;

if(newState.channelId === '1129499028317544549') {

let username = client.users.cache.get(oldState.id).username;

//join

joinVoiceChannel({
channelId: '1129499028317544549',
guildId: newState.guild.id,
adapterCreator: newState.guild.voiceAdapterCreator
})

client.channels.cache.get("1135536647627354153").send('Working')

//Play

const resource = voice.createAudioResource(__dirname, 'res/audio.mp3')
const player = createAudioPlayer();
player.play(resource);

}
});
const { joinVoiceChannel, createAudioResource, createAudioPlayer } = require('@discordjs/voice');

const voice = require("@discordjs/voice");

client.on('voiceStateUpdate', async (oldState, newState) => {
// use the .channelID property (.voice doesn't exist)
//const newUserChannel = newState.channelID;
//const textChannel = client.channels.cache.get('1135536647627354153');

if(client.users.cache.get(oldState.id).bot) return;

if(newState.channelId === '1129499028317544549') {

let username = client.users.cache.get(oldState.id).username;

//join

joinVoiceChannel({
channelId: '1129499028317544549',
guildId: newState.guild.id,
adapterCreator: newState.guild.voiceAdapterCreator
})

client.channels.cache.get("1135536647627354153").send('Working')

//Play

const resource = voice.createAudioResource(__dirname, 'res/audio.mp3')
const player = createAudioPlayer();
player.play(resource);

}
});
12 replies