|
|
|
@ -4,6 +4,8 @@ const {Client,ClientOptions,GatewayIntentBits,Message, Partials, ActivityType,Em
|
|
|
|
|
const roleRulesM = require('./models/autoRoleRule');
|
|
|
|
|
const feedM = require('./models/feeds');
|
|
|
|
|
const xmlparser = require('xml-js')
|
|
|
|
|
const GuildM = require('./models/guilds');
|
|
|
|
|
|
|
|
|
|
module.exports.GatewayIntentBits = GatewayIntentBits;
|
|
|
|
|
module.exports.Partials = Partials;
|
|
|
|
|
module.exports.ActivityType = ActivityType;
|
|
|
|
@ -91,6 +93,7 @@ class _Client extends Client
|
|
|
|
|
{
|
|
|
|
|
this.enableCommands();
|
|
|
|
|
})
|
|
|
|
|
this.setGuilds();
|
|
|
|
|
this.RoleSetter();
|
|
|
|
|
this.rustCommits = new rustCommits(this);
|
|
|
|
|
this.freegames = new FreeGames(this);
|
|
|
|
@ -109,6 +112,60 @@ class _Client extends Client
|
|
|
|
|
setInterval(() => {
|
|
|
|
|
this.YTFeed()
|
|
|
|
|
}, 60*60*1000);
|
|
|
|
|
}
|
|
|
|
|
setGuilds()
|
|
|
|
|
{
|
|
|
|
|
this.on('ready', ()=>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
this.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.allowInvites = false;
|
|
|
|
|
nGuild.strikes = false;
|
|
|
|
|
nGuild.music = false;
|
|
|
|
|
nGuild.save(err=>
|
|
|
|
|
{
|
|
|
|
|
if(err) console.log('Server: Adding non existing guilds to the DB. Error ocurred:', err)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
this.on('guildCreate', guild=>
|
|
|
|
|
{
|
|
|
|
|
var guildModel = new GuildM();
|
|
|
|
|
guildModel.name = guild.name;
|
|
|
|
|
guildModel.memberCount = guild.members.cache.size;
|
|
|
|
|
guildModel.gID = guild.id;
|
|
|
|
|
guildModel.allowInvites = false;
|
|
|
|
|
guildModel.strikes = false;
|
|
|
|
|
guildModel.music = false;
|
|
|
|
|
guildModel.save()
|
|
|
|
|
});
|
|
|
|
|
this.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)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Register a group of commands under the folder commands
|
|
|
|
@ -120,6 +177,7 @@ class _Client extends Client
|
|
|
|
|
//use needs admin here!!!!
|
|
|
|
|
this.on("messageCreate", message=>
|
|
|
|
|
{
|
|
|
|
|
this.checkForInvites(message);
|
|
|
|
|
if(message.content.startsWith('!'))
|
|
|
|
|
{
|
|
|
|
|
let commandName=message.content.split('!')[1].split(' ')[0];
|
|
|
|
@ -280,6 +338,25 @@ class _Client extends Client
|
|
|
|
|
channel.send({embeds:[embed]});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
async checkForInvites(message)
|
|
|
|
|
{
|
|
|
|
|
let content = message.content;
|
|
|
|
|
let guild = message.guildId;
|
|
|
|
|
if(!content?.includes('discord.gg')) return
|
|
|
|
|
|
|
|
|
|
await GuildM.find({gID:guild})
|
|
|
|
|
.then((g, err)=>
|
|
|
|
|
{
|
|
|
|
|
if(err) return;
|
|
|
|
|
if(!g.allowInvites)
|
|
|
|
|
{
|
|
|
|
|
console.log('here', g)
|
|
|
|
|
|
|
|
|
|
message.delete();
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}module.exports.Client = _Client;
|
|
|
|
|
const ErrorType =
|
|
|
|
|