2022-07-31 17:08:00 +05:00
const { EmbedBuilder } = require ( "discord.js" ) ,
2022-07-26 17:20:10 +05:00
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" ,
2022-12-15 21:02:38 +05:00
once : false ,
2022-07-23 17:14:42 +05:00
} ) ;
2022-01-04 02:18:28 +05:00
}
2022-07-23 17:14:42 +05:00
/ * *
*
2022-08-02 17:18:47 +05:00
* @ param { import ( "../../base/JaBa" ) } client
2022-07-23 17:14:42 +05:00
* @ param { import ( "discord.js" ) . Guild } guild
* /
2022-08-02 17:18:47 +05:00
async execute ( client , guild ) {
2023-10-30 21:45:10 +05:00
const userData = await client . findOrCreateUser ( guild . ownerId ) ;
2022-01-16 20:54:40 +05:00
2022-01-04 02:18:28 +05:00
if ( ! userData . achievements . invite . achieved ) {
2023-06-27 21:19:55 +05:00
userData . achievements . invite . progress . now = 1 ;
2022-01-04 02:18:28 +05:00
userData . achievements . invite . achieved = true ;
2023-09-25 21:42:43 +05:00
2023-10-30 21:45:10 +05:00
userData . markModified ( "achievements" ) ;
2022-01-04 02:18:28 +05:00
await userData . save ( ) ;
2022-01-13 00:26:23 +05:00
}
2022-01-04 02:18:28 +05:00
2023-03-26 18:31:19 +05:00
const thanks = new EmbedBuilder ( )
2022-01-11 02:18:39 +05:00
. setAuthor ( {
2023-06-27 21:19:55 +05:00
name : "Thanks for inviting me to your server!" ,
2022-01-11 02:18:39 +05:00
} )
2023-06-27 21:19:55 +05:00
. setDescription ( "Use </help:1029832476077596773> in your server to get list of all commands!." )
2022-08-02 17:18:47 +05:00
. setColor ( client . config . embed . color )
2023-07-07 21:13:11 +05:00
. setFooter ( client . config . embed . footer )
2022-01-04 02:18:28 +05:00
. setTimestamp ( ) ;
2022-01-16 20:54:40 +05:00
const owner = await guild . fetchOwner ( ) ;
2023-03-26 18:31:19 +05:00
owner . send ( {
2023-07-05 00:58:06 +05:00
files : [
{
name : "unlocked.png" ,
attachment : "./assets/img/achievements/achievement_unlocked7.png" ,
} ,
] ,
2023-03-26 18:31:19 +05:00
embeds : [ thanks ] ,
} ) ;
2022-01-04 02:18:28 +05:00
2022-08-26 00:21:26 +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-02-05 22:16:07 +05:00
2022-07-31 17:08:00 +05:00
const embed = new EmbedBuilder ( )
2022-01-11 02:18:39 +05:00
. setAuthor ( {
name : guild . name ,
2022-12-15 21:02:38 +05:00
iconURL : guild . iconURL ( ) ,
2022-01-11 02:18:39 +05:00
} )
2023-07-03 19:30:47 +05:00
. setColor ( client . config . embed . color )
2023-07-07 21:13:11 +05:00
. setFooter ( client . config . embed . footer )
2023-04-20 11:47:47 +05:00
. setDescription ( ` Зашёл на сервер ** ${ guild . name } **. Н а нём ** ${ users } ** ${ client . functions . getNoun ( users , client . translate ( "misc:NOUNS:USERS:1" ) , client . translate ( "misc:NOUNS:USERS:2" ) , client . translate ( "misc:NOUNS:USERS:5" ) ) } и ** ${ bots } ** ${ client . functions . getNoun ( bots , client . translate ( "misc:NOUNS:BOTS:1" ) , client . translate ( "misc:NOUNS:BOTS:2" ) , client . translate ( "misc:NOUNS:BOTS:5" ) ) } ` ) ;
2022-08-02 17:18:47 +05:00
client . channels . cache . get ( client . config . support . logs ) . send ( {
2022-12-15 21:02:38 +05:00
embeds : [ embed ] ,
2022-01-16 20:59:08 +05:00
} ) ;
2022-01-04 02:18:28 +05:00
}
2022-07-23 17:14:42 +05:00
}
2023-07-05 00:58:06 +05:00
module . exports = GuildCreate ;