我正在尝试发出一个命令,当用户说出列入黑名单的词时禁止他们,我试图弄清楚如何将其发送给他们被禁止进入的服务器。例如,
if (message.content == `nword`) {
message.author.send(`You were banned from (The server they were banned from) for saying the n-word`)
member.ban()
}```
答案 0 :(得分:1)
您的消息发送部分正确,请参阅此处的讨论:Sending private messages to user
您可以访问消息的 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...");