mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 06:42:50 +02:00
Limit play video length
This commit is contained in:
@@ -49,6 +49,7 @@ module.exports = class PlayCommand extends Command {
|
|||||||
const data = await ytdl.getInfo(result);
|
const data = await ytdl.getInfo(result);
|
||||||
const canPlay = this.canUseVideo(data, msg.channel.nsfw || false);
|
const canPlay = this.canUseVideo(data, msg.channel.nsfw || false);
|
||||||
if (!canPlay) return msg.say('I cannot play this video.');
|
if (!canPlay) return msg.say('I cannot play this video.');
|
||||||
|
if (canPlay === 'length') return msg.say('This video is longer than 15 minutes, so I can\'t play it.');
|
||||||
await msg.reply('Is this the video you want to play? Type **[y]es** or **[n]o**.', {
|
await msg.reply('Is this the video you want to play? Type **[y]es** or **[n]o**.', {
|
||||||
embed: this.generateEmbed(data)
|
embed: this.generateEmbed(data)
|
||||||
});
|
});
|
||||||
@@ -82,6 +83,7 @@ module.exports = class PlayCommand extends Command {
|
|||||||
canUseVideo(data, nsfw) {
|
canUseVideo(data, nsfw) {
|
||||||
if (data.videoDetails.isPrivate || data.videoDetails.isLiveContent) return false;
|
if (data.videoDetails.isPrivate || data.videoDetails.isLiveContent) return false;
|
||||||
if (data.videoDetails.age_restricted && nsfw) return false;
|
if (data.videoDetails.age_restricted && nsfw) return false;
|
||||||
|
if (Number.parseInt(data.lengthSeconds, 10) > 900) return 'length';
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user