nyx/command/Utilities/suggest.js

95 lines
2.8 KiB
JavaScript
Raw Normal View History

2022-10-26 12:38:28 +02:00
const { EmbedBuilder } = require("discord.js");
2021-09-06 12:38:25 +02:00
module.exports = {
name: "suggest",
description: "Make a suggestion of the bot",
category: "Utilities",
2022-10-26 12:38:28 +02:00
2021-09-06 12:38:25 +02:00
run: async (client, interaction, args) => {
const questions = [
"Describe the suggestion",
// "question 2"
2021-09-06 12:38:25 +02:00
];
let collectCounter = 0;
let endCounter = 0;
const filter = m => m.author.id === interaction.user.id;
interaction.followUp("Check your dm.");
2021-09-06 12:38:25 +02:00
const appStart = await interaction.user.send({
embeds: [
2022-10-26 12:38:28 +02:00
new EmbedBuilder()
2021-09-06 12:38:25 +02:00
.setAuthor(
interaction.user.username,
interaction.user.displayAvatarURL()
)
.setDescription(questions[collectCounter++])
2022-10-26 12:38:28 +02:00
.setFooter({
text: `Made by ${client.author}`,
iconURL: client.user.displayAvatarURL(),
})
2021-09-06 12:38:25 +02:00
.setTimestamp(),
],
});
const channel = appStart.channel;
const collector = channel.createMessageCollector({ filter });
2021-09-06 12:38:25 +02:00
collector.on("collect", () => {
if (collectCounter < questions.length) {
channel.send({
embeds: [
2022-10-26 12:38:28 +02:00
new EmbedBuilder()
2021-09-06 12:38:25 +02:00
.setAuthor(
interaction.user.username,
interaction.user.displayAvatarURL()
)
.setDescription(questions[collectCounter++])
2022-10-26 12:38:28 +02:00
.setFooter({
text: `Made by ${client.author}`,
iconURL: client.user.displayAvatarURL(),
})
2021-09-06 12:38:25 +02:00
.setTimestamp(),
],
});
} else {
channel.send({
embeds: [
2022-10-26 12:38:28 +02:00
new EmbedBuilder()
2021-09-06 12:38:25 +02:00
.setTitle("SUCCESS!")
.setDescription(
"You have sent a suggestion.\nPlease wait for us to review it"
)
.setColor("GREEN")
2022-10-26 12:38:28 +02:00
.setFooter({
text: `Made by ${client.author}`,
iconURL: client.user.displayAvatarURL(),
})
2021-09-06 12:38:25 +02:00
.setTimestamp(),
],
});
collector.stop("fulfilled");
}
});
const appsChannel = client.channels.cache.get(client.config.Config);
2021-09-06 12:38:25 +02:00
collector.on("end", (collected, reason) => {
if (reason === "fulfilled") {
const mapedResponses = collected
.map(msg => {
return `${questions[endCounter++]}**\n->** ${msg.content}`;
})
.join("\n\n");
appsChannel.send({
embeds: [
2022-10-26 12:38:28 +02:00
new EmbedBuilder()
2021-09-06 12:38:25 +02:00
.setAuthor(
interaction.user.tag,
2021-09-06 12:38:25 +02:00
interaction.user.displayAvatarURL({ dynamic: true })
)
.setTitle("New Suggestion")
.setDescription(mapedResponses)
.setColor("ORANGE")
.setTimestamp(),
],
});
}
});
},
};