DJS V13按钮获取错误交互已被确认



当与按钮交互时,我想重新发送一个不同的版本。在尝试之前,我正试图做指南所做的事情,我在点击它时得到错误Interaction Has Already Been Acknowledged

代码如下:

const { SlashCommandBuilder } = require('@discordjs/builders');
const { MessageEmbed, Client, MessageActionRow, MessageButton } = require('discord.js');
const wait = require('node:timers/promises').setTimeout;

let report = ""
module.exports = {
data: new SlashCommandBuilder()
.setName('report')
.setDescription('Report a user, this can be for anything and is sent to MTIA.')
.addStringOption(option =>
option.setName('user')
.setDescription('Please include there RBLX and DISC usernames, discord ID too.')
.setRequired(true))
.addStringOption(option =>
option.setName('report')
.setDescription('Reason for report, please include links to proof.')
.setRequired(true))
.addStringOption(option =>
option.setName('where')
.setDescription('Where the action took place.')
.setRequired(true)),
async execute(interaction, client) {
const channel = client.channels.cache.get('962342252263395378');

if(report == "") {
let report = interaction.options.getString('report')
let offender = interaction.options.getString('user')
let where = interaction.options.getString('where')

const A = new MessageEmbed()
.setTitle("**New Report**")
.setDescription(`Offender: ${offender} n Reporter: ${interaction.user.tag} n Reason: ${report} n Location: ${where} n n  Responce: None`)
.setTimestamp()
.setColor("00000")
const row = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('banuser')
.setLabel('Ban the User')
.setStyle('SUCCESS'),
new MessageButton()
.setCustomId('otheraction')
.setLabel('Other action taken.')
.setStyle('PRIMARY'),
new MessageButton()
.setCustomId('deny')
.setLabel('Deny the report.')
.setStyle('DANGER'),
);

channel.send({ embeds: [A], components: [row] });
interaction.reply(`Report submitted.`);


};
const B = new MessageEmbed()
.setTitle("**New Report**")
.setDescription(`Offender: ${offender} n Reporter: ${interaction.user.tag} n Reason: ${report} n Location: ${where} n n  Responce: Banned`)
.setTimestamp()
.setColor("00FF00")

const C = new MessageEmbed()
.setTitle("**New Report**")
.setDescription(`Offender: ${offender} n Reporter: ${interaction.user.tag} n Reason: ${report} n Location: ${where} n n  Responce: Denied Report`)
.setTimestamp()
.setColor("FF0000")

const D = new MessageEmbed()
.setTitle("**New Report**")
.setDescription(`Offender: ${offender} n Reporter: ${interaction.user.tag} n Reason: ${report} n Location: ${where} n n  Responce: Other Action`)
.setTimestamp()
.setColor("FFFFFF")
const filter = i => i.customId === 'banuser' && i.user.id === '776164004460363816';
const collector = interaction.channel.createMessageComponentCollector({ filter, time: 15000 });


collector.on('collect', async i => {
if (i.customId === 'banuser') {
await i.deferUpdate();
await wait(4000);
await i.editReply({ content: 'A button was clicked!', components: [] });
}
}); 
},
};

我试着改变一下关于扣按钮的问题。如何修复此问题?为什么会出现此错误?

将收集器更改为以下

collector.on('collect', async i => {
if (i.customId === 'banuser') {
await i.deferUpdate();
await wait(4000);
await i.message.edit({components: []}) //Removing the button from the initial reply
await i.reply({ content: 'A button was clicked!'}); //Since you want to resend and not edit
}
});

相关内容

  • 没有找到相关文章

最新更新