Bot 不发送临时消息

Bot not send ephemeral message

我正在创建一个名为 roleinfo 的命令,但是当我想让它按下按钮时,它不会临时发送消息!有谁知道为什么?我已经尝试过 interaction.reply 但是 INTERACTION_ALREADY_REPLIED 错误出现而命令没有 deferReply!


const { MessageEmbed, MessageActionRow, MessageButton } = require("discord.js");
const moment = require("moment");
moment.locale("pt-BR");
module.exports = {
  name: "roleteste",
  description: "Obtenha informações de um cargo",
  options: [
    {
      name: "role",
      type: "ROLE",
      description: "O cargo que você deseja obter as informações !",
      required: true,
    },
  ],
  run: async (client, interaction, args) => {
        
    const role = interaction.guild.roles.cache.get(args[0]);
     const permissions = {
            "ADMINISTRATOR": "Administrador",
            "VIEW_AUDIT_LOG": "Ver Registro de Auditoria",
            "VIEW_GUILD_INSIGHTS": "Exibir insights do servidor",
            "MANAGE_GUILD": "Gerenciar Servidor",
            "MANAGE_ROLES": "Gerenciar Cargos",
            "MANAGE_CHANNELS": "Gerenciar Canais",
            "KICK_MEMBERS": "Expulsar Membros",
            "BAN_MEMBERS": "Banir Membros",
            "CREATE_INSTANT_INVITE": "Criar convite",
            "CHANGE_NICKNAME": "Mudar apelido",
            "MANAGE_NICKNAMES": "Gerenciar apelidos",
            "MANAGE_EMOJIS": "Gerenciar Emojis",
            "MANAGE_WEBHOOKS": "Gerenciar webhooks",
            "VIEW_CHANNEL": "Ler canais de texto e ver canais de voz",
            "SEND_MESSAGES": "Enviar mensagens",
            "SEND_TTS_MESSAGES": "Enviar mensagens TTS",
            "MANAGE_MESSAGES": "Gerenciar mensagens",
            "EMBED_LINKS": "Embed Links",
            "ATTACH_FILES": "Anexar arquivos",
            "READ_MESSAGE_HISTORY": "Leia o histórico da mensagem",
            "MENTION_EVERYONE": "Mencione @everyone, @here e Todos os cargos",
            "USE_EXTERNAL_EMOJIS": "Usar Emojis Externos",
            "ADD_REACTIONS": "Adicionar Reações",
            "CONNECT": "Conectar",
            "SPEAK": "Falar",
            "STREAM": "Video",
            "MUTE_MEMBERS": "Mutar Membros",
            "DEAFEN_MEMBERS": "Membros surdos",
            "MOVE_MEMBERS": "Mover membros",
            "USE_VAD": "Usar atividade de voz",
            "PRIORITY_SPEAKER": "Orador prioritário"
        }

        const yesno = {
            true: '`Sim`',
            false: '`Não`'
        }


        const rolePermissions = role.permissions.toArray();
        const finalPermissions = [];
        for (const permission in permissions) {
            if (rolePermissions.includes(permission)) finalPermissions.push(`${client.emoji.success} ${permissions[permission]}`);
            else finalPermissions.push(`${client.emoji.fail} ${permissions[permission]}`);
        }

        const position = `\`${interaction.guild.roles.cache.size - role.position}°\``;
        
        const embed = new MessageEmbed()
        
        .setTitle(`${role.name}`)
        .addField(`${client.emoji.id} ID`, `\`${role.id}\``, true)
        .addField(`${client.emoji.trophy} Posição`, `${position}`, true)
        .addField(`${client.emoji.ping} Mencionável`, yesno[role.mentionable], true)
        .addField(`${client.emoji.bot} Cargo de bot`, yesno[role.managed], true)
        .addField(`${client.emoji.on} Visível`, yesno[role.hoist], true)
        .addField(`${client.emoji.rcolor} Cor`, `\`${role.hexColor.toUpperCase()}\``, true)
        .addField(`${client.emoji.calendar} Data de criação`, `${moment(role.createdAt).format('LLL')}(${moment(role.createdAt).startOf('day').fromNow()})`, true)
        .setColor(`${role.hexColor.toUpperCase()}`)
              
const row = new MessageActionRow()
    .addComponents(
        new MessageButton()
      .setLabel(`Permissões`)
    .setEmoji(`${client.emoji.perms}`)
             .setCustomId('perms')        .setStyle('SECONDARY')
);
     const m = await interaction.followUp({ embeds: [embed], components: [row], fetchReply: true  })
        const iFilter = i => i.user.id === interaction.user.id;

        const collector = m.createMessageComponentCollector({ filter: iFilter, time: 10 * 60000 });

        collector.on('collect', async(i) => {
            switch (i.customId) {
                case `perms`:
                i.deferUpdate
                   m.reply({
                     embeds: [new MessageEmbed()
                                     .setTitle(`${client.emoji.perms} Permissões`)
                                     .setDescription(`${finalPermissions.join('\n')}`)
                                     ], ephemeral: true
                     })
                 }
        })
    }                    
}

在interactionCreate中应该不是问题,记得我的bot一直有reply error,所以一直用followUp

在按钮按下事件中,您没有调用函数 i.deferUpdate。这很可能表明交互失败,我建议首先通过调用该函数来修复此问题,您可以通过在末尾添加 (); 来完成此操作,这意味着它是这样的:i.deferUpdate();.

其次,邮件未临时发送的原因是您使用了 m.reply,您可以再次将其替换为 interaction.followUp,或将 m.reply 替换为i.reply 并删除 i.deferUpdate(); 以便能够将消息作为临时消息发送。

示例:

i.deferUpdate();
m.reply({ // Object passed here

i.reply({ // Object passed here

如果我在这个回答中有错误,请回复以便我可以编辑修复。