title: discord.js how to find all users assigned @everyone when bot is brought online in server
body: <p>I am having trouble attempting to find users assigned to @everyone when I bring the bot online in my server. I can do it via commands in my discord server, however, when trying to do it automatically, I get the error:</p>
  <p>Cannot read properties of undefined (reading 'roles')</p>
  <p>Here is my code:</p>
  <pre><code>const Discord = require('discord.js');
  
  const client = new Discord.Client({ intents: [&quot;GUILDS&quot;, &quot;GUILD_MESSAGES&quot;] });
  
  const prefix = '-';
  
  const fs = require('fs');
  
  client.commands = new Discord.Collection();
  
  const commandFiles = fs.readdirSync('./commands/').filter(file =&gt; file.endsWith('.js'));
  for(const file of commandFiles){
      const command = require(`./commands/${file}`);
      client.commands.set(command.name, command);
  }
  
  client.once('ready', (message) =&gt; {
      console.log('Bot is online!');
      client.commands.get('find').execute(message);
  });
  </code></pre>
  <pre><code>module.exports = {
      name: 'find',
      description: &quot;&quot;,
      execute(message){
  
          const role = message.guild.roles.cache.find(role =&gt; role.name === &quot;@everyone&quot;);
  
          console.log('complete')
      }
  }
  </code></pre>
  <p>How do I find all the members assigned @everyone when my bot goes online instead of having to type a command in my discord server?</p>