Emoji click interaction

Hey, i made code when author click on reaction get ViewChannel Permission but i didn't work can any body help ??
logChannel.send({ embeds: [embed] })
.then(async (message) => {
// Add reaction emoji to the message
await message.react(':white_check_mark:');

// Await the reaction
const filter = (reaction, user) => reaction.emoji.name === ':white_check_mark:' && user.id === interaction.user.id;
const collector = message.createReactionCollector({ filter, time: 15000 });

console.log("Reaction collector created.");

collector.on('collect', async (reaction, user) => {
console.log("Reaction collected:", reaction.emoji.name, "by user:", user.id);

// Grant view permission to the user
await hiddenChannel.permissionOverwrites.edit(interaction.user.id, {
ViewChannel: true // corrected ViewChannel to VIEW_CHANNEL
});

// Send a confirmation message
interaction.reply({
content: 'You have been granted permission to view the ticket channel.',
ephemeral: true
});
});

collector.on('end', () => {
console.log("Reaction collector ended.");
// Remove the reaction collector after 15 seconds
collector.stop();
});
})
.catch(error => console.error('Error sending message to log channel:', error));
}
logChannel.send({ embeds: [embed] })
.then(async (message) => {
// Add reaction emoji to the message
await message.react(':white_check_mark:');

// Await the reaction
const filter = (reaction, user) => reaction.emoji.name === ':white_check_mark:' && user.id === interaction.user.id;
const collector = message.createReactionCollector({ filter, time: 15000 });

console.log("Reaction collector created.");

collector.on('collect', async (reaction, user) => {
console.log("Reaction collected:", reaction.emoji.name, "by user:", user.id);

// Grant view permission to the user
await hiddenChannel.permissionOverwrites.edit(interaction.user.id, {
ViewChannel: true // corrected ViewChannel to VIEW_CHANNEL
});

// Send a confirmation message
interaction.reply({
content: 'You have been granted permission to view the ticket channel.',
ephemeral: true
});
});

collector.on('end', () => {
console.log("Reaction collector ended.");
// Remove the reaction collector after 15 seconds
collector.stop();
});
})
.catch(error => console.error('Error sending message to log channel:', error));
}
31 Replies
d.js toolkit
d.js toolkit2mo 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! - Marked as resolved by OP
Vicarious
Vicarious2mo ago
There no ERROR
kin.ts
kin.ts2mo ago
use the unicode emoji to be compared with reaction.emoji.name
=== reaction.emoji.name
=== reaction.emoji.name
Vicarious
Vicarious2mo ago
logChannel.send({ embeds: [embed] })
.then(async (message) => {
// Add reaction emoji to the message
await message.react('✅');

// Await the reaction
const filter = (reaction, user) => '✅' === reaction.emoji.name && user.id === interaction.user.id;
const collector = message.createReactionCollector({ filter });

collector.on('collect', async (reaction, user) => {
// Grant view permission to the user
await hiddenChannel.permissionOverwrites.edit(interaction.user.id, {
ViewChannel: true // Corrected property name
});

// Send a confirmation message
interaction.reply({
content: 'You have been granted permission to view the ticket channel.',
ephemeral: true
});
});
})
.catch(error => console.error('Error sending message to log channel:', error));
}
logChannel.send({ embeds: [embed] })
.then(async (message) => {
// Add reaction emoji to the message
await message.react('✅');

// Await the reaction
const filter = (reaction, user) => '✅' === reaction.emoji.name && user.id === interaction.user.id;
const collector = message.createReactionCollector({ filter });

collector.on('collect', async (reaction, user) => {
// Grant view permission to the user
await hiddenChannel.permissionOverwrites.edit(interaction.user.id, {
ViewChannel: true // Corrected property name
});

// Send a confirmation message
interaction.reply({
content: 'You have been granted permission to view the ticket channel.',
ephemeral: true
});
});
})
.catch(error => console.error('Error sending message to log channel:', error));
}
it didn't work
kin.ts
kin.ts2mo ago
what didn't work?
Vicarious
Vicarious2mo ago
click interaction grant permission
kin.ts
kin.ts2mo ago
do you know where the code stuck?
Vicarious
Vicarious2mo ago
am gonna send all codes
kin.ts
kin.ts2mo ago
I don't want to download the file, can you show what the logs show?
Vicarious
Vicarious2mo ago
there no logs LMAO Ready! Logged in as Ticket#1690
kin.ts
kin.ts2mo ago
But your bot sent the embed?
Vicarious
Vicarious2mo ago
yes listen i made temp. log
logChannel.send({ embeds: [embed] })
.then(async (message) => {
// Add reaction emoji to the message
await message.react(':white_check_mark:');

// Await the reaction
const filter = (reaction, user) => reaction.emoji.name === ':white_check_mark:' && user.id === interaction.user.id;
const collector = message.createReactionCollector({ filter, time: 15000 });

console.log("Reaction collector created.");

collector.on('collect', async (reaction, user) => {
console.log("Reaction collected:", reaction.emoji.name, "by user:", user.id);

// Grant view permission to the user
await hiddenChannel.permissionOverwrites.edit(interaction.user.id, {
VIEW_CHANNEL: true
});

// Send a confirmation message
interaction.reply({
content: 'You have been granted permission to view the ticket channel.',
ephemeral: true
});
});

collector.on('end', () => {
console.log("Reaction collector ended.");
// Remove the reaction collector after 15 seconds
collector.stop();
});
})
.catch(error => console.error('Error sending message to log channel:', error));

}
logChannel.send({ embeds: [embed] })
.then(async (message) => {
// Add reaction emoji to the message
await message.react(':white_check_mark:');

// Await the reaction
const filter = (reaction, user) => reaction.emoji.name === ':white_check_mark:' && user.id === interaction.user.id;
const collector = message.createReactionCollector({ filter, time: 15000 });

console.log("Reaction collector created.");

collector.on('collect', async (reaction, user) => {
console.log("Reaction collected:", reaction.emoji.name, "by user:", user.id);

// Grant view permission to the user
await hiddenChannel.permissionOverwrites.edit(interaction.user.id, {
VIEW_CHANNEL: true
});

// Send a confirmation message
interaction.reply({
content: 'You have been granted permission to view the ticket channel.',
ephemeral: true
});
});

collector.on('end', () => {
console.log("Reaction collector ended.");
// Remove the reaction collector after 15 seconds
collector.stop();
});
})
.catch(error => console.error('Error sending message to log channel:', error));

}
Vicarious
Vicarious2mo ago
No description
Vicarious
Vicarious2mo ago
i made when author create hidden channel the bot sends log to channel when user click on emoji get permission to ViewChannel
Vicarious
Vicarious2mo ago
@kin.ts
No description
kin.ts
kin.ts2mo ago
wrong permission name, use PascalCase (ViewChannel)
No description
Vicarious
Vicarious2mo ago
either if i use PascalCase there nothing gonna happen
kin.ts
kin.ts2mo ago
can you show your client constructor?
Vicarious
Vicarious2mo ago
const { Client, GatewayIntentBits, REST } = require('discord.js');
const { token } = require('../config.json');


