all repos — simple-discord-music-bot @ 61364f5fe32e6420a82abd998c4a0baa264184e0

A Discord bot making use of discord.js and play-yt.

commands/stop.js (view raw)

 1const path = require("node:path");
 2const { SlashCommandBuilder } = require("discord.js");
 3
 4module.exports = {
 5  data: new SlashCommandBuilder()
 6    .setName("stop")
 7    .setDescription("Stop the music."),
 8
 9  async execute(interaction) {
10    const member = interaction.member;
11    if (!member)
12      return await interaction.reply({ content: "Please use this in your current server.", ephemeral: true });
13
14    const user_connection = member.voice;
15    const channel = user_connection.channel;
16
17    if (!channel)
18      return await interaction.reply({ content: "You're not in a voice channel.", ephemeral: true });
19
20    player.stop();
21    return await interaction.reply({ content: "Stopped.", ephemeral: true });
22  },
23};