ExpectedConstraintError > s.string.regex

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;
}
})
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;
}
})
6 Replies
d.js toolkit
d.js toolkit6mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - 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!
Гусейн
Гусейн6mo ago
discord.js@14.14.1 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});
}
}

}
}
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});
}
}

}
}
treble/luna
treble/luna6mo ago
slash commands namds and options cant have uppercase letters
Гусейн
Гусейн6mo ago
maybe u can find any other mistakes? because im not getting any other mistakes, but code is still not working
d.js docs
d.js docs6mo ago
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
Гусейн
Гусейн6mo ago
can u show where i need to put console.log?