FranyxD
DIAdiscord.js - Imagine an app
•Created by FranyxD on 5/17/2024 in #djs-voice
Trying to play an audio file
Do you have an example files of how to do this things? In guide don't finde for discord voice
26 replies
DIAdiscord.js - Imagine an app
•Created by FranyxD on 5/17/2024 in #djs-voice
Trying to play an audio file
26 replies
DIAdiscord.js - Imagine an app
•Created by FranyxD on 5/17/2024 in #djs-voice
Trying to play an audio file
So if it's irrelevant, why not works? I change to absolute and it's the same
What type of permission need to mark at the bot
26 replies
DIAdiscord.js - Imagine an app
•Created by FranyxD on 5/17/2024 in #djs-voice
Trying to play an audio file
It's just I don't know what you mean, I need to change the bot permission?
26 replies
DIAdiscord.js - Imagine an app
•Created by FranyxD on 5/17/2024 in #djs-voice
Trying to play an audio file
Bot, can't and the I know
26 replies
DIAdiscord.js - Imagine an app
•Created by FranyxD on 5/17/2024 in #djs-voice
Trying to play an audio file
This?
26 replies
DIAdiscord.js - Imagine an app
•Created by FranyxD on 5/17/2024 in #djs-voice
Trying to play an audio file
// Play audio
const player = createAudioPlayer();
const resource = createAudioResource(path.resolve(__dirname, 'sample.ogg'));
player.play(resource);
// Play "track.mp3" across two voice connections
connection.subscribe(player);
26 replies
DIAdiscord.js - Imagine an app
•Created by FranyxD on 5/17/2024 in #djs-voice
Trying to play an audio file
Nope 😅
26 replies
DIAdiscord.js - Imagine an app
•Created by FranyxD on 5/17/2024 in #djs-voice
Trying to play an audio file
The other message you send me I don't understand at all
26 replies
DIAdiscord.js - Imagine an app
•Created by FranyxD on 5/17/2024 in #djs-voice
Trying to play an audio file
I ll try that
26 replies
DIAdiscord.js - Imagine an app
•Created by FranyxD on 5/17/2024 in #djs-voice
Trying to play an audio file
Yes
26 replies
DIAdiscord.js - Imagine an app
•Created by FranyxD on 5/17/2024 in #djs-voice
Trying to play an audio file
I have never gotten an error that I don't have permissions.
26 replies
DIAdiscord.js - Imagine an app
•Created by FranyxD on 5/17/2024 in #djs-voice
Trying to play an audio file
It's 14.15.2
26 replies
DIAdiscord.js - Imagine an app
•Created by FranyxD on 5/17/2024 in #djs-voice
Trying to play an audio file
Using discord guide, I don't know what I'm missing
26 replies
DIAdiscord.js - Imagine an app
•Created by FranyxD on 5/17/2024 in #djs-voice
Trying to play an audio file
module.exports = {
data: new SlashCommandBuilder()
.setName("play")
.setDescription(
"Command to make the bot join a voice channel and play an mp3",
),
async execute(interaction) {
if (!interaction.inGuild()) {
// Check if the command was used in a guild
interaction.reply("This command can only be used in a server.");
return;
}
const { member } = interaction; // Get the member who ran the command
const channel = member.voice.channel; // Get the voice channel the member is in
if (!channel) {
// Check if the member is in a voice channel
interaction.reply("You need to be in a voice channel to play audio!");
return;
}
if (!channel.permissionsFor(interaction.guild.members.me).has("STREAM")) {
interaction.reply("I don't have permission to stream audio in this voice channel.");
return;
}
// Join the voice channel
const connection = joinVoiceChannel({
// Create a connection to the voice channel
channelId: channel.id, // Use the ID of the voice channel
guildId: channel.guild.id, // Use the ID of the guild
adapterCreator: channel.guild.voiceAdapterCreator,
selfDeaf: false,
});
// Play audio
const player = createAudioPlayer();
const resource = createAudioResource('./sample.ogg');
player.play(resource);
// Play "track.mp3" across two voice connections
connection.subscribe(player);
// Check if the bot is playing audio
player.on(AudioPlayerStatus.Playing, () => {
console.log("Bot is playing audio.");
});
// Check if the bot is reading the mp3 file
player.on(AudioPlayerStatus.Buffering, () => {
console.log("Bot is reading the mp3 file.");
});
await interaction.reply("Playing mp3");
},
};
26 replies
DIAdiscord.js - Imagine an app
•Created by FranyxD on 5/17/2024 in #djs-voice
Trying to play an audio file
Okay
26 replies
DIAdiscord.js - Imagine an app
•Created by FranyxD on 5/17/2024 in #djs-voice
Trying to play an audio file
It's the /commands/utility/play.js
26 replies
DIAdiscord.js - Imagine an app
•Created by FranyxD on 5/17/2024 in #djs-voice
Trying to play an audio file
The code is here in replit
https://replit.com/@FranyxD/Zetydiscordbot?s=app
26 replies
DIAdiscord.js - Imagine an app
•Created by FranyxD on 5/17/2024 in #djs-voice
Trying to play an audio file
I have mp3 and ogg filed just in case
26 replies
DIAdiscord.js - Imagine an app
•Created by FranyxD on 5/17/2024 in #djs-voice
Trying to play an audio file
Yes, I have it in my package.json dependencies
26 replies