mirror of
https://github.com/musix-org/musix-oss
synced 2025-06-16 18:56:00 +00:00
Init
This commit is contained in:
18
src/events/dispatcher/finish.js
Normal file
18
src/events/dispatcher/finish.js
Normal file
@ -0,0 +1,18 @@
|
||||
module.exports = async function (client, reason, guild) {
|
||||
const serverQueue = client.queue.get(guild.id);
|
||||
serverQueue.playing = false;
|
||||
if (reason === "Stream is not generating quickly enough.") {
|
||||
console.log("Song ended");
|
||||
} else if (reason === "seek") {
|
||||
return;
|
||||
} else {
|
||||
console.log(reason);
|
||||
}
|
||||
if (!serverQueue.songLooping) {
|
||||
if (serverQueue.looping) {
|
||||
serverQueue.songs.push(serverQueue.songs[0]);
|
||||
}
|
||||
serverQueue.songs.shift();
|
||||
}
|
||||
client.funcs.play(guild, serverQueue.songs[0], client, 0, true);
|
||||
};
|
21
src/events/guildCreate.js
Normal file
21
src/events/guildCreate.js
Normal file
@ -0,0 +1,21 @@
|
||||
module.exports = {
|
||||
name: 'guildcreate',
|
||||
async execute(client, guild) {
|
||||
client.db.collection('guilds').doc(guild.id).set({
|
||||
prefix: client.config.prefix,
|
||||
defaultVolume: client.config.defaultVolume,
|
||||
permissions: client.config.permissions,
|
||||
dj: client.config.dj,
|
||||
djrole: client.config.djrole,
|
||||
startPlaying: client.config.startPlaying
|
||||
});
|
||||
client.global.db.guilds[guild.id] = {
|
||||
prefix: client.config.prefix,
|
||||
defaultVolume: client.config.defaultVolume,
|
||||
permissions: client.config.permissions,
|
||||
dj: client.config.dj,
|
||||
djrole: client.config.djrole,
|
||||
startPlaying: client.config.startPlaying
|
||||
};
|
||||
}
|
||||
}
|
27
src/events/msg.js
Normal file
27
src/events/msg.js
Normal file
@ -0,0 +1,27 @@
|
||||
module.exports = {
|
||||
name: 'message',
|
||||
async execute(client, msg, Discord) {
|
||||
if (msg.author.bot || !msg.guild) return;
|
||||
let prefix = client.global.db.guilds[msg.guild.id].prefix;
|
||||
if (client.config.devMode) prefix = "-";
|
||||
const args = msg.content.slice(prefix.length).split(' ');
|
||||
if (msg.mentions.users.first()) {
|
||||
if (msg.mentions.users.first().id === client.user.id) {
|
||||
if (!args[1]) return;
|
||||
if (args[1] === 'prefix') return msg.channel.send(`My prefix here is: \`${prefix}\`.`);
|
||||
if (args[1] === 'help') {
|
||||
const command = client.commands.get("help");
|
||||
return client.funcs.exe(msg, args, client, Discord, prefix, command);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (client.config.devMode && msg.member.id !== client.config.devId) return msg.channel.send('<:redx:674263474704220182> Dev mode has been turned on! Commands are only available to developer(s)!');
|
||||
if (!msg.content.startsWith(prefix)) return;
|
||||
if (!args[0]) return;
|
||||
const commandName = args[0].toLowerCase();
|
||||
const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName)) || client.commandAliases.get(commandName);
|
||||
if (!command && msg.content !== `${prefix}`) return;
|
||||
if (command.onlyDev && msg.author.id !== client.config.devId) return msg.channel.send('<:redx:674263474704220182> You are not allowed to do that!');
|
||||
client.funcs.exe(msg, args, client, Discord, prefix, command);
|
||||
}
|
||||
}
|
53
src/events/ready.js
Normal file
53
src/events/ready.js
Normal file
@ -0,0 +1,53 @@
|
||||
const DBL = require("dblapi.js");
|
||||
|
||||
module.exports = {
|
||||
name: 'ready',
|
||||
async execute(client, Discord) {
|
||||
const remoteMusixGuildsData = await client.funcs.dbget('guilds', null, client);
|
||||
remoteMusixGuildsData.forEach(guildData => {
|
||||
client.global.db.guilds[guildData.id] = guildData.d;
|
||||
});
|
||||
if (client.devMode) {
|
||||
client.guilds.forEach(guild => {
|
||||
client.global.db.guilds[guild.id] = {
|
||||
prefix: client.config.prefix,
|
||||
defaultVolume: client.config.defaultVolume,
|
||||
permissions: client.config.permissions,
|
||||
dj: client.config.dj,
|
||||
djrole: client.config.djrole,
|
||||
startPlaying: client.config.startPlaying
|
||||
};
|
||||
});
|
||||
}
|
||||
console.log('- DB Set -');
|
||||
client.user.setActivity(`@${client.user.username} help | 🎶`, { type: 'LISTENING' });
|
||||
client.user.setStatus('dnd');
|
||||
const dbl = new DBL(client.config.DBLTOKEN, client);
|
||||
if (client.config.dblApi && !client.config.devMode) {
|
||||
dbl.on('error', error => {
|
||||
console.log('Error with DBL: ' + error);
|
||||
})
|
||||
dbl.postStats(client.guilds.size);
|
||||
}
|
||||
console.log('- Activated -');
|
||||
setInterval(async () => {
|
||||
if (client.config.saveDB && !client.config.devMode) {
|
||||
client.guilds.forEach(guild => {
|
||||
client.db.collection('guilds').doc(guild.id).set({
|
||||
prefix: client.global.db.guilds[guild.id].prefix,
|
||||
defaultVolume: client.global.db.guilds[guild.id].defaultVolume,
|
||||
permissions: client.global.db.guilds[guild.id].permissions,
|
||||
premium: client.global.db.guilds[guild.id].premium,
|
||||
dj: client.global.db.guilds[guild.id].dj,
|
||||
djrole: client.global.db.guilds[guild.id].djrole,
|
||||
startPlaying: client.global.db.guilds[guild.id].startPlaying
|
||||
});
|
||||
});
|
||||
}
|
||||
if (client.config.dblApi && !client.config.devMode) dbl.postStats(client.guilds.size);
|
||||
}, 1800000);
|
||||
setInterval(() => {
|
||||
client.funcs.ffmpeg(client, Discord);
|
||||
}, 7200000);
|
||||
}
|
||||
}
|
13
src/events/voiceStateUpdate.js
Normal file
13
src/events/voiceStateUpdate.js
Normal file
@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
name: 'voiceStateUpdate',
|
||||
async execute(client, newMember) {
|
||||
const serverQueue = client.queue.get(newMember.guild.id);
|
||||
if (!serverQueue) return;
|
||||
if (newMember === client.user) {
|
||||
if (newMember.voice.channel !== serverQueue.voiceChannel) {
|
||||
serverQueue.voiceChannel = newMember.voice.channel;
|
||||
console.log(`Changed serverQueue voiceChannel since Musix was moved to a different channel!`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user