[英]I need help creating a warning command in Discord.JS
I did this command to warn members and send a message in the DM, but I want the bot to tell the members in which server they were warned.我执行此命令是为了警告成员并在 DM 中发送消息,但我希望机器人告诉成员他们在哪个服务器中收到警告。
if (command === "warn") {
let dUser = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0]);
if (!message.member.hasPermission("ADMINISTRATOR")) return message.reply("You can't use that command!")
if (!dUser) return message.channel.send("Can't find user!")
let dMessage = args.join(" ").slice(22);
if (dMessage.length < 1) return message.reply('what is the reason???')
dUser.send(`${dUser}, You have been warned for doing ${dMessage}`)
message.channel.send(`${dUser} has been warned for doing ${dMessage} :thumbsdown:`)
Message
has a property Guild
, which is the guild in which the message was sent. Message
有一个Guild
属性,它是发送消息的公会。 You can just use message.guild.name
to get the guild name.您可以使用message.guild.name
来获取公会名称。
if (command === "warn") {
let dUser = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0]);
if (!message.member.hasPermission("ADMINISTRATOR")) return message.reply("You can't use that command!")
if (!dUser) return message.channel.send("Can't find user!")
let dMessage = args.join(" ").slice(22);
if (dMessage.length < 1) return message.reply('what is the reason???')
dUser.send(`${dUser}, You have been warned for doing ${dMessage} in the server ${message.guild.name}`)
message.channel.send(`${dUser} has been warned for doing ${dMessage} :thumbsdown:`)
i recommend use a database to store the data which user get warn how many time.我建议使用数据库来存储用户收到警告多少次的数据。 if the user has been warn let's say 3 times then perma ban the user如果用户已被警告让我们说 3 次然后永久禁止用户
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.