module.exports = async (msg,arg)=>{
const guildid = msg.guild.id
const guild =msg.guild
const display = msg.guild.channels.cache.find(ch => ch.name=='Total Members')
if(!display){
try {
const channelName='Total Members'
await msg.guild.channels.create(channelName, {
type: "voice", //This create a text channel, you can make a voice one too, by changing "text" to "voice"
permissionOverwrites: [
{
id: msg.guild.roles.everyone, //To make it be seen by a certain role, user an ID instead
allow: ['VIEW_CHANNEL'], //Allow permissions
deny: [ 'SEND_MESSAGES','CONNECT'] //Deny permissions
}
],
})
msg.channel.send('Successfully created the Channel ')
}
catch (error){console.log(error)
msg.channel.send('Couldnt create one ')}
}
const display1 = await msg.guild.channels.cache.find(ch => ch.name=='Total Members')
const display1id = await msg.guild.channels.cache.get(display1.id)
setInterval((guild)=>{
const count = msg.guild.memberCount
const channel = msg.guild.channels.cache.get(display1id)
channel.setName(`Total Members: ${count.toLocaleString()}`);
console.log('Updating Member Count');
},5000)
}
The error:
const display1id = await msg.guild.channels.cache.get(display1.id)
TypeError: Cannot read property 'id' of undefined
Can anyone tell me how to solve this error, basically this code helps to see the current member of the guild and it will autoupdate it. It will create a voice channel if it didn't found any one for showing the member.