// Define the intents you want to enable
const intents = [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.MessageContent // Note: You have 'MessageContent' included twice in your original array
// Add more intents as needed
];

const rest = new REST({ version: '9' }).setToken(token);

// Create the client with the specified intents
const client = new Client({ intents });

// Export the client instance
module.exports = client;

client.login(token);
const { Client, GatewayIntentBits, REST } = require('discord.js');
const { token } = require('../config.json');


// Define the intents you want to enable
const intents = [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.MessageContent // Note: You have 'MessageContent' included twice in your original array
// Add more intents as needed
];

const rest = new REST({ version: '9' }).setToken(token);

// Create the client with the specified intents
const client = new Client({ intents });

// Export the client instance
module.exports = client;

client.login(token);
thats ??
kin.ts
kin.ts2mo ago
you'd need the GuildMessageReactions intent
Vicarious
Vicarious2mo ago
i wish that's work but it didn't also when click on reaction there nothing happening
kin.ts
kin.ts2mo ago
show your current code
Vicarious
Vicarious2mo ago
const { Client, GatewayIntentBits, REST } = require('discord.js');
const { token } = require('../config.json');


// Define the intents you want to enable
const intents = [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMessageReactions
];

const rest = new REST({ version: '9' }).setToken(token);

// Create the client with the specified intents
const client = new Client({ intents });

// Export the client instance
module.exports = client;

client.login(token);
const { Client, GatewayIntentBits, REST } = require('discord.js');
const { token } = require('../config.json');


// Define the intents you want to enable
const intents = [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMessageReactions
];

const rest = new REST({ version: '9' }).setToken(token);

// Create the client with the specified intents
const client = new Client({ intents });

// Export the client instance
module.exports = client;

client.login(token);
kin.ts
kin.ts2mo ago
no, the collector part
Vicarious
Vicarious2mo ago
logChannel.send({ embeds: [embed] })
.then(async (message) => {
console.log("Message sent with embed.");

// Add reaction emoji to the message
await message.react('✅');
console.log("Reaction added to the message.");

// Await the reaction
const filter = (reaction, user) => reaction.emoji.name === '✅' && user.id === interaction.user.id;
const collector = message.createReactionCollector({ filter, time: 15000 });

console.log("Reaction collector created.");

collector.on('collect', async (reaction, user) => {
console.log("Reaction collected:", reaction.emoji.name, "by user:", user.id);

// Grant view permission to the user
await hiddenChannel.permissionOverwrites.edit(interaction.user.id, {
VIEW_CHANNEL: true
});

// Send a confirmation message
interaction.reply({
content: 'You have been granted permission to view the ticket channel.',
ephemeral: true
});
});

collector.on('end', () => {
console.log("Reaction collector ended.");
// Remove the reaction collector after 15 seconds
collector.stop();
});
})
.catch(error => console.error('Error sending message to log channel:', error));

