Abel P.
Abel P.
DIAdiscord.js - Imagine an app
Created by Abel P. on 11/1/2024 in #djs-questions
Not getting hello @discordjs/ws
identify payload: https://hastebin.abelpurnwasy.com/hejobegana.js dispatch event: https://hastebin.abelpurnwasy.com/yaxivupali.coffeescript manager:
const rest = new REST().setToken(token);

const manager = new WebSocketManager({
token,
intents,
rest,
...DefaultWebSocketManagerOptions,
});
const rest = new REST().setToken(token);

const manager = new WebSocketManager({
token,
intents,
rest,
...DefaultWebSocketManagerOptions,
});
28 replies
DIAdiscord.js - Imagine an app
Created by Abel P. on 6/27/2023 in #djs-voice
Constant in and out of VC
Issue in video
client.isMp3.set(interaction.guildId, true);

const media = interaction.options.getAttachment("mp3_file");
const audioPlayer = createAudioPlayer();
const connection = joinVoiceChannel({
channelId: interaction.member.voice.channelId,
guildId: interaction.guildId,
adapterCreator: interaction.guild.voiceAdapterCreator,
debug: true,
});

try {
connection;
connection.subscribe(audioPlayer);

const resource = createAudioResource(media.url, {
inputType: StreamType.Opus,
});

audioPlayer.play(resource);

setInterval(() => {
if (resource.ended) {
const isMp3Playing = client.isMp3.get(interaction.guildId);
if (interaction.guild.members.me.voice?.channel && isMp3Playing) {
client.isMp3.set(interaction.guildId, false);
connection.destroy();
return interaction.guild.members.me.voice.disconnect();
} else return;
}
}, 1000);

return await Embed(
client,
interaction,
client.i18n.__mf(
{ phrase: "premium.mp3play.success", locale },
{ name: media.name }
)
);
} catch (error) {
if (error) await Embed(client, interaction, "An error occured...");
throw error;
}
client.isMp3.set(interaction.guildId, true);

const media = interaction.options.getAttachment("mp3_file");
const audioPlayer = createAudioPlayer();
const connection = joinVoiceChannel({
channelId: interaction.member.voice.channelId,
guildId: interaction.guildId,
adapterCreator: interaction.guild.voiceAdapterCreator,
debug: true,
});

try {
connection;
connection.subscribe(audioPlayer);

const resource = createAudioResource(media.url, {
inputType: StreamType.Opus,
});

audioPlayer.play(resource);

setInterval(() => {
if (resource.ended) {
const isMp3Playing = client.isMp3.get(interaction.guildId);
if (interaction.guild.members.me.voice?.channel && isMp3Playing) {
client.isMp3.set(interaction.guildId, false);
connection.destroy();
return interaction.guild.members.me.voice.disconnect();
} else return;
}
}, 1000);

return await Embed(
client,
interaction,
client.i18n.__mf(
{ phrase: "premium.mp3play.success", locale },
{ name: media.name }
)
);
} catch (error) {
if (error) await Embed(client, interaction, "An error occured...");
throw error;
}
discord.jsv14.11.0 @discordjs/[email protected] @discordjs/[email protected] node v18.13.0
2 replies