#ExpectedConstraintError > s.string.regex

9 messages · Page 1 of 1 (latest)

late spire
#

code:

const reactions = require('./src/Schemas/reactionrolesSchema');
client.on(Events.MessageReactionAdd, async (reaction, user) => {
    if (!reaction.message.guildId) return;
    if (user.bot) return;

    let cID = `<${reaction.emoji.name}:${reaction.emoji.id}>`;
    if (!reaction.emoji.id) cID = reaction.emoji.name;

    const data = await reactions.findOne({ Guild: ireaction.message.guildId, Message: reaction.message.id, Emoji: cID});
    if (!data) return;

    const guild = await client.guild.cache.get(reaction.message.guildId);
    const member = await guild.members.cache.get(user.id);

    try {
        await member.roles.add(data.Role);
    } catch (e) {
        return;
    }
})
client.on(Events.MessageReactionRemove, async (reaction, user) => {
    if (!reaction.message.guildId) return;
    if (user.bot) return;

    let cID = `<${reaction.emoji.name}:${reaction.emoji.id}>`;
    if (!reaction.emoji.id) cID = reaction.emoji.name;

    const data = await reactions.findOne({ Guild: ireaction.message.guildId, Message: reaction.message.id, Emoji: cID});
    if (!data) return;

    const guild = await client.guild.cache.get(reaction.message.guildId);
    const member = await guild.members.cache.get(user.id);

    try {
        await member.roles.remove(data.Role);
    } catch (e) {
        return;
    }
})
dim islandBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
late spire
# late spire code: ```js const reactions = require('./src/Schemas/reactionrolesSchema'); cli...

reactionroles.js:

const { SlashCommandBuilder, EmbedBuilder, PermissionsBitField, InteractionCollector} = require('discord.js');
const reaction = require('../../Schemas/reactionrolesSchema');
const reactionrolesSchema = require('../../Schemas/reactionrolesSchema');

module.exports = {
    data: new SlashCommandBuilder()
    .setName('AutoRole')
    .setDescription('Создайте систему авторолей.')
    .addSubcommand(command => command.setName('добавить').setDescription('Добавляет систему авторолей под сообщением.').addStringOption(option => option.setName('id-сообщения').setDescription('Сообщение в котором будет система авторолей.').setRequired(true)).addStringOption(option => option.setName('эмодзи').setDescription('эмодзи на которое будет выдаваться роль.').setRequired(true)).addRoleOption(option => option.setName('роль').setDescription('роль которая будет выдаваться после того как нажмут на эмодзи.').setRequired(true)))
    .addSubcommand(command => command.setName('убрать').setDescription('Уберает систему авторолей под сообщением.').addStringOption(option => option.setName('id-сообщения').setDescription('Сообщение на которое будет реагировать.').setRequired(true)).addStringOption(option => option.setName('эмодзи').setDescription('эмодзи на которое будет убераться роль.').setRequired(true))),
    async execute (interaction) {
        const { options, guild, channel } = interaction;
        const sub = options.getSubcommand();
        const emoji = options.getString('эмодзи');
        
        let e;
        const message = await channel.message.fetch(options.getString('id-сообщения')).catch(err => {
            e = err;
        });

        if (!interaction.member.permission.has(PermissionsBitField.Flags.Administrator)) return await interaction.reply({content: `У вас нету прав чтоб использовать эту систему!`, ephemeral: true});
        if (e) return await interaction.reply({ content: `Сообщение щас отправиться в ${channel}!`, ephemeral: true});

        const data = await reaction.findOne({ Guild: guild.id, Message: message.id, Emoji: emoji});

        switch(sub) {
            case `добавить`:

            if (data) {
                return await interaction.reply({ content: `Кажись вы уже поставили ${emoji} на это сообщение.`, ephemeral: true});
            } else {
                const role = options.getRole('роль');
                await reaction.create({
                    Guild: guild.id,
                    Message: message.id,
                    Emoji: emoji,
                    Role: role.id
                });

                const embed = new EmbedBuilder()
                .setColor("Blurple")
                .setDescription(`Я добавил систему автореакций на ${message.url} с эмодзи ${emoji} и ролью ${role}`)

                await message.react(emoji).catch(err => {});

                await interaction.reply({ embeds: [embed], ephemeral: true});
            }

            break;
            case 'убрать':
            
            if (!data) {
                return await interaction.reply({content: `Кажись, у вас нету системы авторолей.`, ephemeral: true});
            } else {
                await reaction.deleteMany({
                    Guild: guild.id,
                    Message: message.id,
                    Emoji: emoji
                });

                const embed = new EmbedBuilder()
                .setColor("Blurple")
                .setDescription(`Я удалил систему авторолей из ${message.url} с эмодзи ${emoji}`)
                
                await interaction.reply({ embeds: [embed], ephemeral: true});
            }
        }

    }
}
rare cypress
#

slash commands namds and options cant have uppercase letters

late spire
#

because im not getting any other mistakes, but code is still not working

formal cosmosBOT
#

If you aren't getting any errors, try to place console.log checkpoints throughout your code to find out where execution stops.

  • Once you do, log relevant values and if-conditions
  • More sophisticated debugging methods are breakpoints and runtime inspections: learn more
late spire
#

can u show where i need to put console.log?