HaruAjsuru
HaruAjsuru
Explore posts from servers
DFDimensional Fun
Created by HaruAjsuru on 1/13/2024 in #lavaclient
play localfile using lavaclient
I want to ask that is it possible to play localfile using lavaclient (since my bot already integrated lavaclient and adding native discord voice js will make more unnecessary complicates) I already done some research and I think that lavaplayer already supported playing localfile but I am not sure how to use that function though lavaclient Also I want to ask if it possible to play music through buffer
1 replies
DIAdiscord.js - Imagine an app
Created by HaruAjsuru on 11/6/2023 in #djs-questions
Fetch user from different shard (without being in the same guild)
I'm working on a notification function to send DM user . But I read some information online that using .broadcastEval() may result in multiple messages will be send if that user is currently in cache of multiple shards. So in my current implementation, I'm using cron job running on shard manager to check when to send user a DM and picking random shard to send it like this: Code in shard manager
// Pick random shard to dm user to prevent dulicate message
const totalShard = manager.totalShards;
const rngShard = getRandomInt(totalShard);
manager.broadcast({ name: 'dmUser', id: id, msg: msg, shard: rngShard });
// Pick random shard to dm user to prevent dulicate message
const totalShard = manager.totalShards;
const rngShard = getRandomInt(totalShard);
manager.broadcast({ name: 'dmUser', id: id, msg: msg, shard: rngShard });
Code in client
process.on('message', async function(m) {
//...
if (m.name === 'dmUser') {
// Check if this shard is the one assigned to dm user
if (client.shard.ids[0] === Number(m.shard)) {
const user = await client.users.fetch(m.id);
if (!m.msg || m.msg === '') {
return;
}
await user.send(m.msg);
}
}
}
process.on('message', async function(m) {
//...
if (m.name === 'dmUser') {
// Check if this shard is the one assigned to dm user
if (client.shard.ids[0] === Number(m.shard)) {
const user = await client.users.fetch(m.id);
if (!m.msg || m.msg === '') {
return;
}
await user.send(m.msg);
}
}
}
but my bot is still in development and don't have enough user to spawn multiple shards yet, so I have no way to test if my shard can fetch and DM that user without being in the same guild as them
8 replies