1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-11-10 02:00:20 +00:00
This commit is contained in:
MatteZ02 2020-03-13 22:31:04 +02:00
parent 34a5d26829
commit d8ec0be2c9
12 changed files with 35 additions and 49 deletions

2
bot.js Normal file
View File

@ -0,0 +1,2 @@
const MusicClient = require('./struct/client.js');
const client = new MusicClient({});

View File

@ -21,7 +21,7 @@ module.exports = {
const embed = new Discord.MessageEmbed()
.setTitle(client.messages.queueTitle)
.setDescription(`${message}\n${queuemessage}`)
.setFooter(`${serverQueue.songs.size - 20} ${client.messages.queueFooter}`)
.setFooter(`${serverQueue.songs.length} ${client.messages.queueFooter}`)
.setColor(client.config.embedColor)
/*if (serverQueue.songs.size > 20) {
embed.setFooter(`${serverQueue.songs.size - 20} ${client.messages.queueFooter}`)

View File

@ -1,30 +0,0 @@
const fs = require('fs');
const path = require('path')
module.exports = {
name: 'reload',
alias: 'none',
usage: '',
description: 'Reload all files',
onlyDev: true,
permission: 'none',
category: 'util',
async execute(msg, args, client, Discord, prefix, command) {
const commandFiles = fs.readdirSync(path.join(path.dirname(__dirname), 'commands')).filter(f => f.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./${file}`);
command.uses = 0;
client.commands.set(command.name, command);
client.commandAliases.set(command.alias, command);
}
const settingFiles = fs.readdirSync(path.join(path.dirname(__dirname), 'commands/settings')).filter(f => f.endsWith('.js'));
for (const file of settingFiles) {
const option = require(`./settings/${file}`);
client.settingCmd.set(option.name, option);
}
/*fs.readdirSync(path.join(__dirname, 'funcs')).forEach(filename => {
this.funcs[filename.slice(0, -3)] = require(`../struct/funcs/${filename}`);
});*/
msg.channel.send(client.messages.reloaded);
}
};

View File

@ -2,13 +2,11 @@ module.exports = {
name: 'restart',
alias: 'none',
usage: '',
description: 'Restart the bot',
description: 'restart all shards',
onlyDev: true,
permission: 'none',
permission: 'dev',
category: 'util',
async execute(msg, args, client, Discord, prefix, command) {
client.destroy();
require('../index.js');
msg.channel.send(client.messages.restart);
client.shard.respawnAll(client.config.shardDelay, client.config.respawnDelay, client.config.spawnTimeout);
}
};

View File

