2021-09-06 12:38:25 +02:00
|
|
|
const { MessageEmbed } = require("discord.js");
|
|
|
|
module.exports = {
|
|
|
|
name: "suggest",
|
|
|
|
description: "Make a suggestion of the bot",
|
|
|
|
category: "Utilities",
|
|
|
|
type: "CHAT_INPUT",
|
|
|
|
run: async (client, interaction, args) => {
|
|
|
|
const questions = [
|
|
|
|
"Describe the suggestion",
|
2021-11-18 18:56:42 +01:00
|
|
|
// "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;
|
2021-11-18 18:56:42 +01:00
|
|
|
interaction.followUp("Check your dm.");
|
2021-09-06 12:38:25 +02:00
|
|
|
const appStart = await interaction.user.send({
|
|
|
|
embeds: [
|
|
|
|
new MessageEmbed()
|
|
|
|
.setAuthor(
|
|
|
|
interaction.user.username,
|
|
|
|
interaction.user.displayAvatarURL()
|
|
|
|
)
|
|
|
|
.setDescription(questions[collectCounter++])
|
2021-11-18 18:56:42 +01:00
|
|
|
.setFooter(`Made by ${client.author}`, client.user.displayAvatarURL())
|
2021-09-06 12:38:25 +02:00
|
|
|
.setTimestamp(),
|
|
|
|
],
|
|
|
|
});
|
|
|
|
const channel = appStart.channel;
|
2021-11-18 18:56:42 +01:00
|
|
|
const collector = channel.createMessageCollector({ filter });
|
2021-09-06 12:38:25 +02:00
|
|
|
collector.on("collect", () => {
|
|
|
|
if (collectCounter < questions.length) {
|
|
|
|
channel.send({
|
|
|
|
embeds: [
|
|
|
|
new MessageEmbed()
|
|
|
|
.setAuthor(
|
|
|
|
interaction.user.username,
|
|
|
|
interaction.user.displayAvatarURL()
|
|
|
|
)
|
|
|
|
.setDescription(questions[collectCounter++])
|
2021-11-18 18:56:42 +01:00
|
|
|
.setFooter(
|
|
|
|
`Made by ${client.author}`,
|
|
|
|
client.user.displayAvatarURL()
|
|
|
|
)
|
2021-09-06 12:38:25 +02:00
|
|
|
.setTimestamp(),
|
|
|
|
],
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
channel.send({
|
|
|
|
embeds: [
|
|
|
|
new MessageEmbed()
|
|
|
|
.setTitle("SUCCESS!")
|
|
|
|
.setDescription(
|
|
|
|
"You have sent a suggestion.\nPlease wait for us to review it"
|
|
|
|
)
|
|
|
|
.setColor("GREEN")
|
2021-11-18 18:56:42 +01:00
|
|
|
.setFooter(
|
|
|
|
`Made by ${client.author}`,
|
|
|
|
client.user.displayAvatarURL()
|
|
|
|
)
|
2021-09-06 12:38:25 +02:00
|
|
|
.setTimestamp(),
|
|
|
|
],
|
|
|
|
});
|
|
|
|
collector.stop("fulfilled");
|
|
|
|
}
|
|
|
|
});
|
2021-11-18 18:56:42 +01:00
|
|
|
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: [
|
|
|
|
new MessageEmbed()
|
|
|
|
.setAuthor(
|
2021-11-18 18:56:42 +01:00
|
|
|
interaction.user.tag,
|
2021-09-06 12:38:25 +02:00
|
|
|
interaction.user.displayAvatarURL({ dynamic: true })
|
|
|
|
)
|
|
|
|
.setTitle("New Suggestion")
|
|
|
|
.setDescription(mapedResponses)
|
|
|
|
.setColor("ORANGE")
|
|
|
|
.setTimestamp(),
|
|
|
|
],
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|