Make the play command play the first attachment if there is one and no arguments are given (#174)

This commit is contained in:
dx9er 2021-11-11 02:14:37 +02:00 committed by GitHub
parent c75b93f563
commit 8431a3ab95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -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;
export default PlayCommand;