mirror of
https://github.com/musix-org/musix-oss
synced 2024-11-10 05:10:17 +00:00
Saved queues
This commit is contained in:
parent
e8f30cd706
commit
a8cde6abca
@ -5,7 +5,9 @@ module.exports = {
|
|||||||
async execute(message, args, client, Discord, prefix) {
|
async execute(message, args, client, Discord, prefix) {
|
||||||
const ytdl = require('ytdl-core');
|
const ytdl = require('ytdl-core');
|
||||||
const serverQueue = client.queue.get(message.guild.id);
|
const serverQueue = client.queue.get(message.guild.id);
|
||||||
|
if (serverQueue) {
|
||||||
let data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url));
|
let data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url));
|
||||||
|
}
|
||||||
if (message.author.id !== '360363051792203779') return message.channel.send(':x: You are not allowed to do that!');
|
if (message.author.id !== '360363051792203779') return message.channel.send(':x: You are not allowed to do that!');
|
||||||
const input = message.content.slice(prefix.length + 4);
|
const input = message.content.slice(prefix.length + 4);
|
||||||
let output;
|
let output;
|
||||||
|
56
commands/playlist.js
Normal file
56
commands/playlist.js
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
module.exports = {
|
||||||
|
name: 'playlist',
|
||||||
|
usage: '[option]',
|
||||||
|
description: 'Save and load queues',
|
||||||
|
cooldown: 10,
|
||||||
|
async execute(message, args, client, Discord, prefix) {
|
||||||
|
const serverQueue = client.queue.get(message.guild.id);
|
||||||
|
if (client.global.db.guilds[message.guild.id].premium) {
|
||||||
|
if (args[1] === 'play') {
|
||||||
|
if (client.global.db.playlists[message.guild.id].saved) {
|
||||||
|
if (!serverQueue) {
|
||||||
|
const construct = {
|
||||||
|
textChannel: message.channel,
|
||||||
|
voiceChannel: message.member.voiceChannel,
|
||||||
|
connection: null,
|
||||||
|
songs: [...client.global.db.playlists[message.guild.id].songs],
|
||||||
|
volume: client.global.db.guilds[message.guild.id].defaultVolume,
|
||||||
|
playing: true,
|
||||||
|
looping: false
|
||||||
|
};
|
||||||
|
client.queue.set(message.guild.id, construct);
|
||||||
|
message.channel.send(":white_check_mark: Queue set!");
|
||||||
|
try {
|
||||||
|
var connection = await message.member.voiceChannel.join();
|
||||||
|
construct.connection = connection;
|
||||||
|
client.funcs.play(message.guild, construct.songs[0], client, message, 0);
|
||||||
|
} catch (error) {
|
||||||
|
client.queue.delete(message.guild.id);
|
||||||
|
return message.channel.send(`:x: An error occured: ${error}`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
serverQueue.connection.dispatcher.end("queue set");
|
||||||
|
serverQueue.songs = [...client.global.db.playlists[message.guild.id].songs];
|
||||||
|
message.channel.send(":white_check_mark: Queue set!");
|
||||||
|
}
|
||||||
|
} else return message.channel.send(':x: There is no queue set for this server!')
|
||||||
|
} else if (args[1] === 'save') {
|
||||||
|
client.global.db.playlists[message.guild.id] = {
|
||||||
|
songs: serverQueue.songs,
|
||||||
|
firstSong: serverQueue.songs[0],
|
||||||
|
saved: true,
|
||||||
|
};
|
||||||
|
message.channel.send(":white_check_mark: Queue saved!");
|
||||||
|
} else {
|
||||||
|
const embed = new Discord.RichEmbed()
|
||||||
|
.setTitle('Options for playlist!')
|
||||||
|
.addField('play', 'Play the guild specific queue.', true)
|
||||||
|
.addField('save', 'Save the currently playing queue.')
|
||||||
|
.setFooter(`how to use: ${prefix}playlist <Option>`)
|
||||||
|
.setAuthor(client.user.username, client.user.displayAvatarURL)
|
||||||
|
.setColor('#b50002')
|
||||||
|
return message.channel.send(embed);
|
||||||
|
}
|
||||||
|
} else return message.channel.send(":x: This is not a premium guild!");
|
||||||
|
},
|
||||||
|
};
|
@ -8,6 +8,7 @@ module.exports = {
|
|||||||
prefix: ">",
|
prefix: ">",
|
||||||
defaultVolume: 5,
|
defaultVolume: 5,
|
||||||
permissions: false,
|
permissions: false,
|
||||||
|
premium: false,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
return message.channel.send(':white_check_mark: Reset all guild settings!')
|
return message.channel.send(':white_check_mark: Reset all guild settings!')
|
||||||
@ -16,9 +17,10 @@ module.exports = {
|
|||||||
prefix: ">",
|
prefix: ">",
|
||||||
defaultVolume: 5,
|
defaultVolume: 5,
|
||||||
permissions: false,
|
permissions: false,
|
||||||
|
premium: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
let prefix = client.global.db.guilds[message.guild.id].prefix;
|
let prefix = "-"//client.global.db.guilds[message.guild.id].prefix;
|
||||||
const args = message.content.slice(prefix.length).split(' ');
|
const args = message.content.slice(prefix.length).split(' ');
|
||||||
if (message.mentions.users.first()) {
|
if (message.mentions.users.first()) {
|
||||||
if (message.mentions.users.first().id === '607266889537945605' && args[1] === 'help') return client.commands.get('help').execute(message, args, client, Discord, prefix, client);
|
if (message.mentions.users.first().id === '607266889537945605' && args[1] === 'help') return client.commands.get('help').execute(message, args, client, Discord, prefix, client);
|
||||||
|
@ -16,8 +16,13 @@ module.exports = {
|
|||||||
defaultVolume: client.global.db.guilds[guild.id].defaultVolume,
|
defaultVolume: client.global.db.guilds[guild.id].defaultVolume,
|
||||||
permissions: client.global.db.guilds[guild.id].permissions,
|
permissions: client.global.db.guilds[guild.id].permissions,
|
||||||
});
|
});
|
||||||
|
if (client.global.db.guilds[guild.id].premium) {
|
||||||
|
client.db.collection('playlists').doc(guild.id).set({
|
||||||
|
songs: client.global.db.playlists[message.guild.id].songs,
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
dbl.postStats(client.guilds.size);
|
dbl.postStats(client.guilds.size);
|
||||||
}, 1200000);
|
}, 1800000);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,11 +25,11 @@ module.exports = async function (guild, song, client, message, seek) {
|
|||||||
});
|
});
|
||||||
dispatcher.setVolume(serverQueue.volume / 10);
|
dispatcher.setVolume(serverQueue.volume / 10);
|
||||||
dispatcher.on("error", error => console.error(error));
|
dispatcher.on("error", error => console.error(error));
|
||||||
//let data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url));
|
let data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url));
|
||||||
//let songtime = (data.length_seconds * 1000).toFixed(0);
|
let songtime = (data.length_seconds * 1000).toFixed(0);
|
||||||
const embed = new Discord.RichEmbed()
|
const embed = new Discord.RichEmbed()
|
||||||
.setTitle(`:musical_note: Start playing: **${song.title}**`)
|
.setTitle(`:musical_note: Start playing: **${song.title}**`)
|
||||||
//.setDescription(`Song duration: \`${client.funcs.msToTime(songtime)}\``)
|
.setDescription(`Song duration: \`${client.funcs.msToTime(songtime)}\``)
|
||||||
.setColor("#b50002")
|
.setColor("#b50002")
|
||||||
serverQueue.textChannel.send(embed);
|
serverQueue.textChannel.send(embed);
|
||||||
}
|
}
|
||||||
|
3
index.js
3
index.js
@ -18,6 +18,7 @@ client.db.FieldValue = require('firebase-admin').firestore.FieldValue;
|
|||||||
client.global = {
|
client.global = {
|
||||||
db: {
|
db: {
|
||||||
guilds: {},
|
guilds: {},
|
||||||
|
playlists: {},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ client.funcs.dbget = require('./funcs/dbget.js');
|
|||||||
|
|
||||||
client.config = {
|
client.config = {
|
||||||
token: process.env.TOKEN,
|
token: process.env.TOKEN,
|
||||||
apikey: process.env.API_KEY,
|
apikey: process.env.API_KEY2,
|
||||||
prefix: '>',
|
prefix: '>',
|
||||||
test: 'success',
|
test: 'success',
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user