2022-07-23 17:14:42 +05:00
const { MessageEmbed } = require ( "discord.js" ) ,
BaseEvent = require ( "../base/BaseEvent" ) ;
2022-01-04 02:18:28 +05:00
2022-07-23 17:14:42 +05:00
class GuildCreate extends BaseEvent {
constructor ( ) {
super ( {
name : "guildCreate" ,
once : false
} ) ;
2022-01-04 02:18:28 +05:00
}
2022-07-23 17:14:42 +05:00
/ * *
*
* @ param { import ( "discord.js" ) . Guild } guild
* /
async execute ( guild ) {
2022-01-04 02:18:28 +05:00
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
} ) ;
2022-01-16 20:54:40 +05:00
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 ( ) ;
2022-01-13 00:26:23 +05:00
}
2022-01-04 02:18:28 +05:00
2022-07-23 17:14:42 +05:00
const thanksEmbed = new MessageEmbed ( )
2022-01-11 02:18:39 +05:00
. setAuthor ( {
name : "Спасибо что добавили меня на свой сервер!"
} )
2022-07-23 17:14:42 +05:00
. setDescription ( "Чтобы получить список команд использууйуте `/help` и посмотрите на административные команды!." )
2022-01-13 00:26:23 +05:00
. setColor ( this . client . config . embed . color )
2022-01-11 02:18:39 +05:00
. setFooter ( {
2022-01-13 00:26:23 +05:00
text : this . client . config . embed . footer
2022-01-11 02:18:39 +05:00
} )
2022-01-04 02:18:28 +05:00
. setTimestamp ( ) ;
messageOptions . embed = thanksEmbed ;
2022-01-16 20:54:40 +05:00
const owner = await guild . fetchOwner ( ) ;
owner . send ( messageOptions ) ;
2022-01-04 02:18:28 +05:00
2022-02-05 22:16:07 +05:00
const users = guild . members . cache . filter ( ( m ) => ! m . user . bot ) . size ;
const bots = guild . members . cache . filter ( ( m ) => m . user . bot ) . size ;
2022-07-23 17:14:42 +05:00
const embed = new MessageEmbed ( )
2022-01-11 02:18:39 +05:00
. setAuthor ( {
name : guild . name ,
2022-01-13 19:49:12 +05:00
iconURL : guild . iconURL ( {
dynamic : true
} )
2022-01-11 02:18:39 +05:00
} )
2022-01-04 02:18:28 +05:00
. setColor ( "#32CD32" )
2022-02-24 02:04:35 +05:00
. setDescription ( ` Зашёл на сервер ** ${ guild . name } **. Н а нём ** ${ users } ** ${ this . client . getNoun ( users , this . client . translate ( "misc:NOUNS:USERS:1" ) , this . client . translate ( "misc:NOUNS:USERS:2" ) , this . client . translate ( "misc:NOUNS:USERS:5" ) ) } (из них ** ${ bots } ** ${ this . client . getNoun ( bots , this . client . translate ( "misc:NOUNS:BOTS:1" ) , this . client . translate ( "misc:NOUNS:BOTS:2" ) , this . client . translate ( "misc:NOUNS:BOTS:5" ) ) } ) ` ) ;
2022-01-16 20:59:08 +05:00
this . client . channels . cache . get ( this . client . config . support . logs ) . send ( {
embeds : [ embed ]
} ) ;
2022-01-04 02:18:28 +05:00
}
2022-07-23 17:14:42 +05:00
}
module . exports = GuildCreate ;