maccrackalackin
maccrackalackin
DIAdiscord.js - Imagine an app
Created by maccrackalackin on 4/20/2024 in #djs-questions
Reaction collector not working
is there a working example of the reaction collector i can test, or if someone can test this code to see if it works. Otherwise i am not sure how else to troubleshoot this
21 replies
DIAdiscord.js - Imagine an app
Created by maccrackalackin on 4/20/2024 in #djs-questions
Reaction collector not working
Thats a good idea. i tried the ignore event before and after the end event to see if it made a difference , Alas it did not, I think i coded it correctly but it did not seem to write to console anything: User xxx used the /ping command. Reaction collector started. Collected 0 reactions. Reason: time
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!'),
async execute(interaction) {
try {
console.log(`User ${interaction.user.tag} used the /ping command.`);

await interaction.reply('React with any emoji within 15 seconds.');

// Get the message object
const message = await interaction.fetchReply();

// Reaction collector
const reactFilter = (reaction, user) => user.id === interaction.user.id;
const collector = message.createReactionCollector({ filter: reactFilter, time: 15000 });

collector.on('collect', (reaction, user) => {
console.log(`User ${user.tag} reacted with ${reaction.emoji.name}`);
});

collector.on('end', (collected, reason) => {
console.log(`Collected ${collected.size} reactions. Reason: ${reason}`);
});

collector.on('ignore', (args) => {
console.log('Element ignored:', args);
});

// Log when collector starts
console.log('Reaction collector started.');

} catch (error) {
console.error(`Error: ${error.message}`);
}
},
};
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!'),
async execute(interaction) {
try {
console.log(`User ${interaction.user.tag} used the /ping command.`);

await interaction.reply('React with any emoji within 15 seconds.');

// Get the message object
const message = await interaction.fetchReply();

// Reaction collector
const reactFilter = (reaction, user) => user.id === interaction.user.id;
const collector = message.createReactionCollector({ filter: reactFilter, time: 15000 });

collector.on('collect', (reaction, user) => {
console.log(`User ${user.tag} reacted with ${reaction.emoji.name}`);
});

collector.on('end', (collected, reason) => {
console.log(`Collected ${collected.size} reactions. Reason: ${reason}`);
});

collector.on('ignore', (args) => {
console.log('Element ignored:', args);
});

// Log when collector starts
console.log('Reaction collector started.');

} catch (error) {
console.error(`Error: ${error.message}`);
}
},
};
21 replies
DIAdiscord.js - Imagine an app
Created by maccrackalackin on 4/20/2024 in #djs-questions
Reaction collector not working
thanks for the input, i apprecciate it it alot, i changed the filter with the same results however. I did have the bot scope, i just didnt have administrator untill recently to make sure i had no permission issues. I have other slash commands working perfectly with a lot of functionality, its just a simple react collector that doesnt seem to work.
21 replies
DIAdiscord.js - Imagine an app
Created by maccrackalackin on 4/20/2024 in #djs-questions
Reaction collector not working
No description
21 replies
DIAdiscord.js - Imagine an app
Created by maccrackalackin on 4/20/2024 in #djs-questions
Reaction collector not working
yes it is inside my client constructor, i believe that should be correct:
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, Events, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');

const client = new Client({ intents:[ GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessageReactions,
],
});
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, Events, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');

const client = new Client({ intents:[ GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessageReactions,
],
});
21 replies
DIAdiscord.js - Imagine an app
Created by maccrackalackin on 4/20/2024 in #djs-questions
Reaction collector not working
does anyone have an insight into why the collector is not working?
21 replies
DIAdiscord.js - Imagine an app
Created by maccrackalackin on 4/20/2024 in #djs-questions
Reaction collector not working
I have worked through this i think, but i am getting this still after i react : User xxx used the /ping command. Collected 0 reactions. Reason: time here is the adjusted code with a reaction collector:
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!'),
async execute(interaction) {
try {
console.log(`User ${interaction.user.tag} used the /ping command.`);

await interaction.reply('React with :thumbsup: within 15 seconds.');

// Get the message object from the interaction
const message = await interaction.fetchReply();

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

collector.on('collect', (reaction, user) => {
console.log(`User ${user.tag} reacted with 👍 `);
});

collector.on('end', (collected, reason) => {
console.log(`Collected ${collected.size} reactions. Reason: ${reason}`);
});
} catch (error) {
console.error(`Error: ${error.message}`);
}
},
};
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!'),
async execute(interaction) {
try {
console.log(`User ${interaction.user.tag} used the /ping command.`);

await interaction.reply('React with :thumbsup: within 15 seconds.');

// Get the message object from the interaction
const message = await interaction.fetchReply();

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

collector.on('collect', (reaction, user) => {
console.log(`User ${user.tag} reacted with 👍 `);
});

collector.on('end', (collected, reason) => {
console.log(`Collected ${collected.size} reactions. Reason: ${reason}`);
});
} catch (error) {
console.error(`Error: ${error.message}`);
}
},
};
21 replies
DIAdiscord.js - Imagine an app
Created by maccrackalackin on 4/20/2024 in #djs-questions
Reaction collector not working
thankyou, i will review this and see if can get it to work
21 replies