|
|
|
@ -8,7 +8,7 @@ const mongoose = require('mongoose');
|
|
|
|
|
const port = process.env.PORT || 5000;
|
|
|
|
|
const {Client, GatewayIntentBits,Partials, ActivityType} = require('./lib.js');
|
|
|
|
|
const Spawner = require('child_process');
|
|
|
|
|
const guildsM = require('./models/guilds')
|
|
|
|
|
const GuildM = require('./models/guilds')
|
|
|
|
|
|
|
|
|
|
app.use(express.static(path.join(__dirname, "public")));
|
|
|
|
|
app.set("view engine", "ejs");
|
|
|
|
@ -66,13 +66,28 @@ bot.on('ready', () =>
|
|
|
|
|
status: 'online',
|
|
|
|
|
});
|
|
|
|
|
console.timeEnd('StartUp');
|
|
|
|
|
|
|
|
|
|
/* spawining a singe music worker for legendary
|
|
|
|
|
|
|
|
|
|
Spawner.fork('./musicWorker.js',['334456736633323520', 'Legendary'])
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
bot.guilds.cache.forEach(guild=>
|
|
|
|
|
{
|
|
|
|
|
GuildM.find({gID:guild.id})
|
|
|
|
|
.then(
|
|
|
|
|
(guild_,err)=>
|
|
|
|
|
{
|
|
|
|
|
if(err || guild_.length==0)
|
|
|
|
|
{
|
|
|
|
|
var nGuild = GuildM();
|
|
|
|
|
nGuild.name = guild.name;
|
|
|
|
|
nGuild.memberCount = guild.members.cache.size;
|
|
|
|
|
nGuild.gID = guild.id;
|
|
|
|
|
nGuild.strike = false;
|
|
|
|
|
nGuild.music = false;
|
|
|
|
|
nGuild.save(err=>
|
|
|
|
|
{
|
|
|
|
|
if(err) console.log('Server: Adding non existing guilds to the DB. Error ocurred:', err)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
music();
|
|
|
|
|
setInterval(() =>
|
|
|
|
|
{
|
|
|
|
@ -84,12 +99,24 @@ bot.on('ready', () =>
|
|
|
|
|
});
|
|
|
|
|
bot.on('guildCreate', guild=>
|
|
|
|
|
{
|
|
|
|
|
console.log('Added To guild', guild);
|
|
|
|
|
var guild = new GuildM()
|
|
|
|
|
var guildModel = new GuildM();
|
|
|
|
|
guildModel.name = guild.name;
|
|
|
|
|
guildModel.memberCount = guild.members.cache.size;
|
|
|
|
|
guildModel.gID = guild.id;
|
|
|
|
|
guildModel.strikes = false;
|
|
|
|
|
guildModel.music = false;
|
|
|
|
|
guildModel.save()
|
|
|
|
|
});
|
|
|
|
|
bot.on('guildDelete', guild =>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
GuildM.find({gID:guild.id}).then(guild=>
|
|
|
|
|
{
|
|
|
|
|
if(guild.length==0) return sendMessage(false, 'ID not on the list.')
|
|
|
|
|
GuildM.findOneAndRemove(guild.id, (err)=>
|
|
|
|
|
{
|
|
|
|
|
if(err) console.log('Server: Deleting guild from DB: There was an error:', err)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
async function music()
|
|
|
|
|
{
|
|
|
|
@ -141,5 +168,5 @@ function moveAFKs(){
|
|
|
|
|
|
|
|
|
|
async function serversWithMusicOn()
|
|
|
|
|
{
|
|
|
|
|
return await guildsM.find({music:true}).then(g=>{return g})
|
|
|
|
|
return await GuildM.find({music:true}).then(g=>{return g})
|
|
|
|
|
}
|