【发布时间】:2022-07-21 15:39:31
【问题描述】:
我目前正在尝试创建一个 unban 命令,但是,“用户”未定义,我不确定解决方案是什么或如何定义它。我检查了我可能犯的错别字和错误,但我所看到的似乎没有。
(另外,我正在关注 reconlx 的 Kick/Ban/Unban 命令教程,其中包含我自己的一些嵌入)。
unban.js 的代码,错误如下。
const { Client, CommandInteraction, MessageEmbed } = require("discord.js");
module.exports = {
name: "unban",
description: "Unbans a user",
userPermissions: ["BAN_MEMBERS"],
options: [
{
name: "userid",
description: "User ID of the offender",
type: "STRING",
required: true,
},
],
/**
* @param {Client} client
* @param {CommandInteraction} interaction
*/
run: async (client, interaction) => {
const userID = interaction.options.getString("userid");
const unbanEmbed = new MessageEmbed()
.setTitle(`${user.tag} has been unbanned!`)
.setFooter({ text: "Unban Successful!"})
const unbanNull = new MessageEmbed()
.setTitle("Invalid ID!")
.setFooter({ text: "Error: Invalid User ID" })
interaction.guild.members
.unban(userID)
.then((user) => {
interaction.followUp({
embeds:
[unbanEmbed],
});
})
.catch(() => {
interaction.followUp({
embeds:
[unbanNull],
});
});
},
};
错误
ReferenceError: user is not defined
at Object.run (C:\Users\admin\Desktop\Tonkotsu\SlashCommands\moderation\unban.js:23:26)
at Client.<anonymous> (C:\Users\admin\Desktop\Tonkotsu\events\interactionCreate.js:27:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
【问题讨论】:
标签: discord discord.js