title: fetch all members of a server inside a funtion | property members undefined | package: discord-giveaways
body: <p>So i am using the package "discord-giveaways" and i want to use the "exemptMembers" option which is a function and with which i can set who is not allowed to take part in a giveaway and i want that people who haven't joined a specific server cannot take part but i am not sure if coded that right and also there is the error: <code>TypeError: Cannot read property 'members' of undefined</code> that i don't really know to fix, so it would be nice if someone can say me what i did wrong.</p>
  
  <pre><code>var server = require('./commands/giveaway/start-giveaway.js')
  let guild = client.guilds.cache.get(server)
  
  // Init discord giveaways
  const { GiveawaysManager } = require('discord-giveaways');
  client.giveawaysManager = new GiveawaysManager(client, {
      storage: "./giveaways.json",
      updateCountdownEvery: 5000,
      default: {
          botsCanWin: false,
          embedColor: "0x0099ff",
          embedColorEnd: "ff0000",
          reaction: "",
          exemptMembers: !guild.members.fetch()
      }
  });
  </code></pre>
  
  <p>If the function returns true then the member should not be able to take part in the giveaway: <code>exemptMembers: !guild.members.fetch()</code></p>
  
  <p>Please don't roast me to hard if i did it completely wrong .</p>
  
  <p>The "start-giveaway" file:</p>
  
  <pre><code>run : async (message, client, args) =&gt; {
          const ms = require('ms');
  
  
              // Giveaway channel
              let giveawayChannel = message.mentions.channels.first();
              // If no channel is mentionned
              if(!giveawayChannel){
                  return message.channel.send(':x: You have to mention a valid channel!');
              }
  
              // Giveaway duration
              let giveawayDuration = args[1];
              // If the duration isn't valid
              if(!giveawayDuration || isNaN(ms(giveawayDuration))){
                  return message.channel.send(':x: You have to specify a valid duration!');
              }
  
              // Number of winners
              let giveawayNumberWinners = args[2];
              // If the specified number of winners is not a number
              if(isNaN(giveawayNumberWinners)){
                  return message.channel.send(':x: You have to specify a valid number of winners!');
              }
  
              // Require members to join a server if author does not say "no"
              if (args[3] !== 'no'){
                  var server = args[3]
                  console.log(server)
  
                  if(!server){
                      return message.channel.send(':x: You habe to specify a valid server ID or say "no"')
                  }
              }
              else {
                  console.log('User sayed no')
              }
  
              // Giveaway prize
              let giveawayPrize = args.slice(4).join(' ');
              // If no prize is specified
              if(!giveawayPrize){
                  return message.channel.send(':x: You have to specify a valid prize!');
              }
  
              // Start the giveaway
              client.giveawaysManager.start(giveawayChannel, {
                  // The giveaway duration
                  time: ms(giveawayDuration),
                  // The giveaway prize
                  prize: giveawayPrize,
                  // The giveaway winner count
                  winnerCount: giveawayNumberWinners,
                  // Who hosts this giveaway
                  hostedBy: true ? message.author : null,
                  // Messages
                  messages: {
                      giveaway: " **GIVEAWAY** ",
                      giveawayEnded: " **GIVEAWAY ENDED** ",
                      timeRemaining: "Time remaining: **{duration}**!",
                      inviteToParticipate: "React with  to participate!",
                      winMessage: "Congratulations, {winners}! You won **{prize}**!",
                      embedFooter: "Giveaways",
                      noWinner: "Giveaway cancelled, no valid participations.",
                      hostedBy: "Hosted by: {user}",
                      winners: "winner(s)",
                      endedAt: "Ended at",
                      units: {
                          seconds: "seconds",
                          minutes: "minutes",
                          hours: "hours",
                          days: "days",
                          weeks: "weeks",
                          months: "months",
                          pluralS: false // Not needed, because units end with a S so it will automatically removed if the unit value is lower than 2
                      }
                  }
              })
              message.channel.send(`Giveaway started in ${giveawayChannel}!`);
  
      }
  </code></pre>