Skip to content

Instantly share code, notes, and snippets.

@icy-r
Last active November 3, 2024 02:33
Show Gist options
  • Select an option

  • Save icy-r/739ef5afdee4333e4dd6f9f02b65f785 to your computer and use it in GitHub Desktop.

Select an option

Save icy-r/739ef5afdee4333e4dd6f9f02b65f785 to your computer and use it in GitHub Desktop.
const { bot, getRandom, getBuffer } = require('../lib/')
let isOn = 'off'
let timer
let keywords,time
bot(
{
pattern: 'aprofile ?(.*)',
fromMe: true,
desc: 'Change your profile automatically',
type: 'misc',
},
async (message, match) => {
if (!match) {
if (isOn === 'on') return await message.send(`*already on* \n
*keyword: ${keywords}* \n
*time: ${time}* \n`)
return await message.send(
'Please specify a profile name,time in minutes\n*example: .aprofile cat, car, house, 5*'
)
}
if (match === 'off') {
isOn = 'off'
if (timer) clearInterval(timer)
return await message.send('Turned off')
}
isOn = 'on'
if(keywords)
{
keywords.push(match.split(',').filter((word) => isNaN(word)))
time = match.split(',').pop()
}
if(!keywords){
keywords = match.split(',').filter((word) => isNaN(word))
time = match.split(',').pop()
if (isNaN(time))
return await message.send(
'Please specify a time in minutes\n*example: .aprofile cat, car, house, 5*'
)
if (time < 3)
return await message.send(
'Please specify a time in minutes more that 3 minutes\n*example: .aprofile cat, car, house, 5*'
)
async function updateProfilePic() {
const randomnum = getRandom(keywords)
const unsplashUrl = `https://source.unsplash.com/460x700/?${randomnum}`
const { buffer } = await getBuffer(unsplashUrl)
if (buffer) await message.updateProfilePicture(buffer, message.client.user.jid)
//await message.send(`changed profile...${time} , ${keywords}`)
}
if(!keywords)
return message.send('Please specify a profile name,time in minutes\n*example: .aprofile cat, car, house, 5*')
await updateProfilePic()
await message.send(`changed profile...${time} , ${keywords}`)
timer = setInterval(updateProfilePic, time * 1000 * 60)
}
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment