Remove musicMatch command ( was not working realiably )
This commit is contained in:
parent
c070194835
commit
bd5ab9f00f
2 changed files with 0 additions and 87 deletions
|
@ -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;
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue