如何使用模态作为选择菜单命令的回复



嗨,我有一个斜线命令回复一个选择菜单,我想打开一个模式的用户,当他选择一个选项,但我不能回复交互两次,所以我想知道是否有办法做到这一点。

我试图在同一通道中发送选择菜单作为正常消息,但每次使用该命令都会出现错误消息,因为它没有直接回复命令。如果有一种方法可以使此消息不显示,它也可以用于我的消息。

如果你能帮助我,请留言。

const { SlashCommandBuilder } = require('@discordjs/builders');
const { ActionRowBuilder, EmbedBuilder, StringSelectMenuBuilder, ModalBuilder, TextInputBuilder, TextInputStyle } = require('discord.js');
const matches = require("../../differents-matches");
module.exports = {
data: new SlashCommandBuilder()
.setName('matchdisponibilities')
.setDescription('Used to give your disponibilities for a specific match'),
async execute(interaction, client) {
const userRoles = interaction.member.roles.cache.map((role) => role.id)
let allMatches = await matches.find()
let userMatches = []
allMatches.forEach(element => {
userRoles.forEach(role => {
if (element._team1 === role || element._team2 === role) {
userMatches.push(element)
}
})
})
const embed = new EmbedBuilder()
.setTitle('Select a match')
.setColor(0x18e1ee)
const componentsMenu = new ActionRowBuilder().addComponents(
new StringSelectMenuBuilder()
.setCustomId('select')
.setPlaceholder('Nothing selected')               
)
userMatches.forEach(element => {
componentsMenu.components[0].addOptions(
{
label: interaction.guild.roles.cache.get(element._team1).name + ' VS ' + interaction.guild.roles.cache.get(element._team2).name,
value: element.id,
}
)
})
const modal = new ModalBuilder()
.setCustomId('test')
.setTitle('test2')
const textInput = new TextInputBuilder()
.setCustomId('test3')
.setLabel('test4')
.setRequired(true)
.setStyle(TextInputStyle.Short)
const channel = interaction.channel
modal.addComponents(new ActionRowBuilder().addComponents(textInput))
const message = await interaction.reply({embeds: [embed], components: [componentsMenu], fetchReply: true})
const collector = message.createMessageComponentCollector({
filter: (u) => {
if (u.user.id === interaction.user.id) return true
else{
return false
}
}            
})

collector.on('collect', async (cld) => {
if(cld.values[0] === '63960e06ee2ff68635eff3bb'){
await interaction.showModal(modal)
}
})
}

}

问题是我在我的收集器中使用await interaction.showModal(modal)作为选择菜单而不是await cld.showModal(modal),所以我响应斜杠命令的交互而不是选择菜单的交互

最新更新