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 toolkit8mo 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
VicariousOP8mo ago
There no ERROR
kin.ts
kin.ts8mo ago
use the unicode emoji to be compared with reaction.emoji.name
=== reaction.emoji.name
=== reaction.emoji.name
Vicarious
VicariousOP8mo 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.ts8mo ago
what didn't work?
Vicarious
VicariousOP8mo ago
click interaction grant permission
kin.ts
kin.ts8mo ago
do you know where the code stuck?
Vicarious
VicariousOP8mo ago
am gonna send all codes
kin.ts
kin.ts8mo ago
I don't want to download the file, can you show what the logs show?
Vicarious
VicariousOP8mo ago
there no logs LMAO Ready! Logged in as Ticket#1690
kin.ts
kin.ts8mo ago
But your bot sent the embed?
Vicarious
VicariousOP8mo 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
VicariousOP8mo ago
No description
Vicarious
VicariousOP8mo ago
i made when author create hidden channel the bot sends log to channel when user click on emoji get permission to ViewChannel
Vicarious
VicariousOP8mo ago
@kin.ts
No description
kin.ts
kin.ts8mo ago
wrong permission name, use PascalCase (ViewChannel)
No description
Vicarious
VicariousOP8mo ago
either if i use PascalCase there nothing gonna happen
kin.ts
kin.ts8mo ago
can you show your client constructor?
Vicarious
VicariousOP8mo 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.ts8mo ago
you'd need the GuildMessageReactions intent
Vicarious
VicariousOP8mo ago
i wish that's work but it didn't also when click on reaction there nothing happening
kin.ts
kin.ts8mo ago
show your current code
Vicarious
VicariousOP8mo 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.ts8mo ago
no, the collector part
Vicarious
VicariousOP8mo 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.ts8mo ago
and what the logs show?
Vicarious
VicariousOP8mo ago
Reaction collector created. after 15 second Reaction collector ended.
kin.ts
kin.ts8mo ago
try add some partials, Partials.Message and Partials.Reaction
Vicarious
VicariousOP8mo 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.ts8mo ago
GuildMessageReactions
Vicarious
VicariousOP8mo 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
Want results from more Discord servers?
Add your server