PurifiedWater
PurifiedWater
DIAdiscord.js - Imagine an app
Created by PurifiedWater on 11/13/2023 in #djs-questions
How to keep listening to messages from a specific channel?
I've tried two ways but I cannot get any message:
// on messageCreate
module.exports = {
name: Events.MessageCreate,
async execute(m) {
logger.info(m);
},
};

// and on ready
module.exports = {
name: Events.ClientReady,
once: true,
execute(client) {
logger.info("Ready!") // this work
const channel = client.channels.cache.get(process.env.LISTEN_CHANNEL);
const collector = channel.createMessageCollector();
collector.on("collect", (m) => {
logger.info(m);
});
},
};
// on messageCreate
module.exports = {
name: Events.MessageCreate,
async execute(m) {
logger.info(m);
},
};

// and on ready
module.exports = {
name: Events.ClientReady,
once: true,
execute(client) {
logger.info("Ready!") // this work
const channel = client.channels.cache.get(process.env.LISTEN_CHANNEL);
const collector = channel.createMessageCollector();
collector.on("collect", (m) => {
logger.info(m);
});
},
};
do I need to add more permissions or intents?
4 replies
DIAdiscord.js - Imagine an app
Created by PurifiedWater on 11/7/2023 in #djs-questions
Different modal IDs still trigger awaitModalSubmit multiple times
No description
8 replies
DIAdiscord.js - Imagine an app
Created by PurifiedWater on 11/7/2023 in #djs-questions
How to make a button open the modal after clicking it again?
I have a button that lets the user enter feedback. But if the user closes the modal midway, this button will become unavailable. How to make this button respond to multiple clicks to open the modal? My code here:
const feedbackButton = new ButtonBuilder()
.setCustomId("Feedback")
.setLabel("Give Feedback")
.setStyle(ButtonStyle.Primary);
message = await confirmation.update({
embeds: [embed],
components: [
new ActionRowBuilder().addComponents(feedbackButton),
],
});

try {
// Wait for feedback
confirmation = await message.awaitMessageComponent({
filter: collectorFilter,
time: 600_000,
});

const modal = new ModalBuilder()
.setCustomId("feedback")
.setTitle("Give some Feedback!");

// add some input components

try {
await confirmation.showModal(modal);
confirmation = await confirmation.awaitModalSubmit({
time: 300_000,
});
const feedback =
confirmation.fields.getTextInputValue("fbInput");

embed.description =
embed.description + `\nFeedback: ${feedback}`;

return confirmation.update({
embeds: [embed],
components: [],
});
} catch (e) {
// timeout, remove button
return confirmation.editReply({
components: [],
});
}
} catch (e) {
// timeout, remove button
return message.edit({
components: [],
});
}
const feedbackButton = new ButtonBuilder()
.setCustomId("Feedback")
.setLabel("Give Feedback")
.setStyle(ButtonStyle.Primary);
message = await confirmation.update({
embeds: [embed],
components: [
new ActionRowBuilder().addComponents(feedbackButton),
],
});

try {
// Wait for feedback
confirmation = await message.awaitMessageComponent({
filter: collectorFilter,
time: 600_000,
});

const modal = new ModalBuilder()
.setCustomId("feedback")
.setTitle("Give some Feedback!");

// add some input components

try {
await confirmation.showModal(modal);
confirmation = await confirmation.awaitModalSubmit({
time: 300_000,
});
const feedback =
confirmation.fields.getTextInputValue("fbInput");

embed.description =
embed.description + `\nFeedback: ${feedback}`;

return confirmation.update({
embeds: [embed],
components: [],
});
} catch (e) {
// timeout, remove button
return confirmation.editReply({
components: [],
});
}
} catch (e) {
// timeout, remove button
return message.edit({
components: [],
});
}
4 replies
DIAdiscord.js - Imagine an app
Created by PurifiedWater on 11/4/2023 in #djs-questions
Cannot update embed after component interaction
No description
4 replies