welcome.js 1.1 KB

12345678910111213141516171819202122232425
  1. const fs = require('fs-extra')
  2. module.exports = welcome = async (client, event) => {
  3. //console.log(event.action)
  4. const welkom = JSON.parse(fs.readFileSync('./lib/welcome.json'))
  5. const isWelkom = welkom.includes(event.chat)
  6. try {
  7. if (event.action == 'add' && isWelkom) {
  8. const gChat = await client.getChatById(event.chat)
  9. const pChat = await client.getContact(event.who)
  10. const { contact, groupMetadata, name } = gChat
  11. const pepe = await client.getProfilePicFromServer(event.who)
  12. const capt = `Halo member baru👋, Welcome to group *${name}* selamat bergabung dan juga semoga betah disini.`
  13. if (pepe == '' || pepe == undefined) {
  14. await client.sendFileFromUrl(event.chat, 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcTQcODjk7AcA4wb_9OLzoeAdpGwmkJqOYxEBA&usqp=CAU', 'profile.jpg', capt)
  15. } else {
  16. await client.sendFileFromUrl(event.chat, pepe, 'profile.jpg', capt)
  17. }
  18. }
  19. } catch (err) {
  20. console.log(err)
  21. }
  22. }