const Discord = require('discord.js');
const bot3 = new Discord.Client();
const token3 = 'I am not telling my bots token';
const mark2 = '*info personal'
bot3.on('message', msg =>{
let args2 = msg.content.substring(mark2.length).split('')
if (msg.content.startsWith(mark2)){
const hashitag = msg.author.id
const actualhashitag = msg.author.discriminator
const evenbetterhashitag = "#" + actualhashitag
const personalembed = new Discord.MessageEmbed()
.setTitle('Stuff about you')
.setImage(msg.author.displayAvatarURL())
.setColor('#D11111')
.addField('Your username', msg.author.username)
.addField('Your hashtag', hashitag, true)
.addField('Your actual hashtag', actualhashitag, true)
.addField('Your even realer hashtag', evenbetterhashitag, true)
.addField('Your amount of friends', 'Discord bots can not know that sadly')
.addField('Your role', )
msg.channel.send(personalembed)
}
})
bot3.login(token3)
我如何获得消息作者在当前公会中的角色? 当我搜索角色时,我只找到了如何检查某人是否有一个角色或者让每个人都有一个角色。 我为它开辟了一个空间。 我很确定我需要更多的领域。
当您使用message.author
时,您将获得一个用户对象:要获得该用户的角色,您需要使用guildmember
对象,您可以使用message.member
获取该对象。 下面是一个例子:
let authorUser = message.author,
authorMember = message.member
let authorRoles = authorMember.roles.cache // Collection<Snowflake, Role>
如您所见,我使用guildmember.roles.cache
获取角色集合:然后您可以使用它来做您想做的任何事情。