Make the play command play the first attachment if there is one and no arguments are given (#174)
This commit is contained in:
parent
c75b93f563
commit
8431a3ab95
|
@ -5,9 +5,10 @@ const searchRegex = /^ytsearch:/;
|
||||||
|
|
||||||
class PlayCommand extends MusicCommand {
|
class PlayCommand extends MusicCommand {
|
||||||
async run() {
|
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 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);
|
return await play(this.client, search, this.message, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue