-
I was looking for the same thing as Discussion #256 and I tried to apply the code written by @skick1234 which is .play(channel, url, { metadata: { i: interaction } })
.on("addSong", (q, song) => {
song.metadata.i.reply(...)
}) and I get the error import { ChatInputCommandInteraction, EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
import { Command } from '../../Core/command.js';
export default new Command({
name: "music_sr",
description: "Request a song that will be played in the voice channel",
emote: false,
data: new SlashCommandBuilder()
.setName("music_sr")
.setDescription("Request a song that will be played in the voice channel")
.addStringOption((Option) =>
Option
.setName("query")
.setDescription("Type the song name or paste any YouTube URL")
.setRequired(true)
),
run: async ({ interaction, client }) => {
if (interaction === undefined) return;
await interaction.deferReply();
const voiceChannel = (interaction.member as GuildMember).voice.channel;
if (!voiceChannel) return await interaction.editReply({
embeds: [
new EmbedBuilder()
.setTitle("Error: Music module")
.setDescription("You must be in a voice channel!")
.setColor("Red")
]
});
const permissions = voiceChannel.permissionsFor(interaction.client.user);
if (!permissions?.has("Connect")) return await interaction.editReply({
embeds: [
new EmbedBuilder()
.setTitle("Error: Music module")
.setDescription(`I don't have the "Connect" permission to join the Voice channel`)
.setColor("Red")
]
});
if (!permissions.has("Speak")) return await interaction.editReply({
embeds: [
new EmbedBuilder()
.setTitle("Error: Music module")
.setDescription(`I don't have the "Speak" permission to join the Voice channel`)
.setColor("Red")
]
});
const msg = await interaction.editReply({
embeds: [
new EmbedBuilder()
.setTitle("Music: Fetching details")
.setDescription(`Fetching music metadata`)
.setColor("Blue")
]
})
client.DisTube.play(voiceChannel, interaction.options.get("query", true).value as string, {
member: interaction.member as GuildMember,
metadata: { i: ChatInputCommandInteraction }
}).on("addSong", async (q, song) => {
await song.metadata.i.editReply({
embeds: [
new EmbedBuilder()
.setDescription("Requested song added to the queue")
.setColor("Random")
.setAuthor({ name: `Song added`, iconURL: `https://cdn.discordapp.com/attachments/933971458496004156/1005595741198233790/My_project.png` })
.setFooter({ text: "Embed auto created by d3fau4tbot" })
.setTimestamp()
.setURL(`${song.url}`)
.setThumbnail(`https://cdn.discordapp.com/attachments/933971458496004156/1005590805756530718/Checkmark-green-tick-isolated-on-transparent-background-PNG.png`)
.addFields(
{ name: "Song Name", value: `${song.name}`, inline: false },
{ name: "Duration", value: `${song.formattedDuration}`, inline: true },
{ name: "Requested by", value: `${song.user}`, inline: true },
)
]
});
});
}
}); |
Beta Was this translation helpful? Give feedback.
Answered by
skick1234
Feb 6, 2023
Replies: 1 comment 5 replies
-
Ofc it is not the same.
Please learn basic js/ts first. We don't support it here. |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
skick1234
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ofc it is not the same.
client.DisTube.on(...)
Please learn basic js/ts first. We don't support it here.