#Trying to do a say slash command

14 messages · Page 1 of 1 (latest)

night canyonBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

jade meteor
#

this is my code

import { PermissionFlagsBits } from 'discord.js';

/**
 * Processes the "say" command.
 * @param {import('../util/i18n.js').default} lang - The user language.
 * @param {import('discord.js').CommandInteraction} interaction - The command interaction.
 * @param {import('../util/wiki.js').default} wiki - The wiki for the message.
 */
export default function cmd_say(lang, interaction, wiki) {
    const text = interaction.options.getString('text');
    const attachments = interaction.options.getMessage('attachments').attachments;

    const imgs = attachments.map(attachment => {
        return { attachment: attachment.url, name: attachment.name };
    });

    let allowedMentions = { parse: ['users'] };
    if (
        interaction.member.permissions.has(PermissionFlagsBits.MentionEveryone)
    ) {
        allowedMentions.parse = ['users', 'roles', 'everyone'];
    } else {
        allowedMentions.roles = interaction.guild.roles.cache
            .filter(role => role.mentionable)
            .map(role => role.id)
            .slice(0, 100);
    }

    interaction.reply({
        content: text,
        files: imgs,
        allowedMentions,
        reference: {
            message: interaction.reference?.messageId,
        },
    }).catch(error => {
        console.error(error);
        interaction.react('❌');
    });
}

export const cmdData = {
    name: 'say',
    description: 'Repeats the provided message.',
    options: [
        {
            name: 'text',
            type: 'STRING',
            description: 'The text to be repeated.',
            required: true,
        },
        {
            name: 'attachments',
            type: 'ATTACHMENT',
            description: 'The attachments to be sent.',
            required: false,
        },
    ],
    defaultPermission: true,
    run: cmd_say,
};```
#

and the .json

#
{
    "id": "",
    "application_id": "",
    "name": "say",
    "name_localizations": {},
    "description": "Repeats the provided message.",
    "description_localizations": {},
    "default_permission": false,
    "default_member_permissions": "0",
    "dm_permission": false,
    "options": [
      {
        "type": 3,
        "name": "text",
        "name_localizations": {},
        "description": "The text to be repeated.",
        "description_localizations": {},
        "required": true
      },
      {
        "type": 11,
        "name": "attachments",
        "name_localizations": {},
        "description": "The attachments to be sent.",
        "description_localizations": {},
        "required": false
      }
    ]
  }```
#

the problem that happens is that the bot does not respond to the command

#

This also happens to me in another command that I am doing to compare statistics of two objects from a wikipedia

severe sphinx
#

Is your function being called at all?

jade meteor
#

Yeah

tulip umbra
jade meteor
#
import { sendMessage } from '../util/functions.js';

function slash_say(interaction) {
    const text = interaction.options.getString('text');
    if (text) {
        return interaction.reply({ content: 'shh', ephemeral: true })
            .then(() => {
                return interaction.channel.send(text);
            })
            .catch((error) => {
                console.error('Error al enviar el mensaje adicional:', error);
            });
    } else {
        return interaction.reply({ content: 'No se proporcionó ningún texto.', ephemeral: true });
    }
}

const command = {
    name: 'say',
    slash: slash_say
};

export default command;

#

I already got it