logChannel.send({ embeds: [embed] })
.then(async (message) => {
console.log("Message sent with embed.");

// Add reaction emoji to the message
await message.react('✅');
console.log("Reaction added to the message.");

// Await the reaction
const filter = (reaction, user) => reaction.emoji.name === '✅' && user.id === interaction.user.id;
const collector = message.createReactionCollector({ filter, time: 15000 });

console.log("Reaction collector created.");

collector.on('collect', async (reaction, user) => {
console.log("Reaction collected:", reaction.emoji.name, "by user:", user.id);

// Grant view permission to the user
await hiddenChannel.permissionOverwrites.edit(interaction.user.id, {
VIEW_CHANNEL: true
});

// Send a confirmation message
interaction.reply({
content: 'You have been granted permission to view the ticket channel.',
ephemeral: true
});
});

collector.on('end', () => {
console.log("Reaction collector ended.");
// Remove the reaction collector after 15 seconds
collector.stop();
});
})
.catch(error => console.error('Error sending message to log channel:', error));

kin.ts
kin.ts2mo ago
and what the logs show?
Vicarious
Vicarious2mo ago
Reaction collector created. after 15 second Reaction collector ended.
kin.ts
kin.ts2mo ago
try add some partials, Partials.Message and Partials.Reaction
Vicarious
Vicarious2mo ago
okey hold a minute You have entered a maze of parts
const { Client, GatewayIntentBits, REST, Partials } = require('discord.js');
const { token } = require('../config.json');

// Define the intents you want to enable
const intents = [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.MessageReactions
// Add more intents as needed
];

const rest = new REST({ version: '9' }).setToken(token);

// Create the client with the specified intents and partials
const client = new Client({ intents, partials: [Partials.Message, Partials.Channel, Partials.Reaction] });

// Export the client instance
module.exports = client;

client.login(token);
const { Client, GatewayIntentBits, REST, Partials } = require('discord.js');
const { token } = require('../config.json');

// Define the intents you want to enable
const intents = [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.MessageReactions
// Add more intents as needed
];

const rest = new REST({ version: '9' }).setToken(token);

// Create the client with the specified intents and partials
const client = new Client({ intents, partials: [Partials.Message, Partials.Channel, Partials.Reaction] });

// Export the client instance
module.exports = client;

client.login(token);
when im solving error i got new error
kin.ts
kin.ts2mo ago
GuildMessageReactions
Vicarious
Vicarious2mo ago
so i'll not use Partials anymore i want other solution I hope this is the problem na isn't i am so confused because why when am clicking on reaction there nothing happen At least a error code! @\ @kin.ts yo finnaly work it i just change it from collect to
client.on('messageReactionAdd', async (reaction, user) => {
// Check if the reaction is added by the bot
if (user.bot) return;

// Check if the reaction is added to the embed message
if (reaction.message.author.id !== client.user.id) return; // Ensure the bot sent the message
if (!reaction.message.embeds.length) return; // Ensure the message has an embed

const embed = reaction.message.embeds[0];
// You can further check the embed properties if needed

// Check if the reaction emoji is '✅'
if (reaction.emoji.name !== '✅') return;

// Grant view permission to the user
try {
await hiddenChannel.permissionOverwrites.edit(user.id, {
ViewChannel: true
});

// Send a confirmation message
const confirmationMessage = 'You have been granted permission to view the ticket channel.';
await reaction.message.channel.send({ content: confirmationMessage, ephemeral: true });
} catch (error) {
console.error('Error granting permission:', error);
// Handle the error, possibly by sending an error message
}
});
client.on('messageReactionAdd', async (reaction, user) => {
// Check if the reaction is added by the bot
if (user.bot) return;

// Check if the reaction is added to the embed message
if (reaction.message.author.id !== client.user.id) return; // Ensure the bot sent the message
if (!reaction.message.embeds.length) return; // Ensure the message has an embed

const embed = reaction.message.embeds[0];
// You can further check the embed properties if needed

// Check if the reaction emoji is '✅'
if (reaction.emoji.name !== '✅') return;

// Grant view permission to the user
try {
await hiddenChannel.permissionOverwrites.edit(user.id, {
ViewChannel: true
});

// Send a confirmation message
const confirmationMessage = 'You have been granted permission to view the ticket channel.';
await reaction.message.channel.send({ content: confirmationMessage, ephemeral: true });
} catch (error) {
console.error('Error granting permission:', error);
// Handle the error, possibly by sending an error message
}
});
thx for helping