better code reuse
Bi-Rabittoh andronacomarco@gmail.com
Mon, 23 Jan 2023 21:38:54 +0100
1 files changed,
3 insertions(+),
9 deletions(-)
jump to
M
commands/stop.js
→
commands/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 });