all repos — simple-discord-music-bot @ acb0e8e5e1fdb917e94a549726e93ad068837575

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

better code reuse
Bi-Rabittoh andronacomarco@gmail.com
Mon, 23 Jan 2023 21:38:54 +0100
commit

acb0e8e5e1fdb917e94a549726e93ad068837575

parent

8f1693b44bb58af48d564493d00baf74f37a27b8

1 files changed, 3 insertions(+), 9 deletions(-)

jump to
M commands/stop.jscommands/stop.js

@@ -1,4 +1,3 @@

-const path = require("node:path"); const { SlashCommandBuilder } = require("discord.js"); module.exports = {

@@ -7,15 +6,10 @@ .setName("stop")

.setDescription("Stop the music."), async execute(interaction) { - const member = interaction.member; - if (!member) - return await interaction.reply({ content: "Please use this in your current server.", ephemeral: true }); - const user_connection = member.voice; - const channel = user_connection.channel; - - if (!channel) - return await interaction.reply({ content: "You're not in a voice channel.", ephemeral: true }); + channel = await getChannel(interaction); + if (typeof channel == "string") + return await interaction.reply({ content: channel, ephemeral: true }); player.stop(); return await interaction.reply({ content: "Stopped.", ephemeral: true });