Kod:
const { Client, GatewayIntentBits } = require("discord.js");
const { joinVoiceChannel, createAudioPlayer, createAudioResource, AudioPlayerStatus } = require("@discordjs/voice");
const ytdl = require("ytdl-core");
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
]
});
const prefix = "!";
const player = createAudioPlayer();
client.once("ready", () => {
console.log(`✅ ${client.user.tag} müzik botu aktif`);
});
client.on("messageCreate", async (message) => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if (command === "play") {
if (!args[0]) return message.reply(" Bir YouTube linki girin");
if (!message.member.voice.channel) return message.reply("Önce ses kanalına girin");
const connection = joinVoiceChannel({
channelId: message.member.voice.channel.id,
guildId: message.guild.id,
adapterCreator: message.guild.voiceAdapterCreator,
});
const stream = ytdl(args[0], { filter: "audioonly" });
const resource = createAudioResource(stream);
player.play(resource);
connection.subscribe(player);
message.reply("Müzik çalıyor!");
}
if (command === "stop") {
player.stop();
message.reply("Müzik durduruldu.");
}
});
player.on(AudioPlayerStatus.Idle, () => {
console.log("Müzik bitti.");
});
client.login("BOT_TOKEN_BURAYA");)

