zeki
zeki
DIAdiscord.js - Imagine an app
Created by zeki on 12/19/2023 in #djs-questions
Play Audio Resource even when bot isn't in a voice channel
my bad solved!!
7 replies
DIAdiscord.js - Imagine an app
Created by zeki on 12/19/2023 in #djs-questions
Play Audio Resource even when bot isn't in a voice channel
oh I'm so dumb I need to pass in behaviors as a nested object to make the flag work
7 replies
DIAdiscord.js - Imagine an app
Created by zeki on 12/19/2023 in #djs-questions
Play Audio Resource even when bot isn't in a voice channel
omg that turned out so ugly sorry
7 replies
DIAdiscord.js - Imagine an app
Created by zeki on 12/19/2023 in #djs-questions
Play Audio Resource even when bot isn't in a voice channel
thanks so much for responding! Reading the docs I think you're right, noSubscriber should work. so I guess the issue is somewhere else, is there something wrong with the way I'm setting the flag?
const src = await axios.get(url, {
responseType: 'stream'
});
const resource = createAudioResource(src.data);
player = createAudioPlayer({ noSubscriber: 'play' });
player.play(resource);

const joinConfig = {
channelId: mainChannel.id,
guildId: mainGuild.id,
adapterCreator: mainGuild.voiceAdapterCreator,
selfDeaf: false
};

const connection = joinVoiceChannel(joinConfig);
connection.subscribe(player);

client.on('voiceStateUpdate', (oldState, newState) => {
if (oldState.member.user.bot) return;

if ( // disconnect
oldState.channelId === mainChannel.id &&
mainChannel.members.size < 2 &&
connection.state.status === 'ready'
) return connection.disconnect();

if ( // connect
newState.channelId === mainChannel.id
) {
connection.subscribe(player);
return connection.rejoin(joinConfig);
}

});
const src = await axios.get(url, {
responseType: 'stream'
});
const resource = createAudioResource(src.data);
player = createAudioPlayer({ noSubscriber: 'play' });
player.play(resource);

const joinConfig = {
channelId: mainChannel.id,
guildId: mainGuild.id,
adapterCreator: mainGuild.voiceAdapterCreator,
selfDeaf: false
};

const connection = joinVoiceChannel(joinConfig);
connection.subscribe(player);

client.on('voiceStateUpdate', (oldState, newState) => {
if (oldState.member.user.bot) return;

if ( // disconnect
oldState.channelId === mainChannel.id &&
mainChannel.members.size < 2 &&
connection.state.status === 'ready'
) return connection.disconnect();

if ( // connect
newState.channelId === mainChannel.id
) {
connection.subscribe(player);
return connection.rejoin(joinConfig);
}

});
7 replies