geeks
geeks
DIAdiscord.js - Imagine an app
Created by geeks on 5/13/2024 in #djs-questions
Building Embed & 3 Buttons in v14 (use ActionRowBuilder and EmbedBuilder?)
It works!!!! Can’t believe I overlooked this. Thanks so much
7 replies
DIAdiscord.js - Imagine an app
Created by geeks on 5/13/2024 in #djs-questions
Building Embed & 3 Buttons in v14 (use ActionRowBuilder and EmbedBuilder?)
Yes not sure why that was hanging out there, have removed the ButtonCOmponent πŸ™‚ So unless I've missed something, is it only possible to push these embeds (with buttons) to a textchat channel? I keep seeing/hearing that there is indeed the capability to push/send to the VC's text/side chat - Is this at all possible? (Eg. bots like Statbot seem to be capable of doing so) Thx
7 replies
DIAdiscord.js - Imagine an app
Created by geeks on 5/13/2024 in #djs-questions
Building Embed & 3 Buttons in v14 (use ActionRowBuilder and EmbedBuilder?)
am I not doing that correctly with this? actionRow.addComponents(ButtonComponent[[ new ButtonBuilder() .setLabel('Join Queue') .setStyle(ButtonStyle.Success) .setCustomId('join-queue-button'), new ButtonBuilder() .setLabel('Leave Queue') .setStyle(ButtonStyle.Danger) .setCustomId('leave-queue-button'), new ButtonBuilder() .setLabel('Pass Time') .setStyle(ButtonStyle.Primary) .setCustomId('pass-time-button') ]]
7 replies
DIAdiscord.js - Imagine an app
Created by geeks on 5/9/2024 in #djs-questions
Conditional display of Button Components in Text Channel (based on user role?)
Fair enough. I'll just put in some handling for the redundant buttons. Thanks πŸ™‚
3 replies
DIAdiscord.js - Imagine an app
Created by geeks on 5/5/2024 in #djs-voice
Speaking 'start'/'end' events trigger continuously - Caused by while loop?
But thats genuinely not happening. It's continuous voice... There must be an option to delay the trigger, such that regular speech can be considered ongoing.
29 replies
DIAdiscord.js - Imagine an app
Created by geeks on 5/5/2024 in #djs-voice
Speaking 'start'/'end' events trigger continuously - Caused by while loop?
geeks started speaking at Wed May 08 2024 02:37:20 GMT+0100 (British Summer Time) geeks finished speaking at Wed May 08 2024 02:37:21 GMT+0100 (British Summer Time) geeks started speaking at Wed May 08 2024 02:37:23 GMT+0100 (British Summer Time) geeks finished speaking at Wed May 08 2024 02:37:23 GMT+0100 (British Summer Time) geeks started speaking at Wed May 08 2024 02:37:23 GMT+0100 (British Summer Time) geeks finished speaking at Wed May 08 2024 02:37:23 GMT+0100 (British Summer Time) geeks started speaking at Wed May 08 2024 02:37:23 GMT+0100 (British Summer Time)
29 replies
DIAdiscord.js - Imagine an app
Created by geeks on 5/5/2024 in #djs-voice
Speaking 'start'/'end' events trigger continuously - Caused by while loop?
So, I still get erroneous 'end' events triggering, even without any while loops. It's nothing to do with my microphone or setup, because it happens with all users. It must be something to do with the configuration of sensitivity or something else regarding listening to the speaking user.
29 replies
DIAdiscord.js - Imagine an app
Created by geeks on 5/5/2024 in #djs-voice
Speaking 'start'/'end' events trigger continuously - Caused by while loop?
The thing is that my while loop is actually checking for Timestamps, not the start/end events. The start/end events are updating the Timestamps which are then referred to I'll try without any while loops to see what happens
29 replies
DIAdiscord.js - Imagine an app
Created by geeks on 5/5/2024 in #djs-voice
Speaking 'start'/'end' events trigger continuously - Caused by while loop?
i think this is the state for the VoiceConnection object when it's initialising no? ie. when it's going through signalling, connecting, ready etc? Nothing to do with tracking the receiver.speaking events (start or end)
29 replies
DIAdiscord.js - Imagine an app
Created by geeks on 5/5/2024 in #djs-voice
Speaking 'start'/'end' events trigger continuously - Caused by while loop?
I'm still getting repeated start/end triggers.... geeks started speaking at Wed May 08 2024 02:37:20 GMT+0100 (British Summer Time) geeks finished speaking at Wed May 08 2024 02:37:21 GMT+0100 (British Summer Time) geeks started speaking at Wed May 08 2024 02:37:23 GMT+0100 (British Summer Time) geeks finished speaking at Wed May 08 2024 02:37:23 GMT+0100 (British Summer Time) geeks started speaking at Wed May 08 2024 02:37:23 GMT+0100 (British Summer Time) geeks finished speaking at Wed May 08 2024 02:37:23 GMT+0100 (British Summer Time) geeks started speaking at Wed May 08 2024 02:37:23 GMT+0100 (British Summer Time) But I still have the while/set timeout loop/block in my startTimer function... (the biggest while loop) You mentioned events exist that could better handle the requirements to consistently check for changes - how would I modify the below to do that? https://gist.github.com/lucromano/72456246a763b844776b7111b6919ef4
29 replies
DIAdiscord.js - Imagine an app
Created by geeks on 5/5/2024 in #djs-voice
Speaking 'start'/'end' events trigger continuously - Caused by while loop?
Thanks for the info, am looking at what happens when I remove the ifs in start and end regarding the setTimeout/while loop.... are you referring to this block? async function waitForConnectionStatus(botConnection) { while (botConnection._state.status !== 'ready') { // Adjust the property and condition as needed await new Promise(resolve => setTimeout(resolve, 1000)); // Adjust the delay as needed } }
29 replies
DIAdiscord.js - Imagine an app
Created by geeks on 5/5/2024 in #djs-voice
Speaking 'start'/'end' events trigger continuously - Caused by while loop?
29 replies
DIAdiscord.js - Imagine an app
Created by geeks on 5/5/2024 in #djs-voice
Speaking 'start'/'end' events trigger continuously - Caused by while loop?
My logs are showing that I'm constantly triggering the start/end events for speaking: 2024-05-05T22:09:27.857Z geeks started speaking at Sun May 05 2024 23:09:28 GMT+0100 (British Summer Time) geeks finished speaking at Sun May 05 2024 23:09:29 GMT+0100 (British Summer Time) geeks finished speaking at Sun May 05 2024 23:09:29 GMT+0100 (British Summer Time) geeks finished speaking at Sun May 05 2024 23:09:30 GMT+0100 (British Summer Time) geeks finished speaking at Sun May 05 2024 23:09:30 GMT+0100 (British Summer Time) (the started speaking I've handled, but still showing the end speaking triggers continuously) My question is - Is this due to the while loop I have? Is it likely 'cutting off' the voice stream, thus triggering an 'end' speaking state? Or could it be due to something else? Thx
29 replies
DIAdiscord.js - Imagine an app
Created by geeks on 5/5/2024 in #djs-voice
Speaking 'start'/'end' events trigger continuously - Caused by while loop?
and I also have an async function that is triggered as part of the core flow, which has a while loop async function startTimer() { .......... while (userActive) { elapsedTime = Date.now() - unmuteTimestamp; silenceTime = remainingTime = speakTime - elapsedTime if (!startedSpeakingTimestamp && elapsedTime >= startedSpeakingLimit) { console.log("${currentMember.displayName} did not start speaking."); await muteUser(currentMember); queue.push(queue.shift()); userActive = false; } else if (remainingTime < speakTimeAlert && !timeAlert) { timeAlert = true; const remainingSecs = Math.round(remainingTime/1000) const nextMember = queue[1] const msgText = "${currentMember.displayName} has ${String(remainingSecs)} seconds left. ${nextMember.displayName} is next up to speak." const channel = client.channels.cache.get(textChannelId); if (channel && channel.isTextBased) { await channel.send(msgText); } else { console.error('Text channel not found!'); } } else if (elapsedTime >= speakTime) { console.log("${currentMember.displayName} reached maximum speak time."); await muteUser(currentMember); queue.push(queue.shift()); userActive = false; timeAlert = false; } await new Promise(resolve => setTimeout(resolve, userSwitchInterval)); } continued below
29 replies
DIAdiscord.js - Imagine an app
Created by geeks on 5/4/2024 in #djs-questions
Using discord.py base with nodejs (discord.js & voice) as addons
DIdn't work for me for some reason 😦
18 replies
DIAdiscord.js - Imagine an app
Created by geeks on 5/1/2024 in #djs-questions
OAuth2 URL + Bot Permissions + Discord Intents
async function startTimer() { if (queueActive && queue.length > 0) { try { const currentMember = queue[0]; await unmuteUser(currentMember); userActive = true; unmuteTimestamp = Date.now(); const unmuteDate = new Date(unmuteTimestamp) console.log(unmuteDate) while (userActive) { elapsedTime = Date.now() - unmuteTimestamp; if (!startedSpeakingTimestamp && elapsedTime >= startedSpeakingLimit) { console.log(${currentMember.displayName} did not start speaking.); await muteUser(currentMember); queue.push(queue.shift()); userActive = false; } else if (elapsedTime >= speakTime) { console.log(${currentMember.displayName} reached maximum speak time.); await muteUser(currentMember); queue.push(queue.shift()); userActive = false; } await new Promise(resolve => setTimeout(resolve, userSwitchInterval)); } startedSpeakingTimestamp = null; stoppedSpeakingTimestamp = null; unmuteTimestamp = null; if (queueActive) { await startTimer(); } } catch (error) { console.error('Error in user timer:', error); } } }
8 replies
DIAdiscord.js - Imagine an app
Created by geeks on 5/1/2024 in #djs-questions
OAuth2 URL + Bot Permissions + Discord Intents
So if I have my speaking listeners loaded: botConnection.receiver.speaking.on('start', (userId) => { if (!startedSpeakingTimestamp) { client.users.fetch(userId) .then(user => { startedSpeakingTimestamp = Date.now(); const startedDate = new Date(startedSpeakingTimestamp) console.log(${user.displayName} started speaking at ${startedDate}); }) } }); botConnection.receiver.speaking.on('end', (userId) => { if (!stoppedSpeakingTimestamp || Date.now() > stoppedSpeakingTimestamp) { client.users.fetch(userId) .then(user => { stoppedSpeakingTimestamp = Date.now(); const stoppedDate = new Date(stoppedSpeakingTimestamp) console.log(${user.displayName} finished speaking at ${stoppedDate}); }); } }); But they are triggering repeatedly, start and end, multiple times a second (which obviously isn't representing the fact that a user has finished and starts speaking again). You mentioned the blocking while loop (see below for it in context) - is it likely to be 'cutting off' the speaking stream thus causing these multiple speaker triggers?
8 replies
DIAdiscord.js - Imagine an app
Created by geeks on 5/4/2024 in #djs-questions
Using discord.py base with nodejs (discord.js & voice) as addons
No description
18 replies
DIAdiscord.js - Imagine an app
Created by geeks on 5/4/2024 in #djs-questions
Using discord.py base with nodejs (discord.js & voice) as addons
No description
18 replies
DIAdiscord.js - Imagine an app
Created by geeks on 5/4/2024 in #djs-questions
Using discord.py base with nodejs (discord.js & voice) as addons
So I was able to get this to work by using IntentsBitField: const { Client, IntentsBitField } = require('../node_modules/discord.js') const { joinVoiceChannel } = require('../node_modules/@discordjs/voice') const clientIntents = new IntentsBitField(); clientIntents.add(1); clientIntents.add(128); clientIntents.add(256); const client = new Client({intents: clientIntents})
18 replies