如何让我的bot显示使用该命令的discord服务器的名称



我正试图制定一个命令,当用户说出列入黑名单的单词时禁止他们使用,我正试图找出如何使其成为他们被禁止使用的服务器。例如,

if (message.content == `nword`) {
message.author.send(`You were banned from (The server they were banned from) for saying the n-word`)
member.ban()
}```

您的消息发送部分是正确的,请参阅此处讨论:向用户发送私人消息

您可以访问消息的guild属性,并将公会的名称添加到DM消息中。https://discord.js.org/#/docs/main/master/class/Message?scrollTo=guild

这将是公会类的一个实例,它有很多属性,包括name,这可能是您想要的。https://discord.js.org/#/docs/main/stable/class/Guild?scrollTo=name

未经测试的示例实现:

let serverName = message.guild.name;
message.author.send("You were banned from " + serverName + "for saying...");

最新更新