mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-23 15:47:57 -05:00
add skip + remove sleep
This commit is contained in:
parent
390852f890
commit
daf4b2a50e
2 changed files with 15 additions and 5 deletions
|
@ -148,6 +148,14 @@ module.exports = {
|
|||
}
|
||||
bot.music.stop();
|
||||
}
|
||||
if (args[0]==='skip') {
|
||||
try {
|
||||
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: 'Skipped '}, {text: bot.music.song.name, color: 'gold'}]));
|
||||
bot.music.skip();
|
||||
} catch (e) {
|
||||
throw new Error('No music is currently playing!');
|
||||
}
|
||||
}
|
||||
if (args[0]==='loop') {
|
||||
if (args[1] === 'off') {
|
||||
bot.music.loop = 0;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
/* eslint-disable max-len */
|
||||
const {Midi} = require('@tonejs/midi');
|
||||
const {convertMidi} = require('../util/midi_converter');
|
||||
const sleep = require('sleep-promise');
|
||||
|
||||
const soundNames = {
|
||||
harp: 'minecraft:block.note_block.harp',
|
||||
|
@ -30,6 +29,11 @@ function inject(bot) {
|
|||
time = 0;
|
||||
startTime = 0;
|
||||
noteIndex = 0;
|
||||
bot.music.skip = function() {
|
||||
bot.music.queue.shift();
|
||||
resetTime();
|
||||
};
|
||||
|
||||
const interval = setInterval(async () => {
|
||||
try {
|
||||
if (!bot.music.queue.length) return;
|
||||
|
@ -48,16 +52,14 @@ function inject(bot) {
|
|||
}
|
||||
if (bot.music.loop === 2) {
|
||||
resetTime();
|
||||
await sleep(100);
|
||||
bot.music.queue.push(song);
|
||||
bot.music.play(bot.music.queue.shift());
|
||||
bot.music.queue.push(bot.music.queue.shift());
|
||||
bot.music.play(bot.music.queue[0]);
|
||||
return;
|
||||
}
|
||||
bot.music.queue.shift();
|
||||
if (!bot.music.queue[0]) return;
|
||||
if (bot.music.queue[0].notes.length > 0) {
|
||||
if (bot.music.queue.length !== 1) resetTime();
|
||||
await sleep(100);
|
||||
bot.music.play(bot.music.queue[0]);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue