我的代码
module.exports = {
data: new SlashCommandBuilder()
.setName('remove')
.setDescription('Removes a user to the ticket')
.addSubcommand(subcommand =>
subcommand
.setName('user')
.setDescription('Remove taged User')
.addUserOption(option => option.setName('user').setDescription('The user'))),
async execute(interaction, client) {
const channel = interaction.channel;
const user = interaction.subcommand.getUser('user');
channel.permissionOverwrites.edit(user, {
'ViewChannel': false,
'SendMessages': false
});
await interaction.channel.reply({ content: `${user} Has been removed from the ticket!`});
},
};
错误:类型错误:无法读取未定义的属性(阅读“getUser”)
运行此命令时尝试从频道中删除用户
1条答案
按热度按时间mzsu5hc01#
interaction.subcommand
不存在。您可能希望使用interaction.options
,它是CommandInteractionOptionResolver
discord.js指南解释了如何解析命令中的选项。