@ -16,6 +16,7 @@ module.exports = {
.addField(client.messages.statusField1, client.ws.ping, true)
.addField(client.messages.statusField2, latency, true)
.addField(client.messages.statusField3, uptime, true)
.addField(client.messages.statusField4, client.shard.ids)
.setAuthor(client.user.username, client.user.displayAvatarURL)
.setColor(client.config.embedColor)
m.delete();

View File

@ -2,6 +2,7 @@ module.exports = {
name: 'message',
async execute(client, msg, Discord) {
if (msg.author.bot || !msg.guild) return;
if (!client.global.db.guilds[msg.guild.id]) return;
let prefix = client.global.db.guilds[msg.guild.id].prefix;
if (client.config.devMode) prefix = client.config.devPrefix;
const args = msg.content.slice(prefix.length).split(' ');

View File

@ -23,7 +23,7 @@ module.exports = {
};
});
}
console.log('- DB Set -');
console.log(`- DB Set - Shard: ${client.shard.ids} -`);
client.user.setActivity(`@${client.user.username} help | 🎶`, { type: 'LISTENING' });
client.user.setStatus('online');
const dbl = new DBL(client.config.dblKey, client);
@ -36,7 +36,7 @@ module.exports = {
});
dbl.postStats(client.guilds.size);
}
console.log('- Activated -');
console.log(`- Activated - Shard: ${client.shard.ids} -`);
setInterval(async () => {
if (client.config.saveDB && !client.config.devMode) {
console.log('DB saved');

View File

@ -1,2 +1,13 @@
const MusicClient = require('./struct/client.js');
const client = new MusicClient({});
const config = require("./struct/config/config.js");
if (config.devMode) {
config.token = config.devToken;
config.shards = 1;
}
const { ShardingManager } = require('discord.js');
const manager = new ShardingManager('./bot.js', { token: config.token, respawn: true, totalShards: config.shards });
console.log('Launching shards...');
manager.spawn(config.shards, config.shardDelay, config.shardTimeout);
manager.on('shardCreate', shard => console.log(`Launched shard ${shard.id}`));

View File

@ -38,6 +38,9 @@ module.exports = class extends Client {
const option = require(`../commands/settings/${file}`);
this.settingCmd.set(option.name, option);
}
if (this.config.devMode) {
this.config.token = this.config.devToken;
}
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
@ -53,10 +56,6 @@ module.exports = class extends Client {
this.db.FieldValue = require('firebase-admin').firestore.FieldValue;
if (this.config.devMode) {
this.config.token = this.config.devToken;
}
this.on('ready', () => {
require(`${events}ready`).execute(this, Discord);
});
@ -70,7 +69,7 @@ module.exports = class extends Client {
require(`${events}voiceStateUpdate`).execute(this, oldState, newState);
});
this.on('error', (error) => {
client.channels.fetch(client.config.debug_channel).send('Error: ' + error);
client.channels.fetch(client.config.debug_channel).send(`Error: ${error} on shard: ${this.shard}`);
});
this.login(this.config.token).catch(err => console.log('Failed to login: ' + err));

View File

@ -11,13 +11,16 @@ module.exports = {
primary_test_channel: "617633098296721409",
secondary_test_channel: "570531724002328577",
devId: "360363051792203779",
//misc
embedColor: "#b50002",
invite: "https://discordapp.com/api/oauth2/authorize?client_id=607266889537945605&permissions=3427328&redirect_uri=https%3A%2F%2Fdiscordapp.com%2Foauth2%2Fauthorize%3Fclient_id%3D607266889537945605%26%3Bscope%3Dbot%26%3Bpermissions%3D0&scope=bot",
//Settings
devMode: false,
devMode: true,
dblApi: false,
saveDB: true,
shards: 8,
shardDelay: 5000,
spawnTimeout: 30000,
respawnDelay: 1000,
//db values
prefix: ">",
devPrefix: "-",

View File

@ -91,7 +91,7 @@ module.exports = {
reloaded: "All files reloaded!",
removed: "🗑 removed `%SONG%` from the queue!",
reset: "<:green_check_mark:674265384777416705> Reset __all__ guild settings!",
restart: "restarted!",
restart: "restarting all shards...",
resumed: "<:resume:674685585478254603> Resumed the music!",
seekingPointPositive: "<:redx:674263474704220182> The seeking point needs to be a positive number!",
seekMax: "<:redx:674263474704220182> The lenght of this song is %LENGTH% seconds! You can't seek further than that!",
@ -118,6 +118,7 @@ module.exports = {
statusField1: ":signal_strength: Ping",
statusField2: "Latency",
statusField3: ":stopwatch: Uptime",
statusField4: "Shard: ",
statusTitle: "Status for Musix",
stop: "<:stop:674685626108477519> Stopped the music!",
validNumber: "<:redx:674263474704220182> I'm sorry, But you need to enter a valid __number__.",

View File

@ -11,7 +11,7 @@ module.exports = function (msg, args, client, Discord, prefix, command) {
const embed = new Discord.MessageEmbed()
.setTitle(`Musix ${error.toString()}`)
.setDescription(error.stack.replace(/at /g, '**at **'))
.setFooter(`guild: ${msg.guild.id}, user: ${msg.member.id}, channel: ${msg.channel.id}, date: ${date}`)
.setFooter(`guild: ${msg.guild.id} (${msg.guild.name}), user: ${msg.member.id} (${msg.member.displayName}), channel: ${msg.channel.id} (${msg.channel.name}), date: ${date}, Shard: ${client.shard.ids}`)
.setColor('#b50002');
client.debug_channel.send(embed);
console.error(error);