|
| 1 | +const { |
| 2 | + MessageEmbed, Message, splitMessage |
| 3 | +} = require(`discord.js`); |
| 4 | +const config = require(`../../botconfig/config.json`); |
| 5 | +const { |
| 6 | + KSoftClient |
| 7 | +} = require(`@ksoft/api`); |
| 8 | +const ee = require(`../../botconfig/embed.json`); |
| 9 | +const { |
| 10 | + format, |
| 11 | + delay |
| 12 | +} = require(`../../handlers/functions`); |
| 13 | +module.exports = { |
| 14 | + name: `lyrics`, |
| 15 | + category: `Song`, |
| 16 | + aliases: [`l`, `ly`], |
| 17 | + description: `Shows The Lyrics of the current track`, |
| 18 | + usage: `lyrics [Songtitle]`, |
| 19 | + cooldown: 15, |
| 20 | + run: async (client, message, args, cmduser, text, prefix) => { |
| 21 | + //get the voice channel of the member |
| 22 | + const { channel } = message.member.voice; |
| 23 | + //if he is not connected to a vc return error |
| 24 | + if (!args[0] && !channel) return message.channel.send(`:x: **You have to be in a voice channel to use this command.**`); |
| 25 | + //send error if member is Deafed |
| 26 | + if(!args[0] && message.member.voice.selfDeaf) return message.channel.send(`:x: **You cannot run this command while deafened**`); |
| 27 | + //get voice channel of the bot |
| 28 | + const botchannel = message.guild.me.voice.channel; |
| 29 | + //get the music player |
| 30 | + const player = client.manager.players.get(message.guild.id); |
| 31 | + //if no player or no botchannel return error |
| 32 | + if(!args[0] && (!player || !botchannel)) return message.channel.send(`**:x: Nothing playing in this server**`); |
| 33 | + //if queue size too small return error |
| 34 | + if (!args[0] && (!player.queue || !player.queue.current)) return message.channel.send(`**:x: Nothing playing in this server**`); |
| 35 | + //if user is not in the right channel as bot, then return error |
| 36 | + if(!args[0] && (player && channel.id !== player.voiceChannel)) |
| 37 | + return message.channel.send(`**:x: You need to be in the same voice channel as Milrato x Rythm to use this command**`); |
| 38 | + //if bot connected bot not with the lavalink player then try to delete the player |
| 39 | + if(!args[0] && (player && botchannel && channel.id !== botchannel.id)){ |
| 40 | + player.destroy(); |
| 41 | + } |
| 42 | + //get the Song Title |
| 43 | + let title = args[0] || player.queue.current.title || "404"; |
| 44 | + if(title == "404") return message.channel.send(`**:x: Something went wrong**`); |
| 45 | + //if there are search terms, search for the lyrics |
| 46 | + if (args[0]) { |
| 47 | + //get the new title |
| 48 | + title = args.join(` `); |
| 49 | + } |
| 50 | + //set the lyrics temp. to null |
| 51 | + let lyrics = null; |
| 52 | + //send info msg |
| 53 | + let lyricsmsg = await message.channel.send(`**:mag: Searching lyrics for \`${title}\`**`).catch(e=>console.log("error")) |
| 54 | + //if there is the use of lyrics_finder |
| 55 | + //create a new Ksoft Client |
| 56 | + const ksoft = new KSoftClient(config.ksoftapi); |
| 57 | + //get the lyrics |
| 58 | + await ksoft.lyrics.get(title).then(async (track) => { |
| 59 | + //send error if no lyrics |
| 60 | + if (!track.lyrics) return lyricsmsg.edit(`**:x: No Lyrics found for:** \`${title}\``).catch(e=>console.log("error")) |
| 61 | + //safe the lyrics on the temp. variable |
| 62 | + lyrics = track.lyrics; |
| 63 | + }); |
| 64 | + var embeds = []; |
| 65 | + |
| 66 | + let lyembed = new MessageEmbed().setColor("#00ff00").setTitle(title.substr(0, 256)).setDescription(lyrics); |
| 67 | + |
| 68 | + const splitDescription = splitMessage(lyembed.description); |
| 69 | + for(var i = 0; i < splitDescription.length; i++){ |
| 70 | + if(i > 0){ |
| 71 | + embeds.push(new MessageEmbed().setColor("#00ff00").setDescription(splitDescription[i])) |
| 72 | + }else{ |
| 73 | + embeds.push(lyembed.setDescription(splitDescription[i])); |
| 74 | + } |
| 75 | + } |
| 76 | + |
| 77 | + |
| 78 | + lyricsmsg.edit({content: `**:mag: Searching lyrics for \`${title}\`**`, embed: embeds[0]}).catch(e=>console.log("error")) |
| 79 | + for(let i = 1; i<embeds.length;i++){ |
| 80 | + message.channel.send(embeds[i]).catch(e=>console.log("error")) |
| 81 | + } |
| 82 | + } |
| 83 | +}; |
| 84 | +/** |
| 85 | + * @INFO |
| 86 | + * Bot Coded by Tomato#6966 | https://github.com/Tomato6966/discord-js-lavalink-Music-Bot-erela-js |
| 87 | + * @INFO |
| 88 | + * Work for Milrato Development | https://milrato.eu |
| 89 | + * @INFO |
| 90 | + * Please mention Him / Milrato Development, when using this Code! |
| 91 | + * @INFO |
| 92 | + */ |
0 commit comments