From bd5ab9f00fb23055fef4fa144e3bb3a985ad6fae Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sat, 9 Nov 2019 11:20:28 +0100 Subject: [PATCH] Remove musicMatch command ( was not working realiably ) --- commands/utility/musicMatch.js | 86 ---------------------------------- package.json | 1 - 2 files changed, 87 deletions(-) delete mode 100644 commands/utility/musicMatch.js diff --git a/commands/utility/musicMatch.js b/commands/utility/musicMatch.js deleted file mode 100644 index 358f898..0000000 --- a/commands/utility/musicMatch.js +++ /dev/null @@ -1,86 +0,0 @@ -const { Command } = require('discord-akairo'); -const { MessageEmbed } = require('discord.js'); -const fpcalc = require('fpcalc'); -const fetch = require('node-fetch'); -const youtubedl = require('youtube-dl'); -const fs = require('fs'); -const { acoustID } = require('../../config.json'); - - -class musicCommand extends Command { - constructor() { - super('musicMatch', { - aliases: ['musicMatch', 'music', 'shazam', 'soundhound'], - category: 'utility', - args: [ - { - id: 'music', - type: 'string', - prompt: { - start: 'Send the link of wich video you want to know song', - }, - match: 'rest' - } - ], - description: { - content: 'Find what music it is from attachment or link', - usage: '[file]', - examples: ['[file]'] - } - }); - } - - async exec(message,args) { - let link; - let Attachment = (message.attachments).array(); - - function checkURL(url) { - return(url.match(/\.(mp3|wav|mp4|webm)$/) != null); - } - - if (!args.music && Attachment[0]) { - if (!checkURL(Attachment[0].url)) - return message.channel.send('Only mp3,wav,mp4 and webm are supported'); - link = Attachment[0].url; - } else { - link = args.music; - if (!checkURL(link)) - return message.channel.send('Only mp3,wav,mp4 and webm are supported'); - } - - let video = youtubedl(link, ['-x', '--audio-format', 'mp3']); - video.pipe(fs.createWriteStream('./music.mp3')); - video.on('error', function error(err) { - console.log('error 2:', err); - message.channel.send('An error has occured, I can\'t download from the link you provided.'); - }); - video.on('end', function () { - fpcalc('./music.mp3', function(err, result) { - if (err) throw err; - fetch(`https://api.acoustid.org/v2/lookup?client=${acoustID}&meta=recordings+releasegroups+compress&duration=${result.duration}&fingerprint=${result.fingerprint}`).then((response) => { - return response.json(); - }).then((response) => { - if (!response.results[0]) - return message.channel.send('Could not identify the music'); - - let time = response.results[0].recordings[0].duration; - let minutes = Math.floor(time / 60); - let seconds = time - minutes * 60; - - const musicEmbed = new MessageEmbed() - .setColor(message.member.displayHexColor) - .setTitle('Music found!') - .addField('Title', response.results[0].recordings[0].title, true) - .addField('Artist', response.results[0].recordings[0].artists[0].name, true) - .addField('Album', response.results[0].recordings[0].releasegroups[0].title, true) - .addField('Duration', `${minutes}:${seconds}`); - - - message.channel.send(musicEmbed); - }); - }); - }); - } -} - -module.exports = musicCommand; \ No newline at end of file diff --git a/package.json b/package.json index 4061c98..b7cfe2f 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,6 @@ "console-stamp": "^0.2.9", "discord-akairo": "github:1Computer1/discord-akairo#master", "discord.js": "github:discordjs/discord.js#master", - "fpcalc": "^1.3.0", "gm": "^1.23.1", "grpc": "^1.24.1", "handbrake-js": "^3.0.8",