2021-12-10 21:39:54 +05:00
const Discord = require ( "discord.js" ) ;
module . exports = class {
2021-12-26 19:29:37 +05:00
constructor ( client ) {
2021-12-10 21:39:54 +05:00
this . client = client ;
}
2021-12-26 19:29:37 +05:00
async run ( guild ) {
2021-12-10 21:39:54 +05:00
if ( this . client . config . proMode ) {
if ( ( ! this . client . config . proUsers . includes ( guild . ownerID ) || this . guilds . filter ( ( g ) => g . ownerID === guild . ownerID ) > 1 ) && guild . ownerID !== this . client . config . owner . id ) {
2021-12-22 16:50:28 +05:00
this . client . logger . log ( ` ${ guild . ownerID } tried to invite JaBa on its server. ` ) ;
2021-12-10 21:39:54 +05:00
return guild . leave ( ) ;
} ;
} ;
const messageOptions = { } ;
2021-12-26 19:29:37 +05:00
const userData = await this . client . findOrCreateUser ( {
id : guild . ownerID
} ) ;
2021-12-10 21:39:54 +05:00
if ( ! userData . achievements . invite . achieved ) {
userData . achievements . invite . progress . now += 1 ;
userData . achievements . invite . achieved = true ;
2021-12-26 19:29:37 +05:00
messageOptions . files = [ {
name : "unlocked.png" ,
attachment : "./assets/img/achievements/achievement_unlocked7.png"
} ] ;
2021-12-10 21:39:54 +05:00
userData . markModified ( "achievements.invite" ) ;
await userData . save ( ) ;
} ;
const thanksEmbed = new Discord . MessageEmbed ( )
2021-12-21 00:37:20 +05:00
. setAuthor ( "Спасибо что добавили меня на свой сервер!" )
. setDescription ( ` Для настроек используйте \` ${ this . client . config . prefix } help \` и посмотрите на административные команды! \n Чтобы изменить язык используйте \` ${ this . client . config . prefix } setlang [язык] \` . ` )
2021-12-10 21:39:54 +05:00
. setColor ( this . client . config . embed . color )
. setFooter ( this . client . config . embed . footer )
. setTimestamp ( ) ;
messageOptions . embed = thanksEmbed ;
guild . owner . send ( messageOptions ) . catch ( ( ) => { } ) ;
const text = ` Зашёл на сервер ** ${ guild . name } **. Н а нём ** ${ guild . members . cache . filter ( ( m ) => ! m . user . bot ) . size } ** пользователей (из них ${ guild . members . cache . filter ( ( m ) => m . user . bot ) . size } ботов) ` ;
// Sends log embed in the logs channel
const logsEmbed = new Discord . MessageEmbed ( )
. setAuthor ( guild . name , guild . iconURL ( ) )
. setColor ( "#32CD32" )
. setDescription ( text ) ;
this . client . channels . cache . get ( this . client . config . support . logs ) . send ( logsEmbed ) ;
}
} ;