Simple Music Bot

Here is a complete example of a simple music bot that can play, pause, and skip tracks.

bot.js
const { Client, GatewayIntentBits } = require("discord.js");
const { Manager } = require("kawalink");

const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.MessageContent,
    GatewayIntentBits.GuildVoiceStates
  ]
});



client.on("messageCreate", async (message) => {
  if (!message.content.startsWith("!play")) return;

  const query = message.content.split(" ").slice(1).join(" ");
  const player = client.manager.create({
    guild: message.guild.id,
    voiceChannel: message.member.voice.channel.id,
    textChannel: message.channel.id,
  });

  player.connect();
  const res = await client.manager.search(query, message.author);
  player.queue.add(res.tracks[0]);

  if (!player.playing) player.play();
});

Full Example Bot

Want a production-ready bot? Check out this open source example with Slash Commands, loop, autoplay, and more.

x2super

bot-music

/play/pause/resume/stop/skip/volume/loop/autoplay/nodes
1 star 0 forksJavaScript · MIT