import { Guild } from 'discord.js' ; import { Lang , Logger } from '../services' ; import { ClientUtils , MessageUtils } from '../utils' ; import { EventHandler } from './event-handler' ; let Logs = require ( '../../lang/logs.json' ) ; export class GuildJoinHandler implements EventHandler { public async process ( guild ) { Logger . info ( Logs . info . guildJoined . replaceAll ( '{GUILD_NAME}' , guild . name ) . replaceAll ( '{GUILD_ID}' , guild . id ) ) ; let guildLang = Lang . Default ; let notifyChannel = await ClientUtils . findNotifyChannel ( guild , guildLang ) ; if ( notifyChannel ) { await MessageUtils . send ( notifyChannel , Lang . getEmbed ( 'displayEmbeds.welcome' , guildLang ) . setAuthor ( { name : guild . name , iconURL : guild . iconURL ( ) , } ) ) ; } let ownerLang = Lang . Default ; let owner = await guild . fetchOwner ( ) ; if ( owner ) { await MessageUtils . send ( owner . user , Lang . getEmbed ( 'displayEmbeds.welcome' , ownerLang ) . setAuthor ( { name : guild . name , iconURL : guild . iconURL ( ) , } ) ) ; } } }