Answers for "user info command discord.js"

2

discord.js user info

if(!args[0]){
  var user = message.author;
} else var user = message.mentions.users.first()
         
const member = message.guild.member(user);

    const activities = [];
    for (const activity of user.presence.activities.values()) {
      switch (activity.type) {
        case 'PLAYING':
          activities.push(`Playing **${activity.name}**`);
          break;
        case 'LISTENING':
          if (user.bot) activities.push(`Listening to **${activity.name}**`);
          else activities.push(`Listening to **${activity.details}** by **${activity.state}**`);
          break;
        case 'WATCHING':
          activities.push(`Watching **${activity.name}**`);
          break;
        case 'STREAMING':
          activities.push(`Streaming **${activity.name}**`);
          break;
        case 'CUSTOM_STATUS':
          customStatus = activity.state;
          break;
      }}





  const infoEmbed = new Discord.MessageEmbed()
  .setColor("BLUE")
  .setTitle(`${user.username}'s Information`)
  .setDescription(`Info from ${message.guild.name}`)
  .setThumbnail(user.avatarURL({dynamic: true}))
  .setFooter('requested')
  .setTimestamp()
  .addFields(
      { 
          name: "User Info",
          value: "```Username:"+user.username+"\nDiscriminator: #"+user.discriminator+"\nTag: "+user.tag+"\nServer Nickname: "+member.displayName+"\nIs Bot: "+user.bot+"\nID: "+user.id+" ```",
          inline: true
      },
      {
          name: `Status`,
          value: "```"+user.presence.status+"\n"+activities+"```",
          inline: false
      },
      {
          name: `Member Info`,
          value: "```Joined Server: "+new Date(user.joinedAt).toLocaleDateString()+"\nJoined Discord: "+new Date(user.createdTimestamp).toLocaleDateString()+"```",
          inline: true
      },
      {
        name: `Roles`,
        value: ""+member.roles.cache.map(r => r).join(' | ')+"",
        inline: true
      },
    

  )

  return message.channel.send(infoEmbed)
Posted by: Guest on July-07-2021
1

If statement discord js

<client>.on('message', message => {
	if (message.content === '!ping') {
		message.channel.send('Pong.');
	} else if (message.content.startsWith('beep')) {
		message.channel.send('Boop.');
    }
});
// The client is the bot itself. 
// You would have defined this at the top of your index.js/app.js
// It would look like 'const client = new Discord.Client()'
// Put that in place for '<client>' and remove the <>
Posted by: Guest on June-21-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language