我想制定一个可以向人们展示角色的命令。这是我的代码:
client.on("message", message => {
if(message.content == `+dump admin`) {
const ListEmbed = new MessageEmbed()
.setTitle('Users with the admin role:')
.setDescription(message.guild.roles.get('741231292544188439').members.map(m=>m.user.tag).join('\n'));
message.channel.send(ListEmbed);
}
});
这段代码给我这个错误:
TypeError: message.guild.roles.get is not a function
at Client.<anonymous> (/home/runner/MutedPinkBlogclient/index.js:244:49)
at Client.emit (events.js:327:22)
at Client.EventEmitter.emit (domain.js:483:12)
at MessageCreateAction.handle (/home/runner/MutedPinkBlogclient/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/runner/MutedPinkBlogclient/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/runner/MutedPinkBlogclient/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/home/runner/MutedPinkBlogclient/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/home/runner/MutedPinkBlogclient/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/home/runner/MutedPinkBlogclient/node_modules/ws/lib/event-target.js:125:16)
此命令也只为我提供特定角色的成员。无论如何,我可以显示我键入或提及的角色名称。预先感谢。.