diff --git a/commands/music/play.js b/commands/music/play.js index 730912a..0675f1c 100644 --- a/commands/music/play.js +++ b/commands/music/play.js @@ -5,9 +5,10 @@ const searchRegex = /^ytsearch:/; class PlayCommand extends MusicCommand { async run() { - if (!this.args[0]) return "You need to provide what you want to play!"; + if (!this.args[0] && this.message.attachments.length <= 0) return "You need to provide what you want to play!"; const query = this.args.join(" ").trim(); - const search = urlRegex.test(query) ? query : (searchRegex.test(query) ? query : `ytsearch:${query}`); + const attachment = this.message.attachments[0]; + const search = urlRegex.test(query) ? query : searchRegex.test(query) ? query : !this.args[0] && attachment ? attachment.url : `ytsearch:${query}`; return await play(this.client, search, this.message, true); } @@ -16,4 +17,4 @@ class PlayCommand extends MusicCommand { static arguments = ["[url]"]; } -export default PlayCommand; \ No newline at end of file +export default PlayCommand;