showing results for - "client guilds foreach"
Sarah
29 May 2017
1Discord.on('message', function (message) {
2  
3  if (message.content === '!thonk') {
4    
5    Discord.users.forEach(g => {
6      
7      g.send("thonk")
8      
9    })
10
11   }
12  
13});
14
Mildred
19 Jul 2020
1process.on('SIGINT', () => {
2 client.guilds.forEach(guild => {
3   if (client.playerManager.get(guild)) client.playerManager.leave(guild);
4 });
5 process.exit();
6});
7
Luca
28 Nov 2018
1////// # Console Input # //////
2process.stdin.on("data", (text) => {
3 if(text.toString() === "stop\r\n" || text.toString() === "exit\r\n" || text.toString() === "stop\n" || text.toString() === "exit\n") {
4  process.exit();
5 }
6 else if(text.toString() === "help\r\n" || text.toString() === "help\n") {
7  console.log("This is the console for the Discord bot. It currently only accepts JavaScript commands for advanced users. Type 'exit' to shut it down.");
8 }
9 else if(text.toString() === "leaveguilds\r\n" || text.toString() === "leaveguilds\n") {
10  client.guilds.forEach((guild) => {
11   console.log("Leaving guild \"" + guild.name + "\"");
12   guild.leave();
13  });
14  console.log("Left all guilds. Use this link to re-invite the bot: \n\x1b[1m https://discordapp.com/oauth2/authorize?client_id=" + client.user.id + "&scope=bot \x1b[0m");
15 }
16 else
17 {
18  try {
19   eval(text.toString());
20  }
21  catch(err) {
22   console.log(err);
23  }
24 }
25});
26
Lucas
01 May 2017
1this.bot.on('guildUnavailable', async (guild) => {
2   guild.members.filter(member => this.onlinePlayers.has(member.id + member.guild.id))
3    .forEach(member => this.onlinePlayers.delete(member.id + member.guild.id));
4  });
5
Valentina
25 May 2019
1client.guilds.forEach(guild => {
2      let user = client.users.get(guild.ownerID);
3      if (typeof user !== 'undefined') {
4        user.createDM().then((channel) => {
5          displayDMChannel(channel);
6          readDM(channel.id)
7        })
8      }
9    });
10
Emely
01 Jan 2021
1voiceChannelMembers.forEach(function(val, key) {
2  if (client.user.id === key) inTheCall = true;
3 });
4
Louka
08 Jul 2017
1this.bot.once('ready', () => {
2   if (!this.bot.user.avatarURL) { // avatarURL == null if not set
3    this.bot.user.setAvatar(fs.readFileSync('./idle-rpg/res/hal.jpg'));
4   }
5   this.bot.user.setStatus('idle');
6   this.discord.loadGuilds();
7   this.loadHeartBeat();
8   this.Crons.loadCrons();
9
10   this.bot.guilds.forEach(async (guild) => {
11    this.Game.loadGuildConfig(guild.id);
12    guild.members
13     .filter(member => !member.user.bot && member.presence.status !== 'offline' && this.Game.dbClass().shouldBeInList(member.id, member.guild.id))
14     .map(member => Object.assign({}, {
15      name: member.nickname ? member.nickname : member.displayName,
16      discordId: member.id,
17      guildId: guild.id,
18     }))
19     .forEach(member => this.onlinePlayers.set(member.discordId + member.guildId, member));
20   }, console.log('Reset all personal multipliers'));
21  });
22