Skip to content

Instantly share code, notes, and snippets.

@rpsirois
Last active May 21, 2019 09:17
Show Gist options
  • Save rpsirois/57daed67fc070bf2e858f6113421936d to your computer and use it in GitHub Desktop.
Save rpsirois/57daed67fc070bf2e858f6113421936d to your computer and use it in GitHub Desktop.
const Discord = require("discord.js");
const client = new Discord.Client();
client.login('');
client.on('ready', () => {
console.log(Logged in as $ {
client.user.tag
}!);
client.user.setActivity('DCS World', {
type: 'PLAYING'
})
.catch(console.error)
});
client.on('message', function(msg) {
if (msg.author.bot) return
if (msg.content.startsWith('!online')) {
const onlineUsers = msg.guild.members.filter(member => member.presence.game == 'DCS World').array()
var messageText = onlineUsers.length > 0 ? onlineUsers.map(member => member.displayName).join(', ') : 'No online users found right now.'
msg.channel.send({
embed: {
"title": "Online Users - DCS World",
"color": 53380,
"footer": {
"text": onlineUsers.length + " online users",
"icon_url": "https://i.imgur.com/Thhs8Ky.png"
},
"thumbnail": {
"url": "https://i.imgur.com/3Mfxuzf.jpg"
},
"description": messageText
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment