ted
ted
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by ted on 10/13/2024 in #djs-voice
After disconnecting once, audio starts audibly buffering
Here is part of my /play command:
const connection = joinVoiceChannel({
channelId: interaction.member.voice.channelId,
guildId: interaction.guildId,
adapterCreator: interaction.member.voice.channel.guild.voiceAdapterCreator,
});

const resource = createAudioResource("an mp3 live link", {
inlineVolume: true,
});

const player = createAudioPlayer();

connection.subscribe(player);
player.play(resource);

player.on("stateChange", async (oldState: any, newState: any) => {
log(`AudioPlayer: ${oldState.status} -> ${newState.status}`, "debug");

switch (newState.status) {
case AudioPlayerStatus.Idle:
log("The player has become idle.", "debug");
const resource = createAudioResource("an mp3 live link", {
inlineVolume: true,
});
player.play(resource);
break;
case AudioPlayerStatus.AutoPaused:
try {
await Promise.race([
entersState(player, AudioPlayerStatus.Idle, 2_000),
entersState(player, AudioPlayerStatus.Buffering, 2_000),
entersState(player, AudioPlayerStatus.Playing, 2_000),
]);
} catch {
connection.disconnect();
}
break;
}
});

connection.on("stateChange", async (oldState: any, newState: any) => {
log(`VoiceConnection: ${oldState.status} -> ${newState.status}`, "debug");

switch (newState.status) {
case VoiceConnectionStatus.Disconnected:
try {
await Promise.race([
entersState(connection, VoiceConnectionStatus.Signalling, 2_000),
entersState(connection, VoiceConnectionStatus.Connecting, 2_000),
]);
} catch (error) {
connection.destroy();
}
break;
case VoiceConnectionStatus.Destroyed:
player.stop();
break;
}
});
const connection = joinVoiceChannel({
channelId: interaction.member.voice.channelId,
guildId: interaction.guildId,
adapterCreator: interaction.member.voice.channel.guild.voiceAdapterCreator,
});

const resource = createAudioResource("an mp3 live link", {
inlineVolume: true,
});

const player = createAudioPlayer();

connection.subscribe(player);
player.play(resource);

player.on("stateChange", async (oldState: any, newState: any) => {
log(`AudioPlayer: ${oldState.status} -> ${newState.status}`, "debug");

switch (newState.status) {
case AudioPlayerStatus.Idle:
log("The player has become idle.", "debug");
const resource = createAudioResource("an mp3 live link", {
inlineVolume: true,
});
player.play(resource);
break;
case AudioPlayerStatus.AutoPaused:
try {
await Promise.race([
entersState(player, AudioPlayerStatus.Idle, 2_000),
entersState(player, AudioPlayerStatus.Buffering, 2_000),
entersState(player, AudioPlayerStatus.Playing, 2_000),
]);
} catch {
connection.disconnect();
}
break;
}
});

connection.on("stateChange", async (oldState: any, newState: any) => {
log(`VoiceConnection: ${oldState.status} -> ${newState.status}`, "debug");

switch (newState.status) {
case VoiceConnectionStatus.Disconnected:
try {
await Promise.race([
entersState(connection, VoiceConnectionStatus.Signalling, 2_000),
entersState(connection, VoiceConnectionStatus.Connecting, 2_000),
]);
} catch (error) {
connection.destroy();
}
break;
case VoiceConnectionStatus.Destroyed:
player.stop();
break;
}
});
Now, this works flawlessly. But, when I initiate a connection.disconnect() - in a seperate command - it does indeed leave the voice channel. But when I run /play again, while it does play, it is very buffery. I believe what is happening is the old player hasn't been destroyed, and my computer is trying to play 2 streams? Maybe not? - GuildVoiceStates intent is enabled - Here is my dependencies:
Core Dependencies
- @discordjs/voice: 0.17.0
- prism-media: 1.3.5
Opus Libraries
- @discordjs/opus: 0.9.0
- opusscript: 0.1.1
Encryption Libraries
- sodium-native: not found
- sodium: 3.0.2
- libsodium-wrappers: 0.7.15
- tweetnacl: 1.0.3
FFmpeg
- version: 6.0-essentials_build-www.gyan.dev
- libopus: yes
Core Dependencies
- @discordjs/voice: 0.17.0
- prism-media: 1.3.5
Opus Libraries
- @discordjs/opus: 0.9.0
- opusscript: 0.1.1
Encryption Libraries
- sodium-native: not found
- sodium: 3.0.2
- libsodium-wrappers: 0.7.15
- tweetnacl: 1.0.3
FFmpeg
- version: 6.0-essentials_build-www.gyan.dev
- libopus: yes
14 replies
CDCloudflare Developers
Created by ted on 7/29/2024 in #general-help
Being DDoSed
I've got a friend to DDoS me, but my site is still going donw. Security level is on high, all dns are proxied? Why is thhis?
8 replies
PPrisma
Created by ted on 7/26/2024 in #help-and-questions
prisma enum types as argument type?
i've got this function:
export async function log(arg1) {
// logic
}
export async function log(arg1) {
// logic
}
i also have the enum logType with Prisma. how can I set the type for arg1 by using the enum logType?
4 replies
CDCloudflare Developers
Created by ted on 7/23/2024 in #general-help
Cloudflare Zero Trust Access Help
I am using service tokens to authenticate an automation system with an application. But, it only lets me through the login portal when I'm on the root domain, or in one level deep paths. I need to get to a two level deep path for the API, but, even with the valid service token in headers, it won't allow me into the two level deep opath.
5 replies
CDCloudflare Developers
Created by ted on 10/11/2023 in #general-help
1.1.1.1 Connection issue
My macbook used to work fine connecting, but now it only connected 1/100 times and stays on establishing connection
1 replies
CDCloudflare Developers
Created by ted on 8/29/2023 in #general-help
Cloudflare Email Query
We use Google Workspace for company emails which has the MX records on the root domain. On our product we are introducing a new feature where we would like to be able to use the cloudflare email system, yet we also want these emails to be on the root domain. Any tips?
1 replies