【发布时间】:2021-07-29 18:58:23
【问题描述】:
所以我正在制作一个具有自动日志记录功能的 Discord Bot,直到现在我都完成了大部分代码,其中包括设置 mod-log 通道的命令和事件代码,这里是命令:
let db = require(`quick.db`)
module.exports = {
name: "modlog",
aliases: ["modlogs", "log", "logs"],
description: "Change the modlogs channel of the current server",
permission: "MANAGE_CHANNELS",
usage: "modlog #[channel_name]",
run: async (client, message, args) => {
if(!message.member.hasPermission(`MANAGE_CHANNELS`)) {
return message.channel.send(`:x: You do not have permission to use this command!`)
} else {
let channel = message.mentions.channels.first();
if(!channel) return message.channel.send(`:x: Please specify a channel to make it as the modlogs!`)
await db.set(`modlog_${message.guild.id}`, channel)
message.channel.send(`Set **${channel}** as the server's modlog channel!`)
}
}
}
还有inviteCreate 事件:
client.on("inviteCreate", async invite => {
const log = client.channels.cache.get(`${`modlog_${message.guild.id}`}`)
let inviteCreated = new Discord.MessageEmbed()
log.send(`An invite has been created on this server!`)
})
问题在于,由于inviteCreate 事件只接受一个参数(我认为这就是它们的名称),即invite,因此没有message 参数,因此消息变得未定义,有没有人有解决方案?
谢谢!
【问题讨论】:
-
好的,看起来您的上次编辑现在是一个完全不同的问题。如果对您有帮助,您应该在此处投票(并且两个答案都是您设法从邀请中获得公会 ID),并使用新的详细信息创建一个新问题。
标签: javascript discord discord.js