mirror of
https://github.com/hazemKrimi/discord-bot.git
synced 2026-05-01 18:30:25 +00:00
improved seek command
This commit is contained in:
@@ -25,7 +25,7 @@ module.exports = class JoinCommand extends Command {
|
|||||||
key: 'query',
|
key: 'query',
|
||||||
prompt: 'to what time do you want to seek? (HH:MM:SS)',
|
prompt: 'to what time do you want to seek? (HH:MM:SS)',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: query => query.length > 0 && query.match(/\d+:\d{2}:\d{2}/)
|
validate: query => query.length > 0 && query.match(/(\d+:)?(\d{2}:)?\d{2}/)
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
throttling: {
|
throttling: {
|
||||||
@@ -54,7 +54,7 @@ module.exports = class JoinCommand extends Command {
|
|||||||
}
|
}
|
||||||
message.guild.music.seek = seekSeconds;
|
message.guild.music.seek = seekSeconds;
|
||||||
await message.guild.play(message.guild.music.queue, message);
|
await message.guild.play(message.guild.music.queue, message);
|
||||||
const embed = new MessageEmbed().setColor('#000099').setTitle(`:musical_note: Sought to ${query}`);
|
const embed = new MessageEmbed().setColor('#000099').setTitle(`:musical_note: Sought to ${message.guild.formatDurationString(Math.floor(seekSeconds / 3600), Math.floor(seekSeconds / 60), seekSeconds % 60)}`);
|
||||||
return await message.say({ embed });
|
return await message.say({ embed });
|
||||||
}
|
}
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
|
|||||||
@@ -104,11 +104,15 @@ Structures.extend('Guild', Guild => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
formatDurationSeconds = durationString => {
|
formatDurationSeconds = durationString => {
|
||||||
if (!durationString.match(/\d+:\d{2}:\d{2}/)) return;
|
if (!durationString.match(/(\d+:)?(\d{2}:)?\d{2}/)) return;
|
||||||
|
|
||||||
const time = durationString.split(':').map(time => parseInt(time));
|
const time = durationString.split(':').map(time => parseInt(time));
|
||||||
|
|
||||||
return time[0] * 3600 + time[1] * 60 + time[2];
|
switch (time.length) {
|
||||||
|
case 3: return time[0] * 3600 + time[1] * 60 + time[2];
|
||||||
|
case 2: return time[0] * 60 + time[1];
|
||||||
|
case 1: return time[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user