2022-01-04 02:18:28 +05:00
const Discord = require ( "discord.js" ) ;
module . exports = class {
constructor ( client ) {
this . client = client ;
}
async run ( guild ) {
if ( this . client . config . proMode ) {
2022-01-05 00:24:57 +05:00
if ( ( ! this . client . config . proUsers . includes ( guild . ownerId ) || this . guilds . filter ( ( g ) => g . ownerId === guild . ownerId ) > 1 ) && guild . ownerId !== this . client . config . owner . id ) {
this . client . logger . log ( ` ${ guild . ownerId } tried to invite JaBa on its server. ` ) ;
2022-01-04 02:18:28 +05:00
return guild . leave ( ) ;
} ;
} ;
const messageOptions = { } ;
const userData = await this . client . findOrCreateUser ( {
2022-01-05 00:24:57 +05:00
id : guild . ownerId
2022-01-04 02:18:28 +05:00
} ) ;
if ( ! userData . achievements . invite . achieved ) {
userData . achievements . invite . progress . now += 1 ;
userData . achievements . invite . achieved = true ;
messageOptions . files = [ {
name : "unlocked.png" ,
attachment : "./assets/img/achievements/achievement_unlocked7.png"
} ] ;
userData . markModified ( "achievements.invite" ) ;
await userData . save ( ) ;
} ;
const thanksEmbed = new Discord . MessageEmbed ( )
2022-01-11 02:18:39 +05:00
. setAuthor ( {
name : "Спасибо что добавили меня на свой сервер!"
} )
2022-01-05 00:24:57 +05:00
. setDescription ( ` Для настроек используйте \` ${ data . config . prefix } help \` и посмотрите на административные команды! \n Чтобы изменить язык используйте \` ${ this . client . config . prefix } setlang [язык] \` . ` )
. setColor ( data . config . embed . color )
2022-01-11 02:18:39 +05:00
. setFooter ( {
text : data . config . embed . footer
} )
2022-01-04 02:18:28 +05:00
. 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 } ботов) ` ;
const logsEmbed = new Discord . MessageEmbed ( )
2022-01-11 02:18:39 +05:00
. setAuthor ( {
name : guild . name ,
iconURL : guild . iconURL ( )
} )
2022-01-04 02:18:28 +05:00
. setColor ( "#32CD32" )
. setDescription ( text ) ;
2022-01-05 00:24:57 +05:00
this . client . channels . cache . get ( data . config . support . logs ) . send ( logsEmbed ) ;
2022-01-04 02:18:28 +05:00
}
} ;