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
- 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 OPThere no ERROR
use the unicode emoji to be compared with
reaction.emoji.name
✅ === reaction.emoji.name
✅ === reaction.emoji.name
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));
}
what didn't work?
click interaction
grant permission
do you know where the code stuck?
am gonna send all codes
I don't want to download the file, can you show what the logs show?
there no logs LMAO
Ready! Logged in as Ticket#1690
But your bot sent the embed?
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));
}
i made when author create hidden channel the bot sends log to channel when user click on emoji get permission to ViewChannel
@kin.ts
wrong permission name, use PascalCase (
ViewChannel
)either if i use PascalCase
there nothing gonna happen
can you show your client constructor?
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);
you'd need the GuildMessageReactions intent
i wish that's work but it didn't also
when click on reaction there nothing happening
show your current code
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);
no, the collector part
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));
and what the logs show?
Reaction collector created.
after 15 second
Reaction collector ended.
try add some partials, Partials.Message and Partials.Reaction
okey hold a minute
You have entered a maze of parts
when im solving error i got new error
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);
GuildMessageReactions
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
thx for helping
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
}
});