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
1 changed files with 4 additions and 3 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue