【发布时间】:2020-05-05 23:34:42
【问题描述】:
您好 StackOverflow 社区,这是我第一个需要 Discord 帮助的问题,有人可以编辑此代码以使此命令向 #logs 频道发送包含以下信息的日志 1) 标题 - 审核日志 2) 执行审核操作的用户 3) 执行了哪些审核操作(在本例中为禁令) 4) 主持人 5) 页脚 - Proton Servers Bot©2020
const { client, config, functions } = require('../index.js');
module.exports.run = async (message, u) => {
if (!message.member.hasPermission('BAN_MEMBERS')) return message.channel.send(functions.errorEmbed('You are not permitted to do this.'));
if (!u) return message.channel.send(functions.usageEmbed(config.prefix + 'ban <user/id>'));
const userID = u.match(/[0-9]+/) ? u.match(/([0-9]+)/)[0] : undefined;
const user = message.guild.members.get(userID);
if (!user) return message.channel.send(functions.errorEmbed('**' + u + '** is not a valid user.'));
try {
await user.ban();
return message.channel.send(functions.successEmbed('Banned ' + user + ' successfully.'));
} catch {
return message.channel.send(functions.errorEmbed('Could not ban ' + user + '. Is their role higher than mine?'));
}
}
module.exports.description = 'Ban a user.';```
【问题讨论】:
-
Discord JS 版本:11.5.1 Nodejs 版本:v10.20.0
-
我的 discord.js 很生锈,尽管我认为可以澄清您的问题以帮助任何试图回答您的问题的人。例如,您在这里有一大段代码;您应该解释其中的某些部分,按预期工作的内容以及所需结果中缺少的内容。
标签: node.js discord.js