nyx/commands/Utilities/report.js

80 lines
2.2 KiB
JavaScript
Raw Normal View History

2021-06-12 12:53:51 +02:00
const { Client, Message, MessageEmbed } = require("discord.js");
require("../../inlinereply");
module.exports = {
name: "report",
description: "Report a bug of the bot",
category: "Utilities",
run: async (client, message, args) => {
const questions = [
"Describe the bug",
//"question 2"
];
let collectCounter = 0;
let endCounter = 0;
const filter = m => m.author.id === message.author.id;
message.inlineReply("Check your dm.");
const appStart = await message.author.send(
new MessageEmbed()
.setAuthor(message.author.username, message.author.displayAvatarURL())
.setDescription(questions[collectCounter++])
.setFooter(client.user.username)
.setTimestamp()
);
const channel = appStart.channel;
const collector = channel.createMessageCollector(filter);
collector.on("collect", () => {
if (collectCounter < questions.length) {
channel.send(
new MessageEmbed()
.setAuthor(
message.author.username,
message.author.displayAvatarURL()
)
.setDescription(questions[collectCounter++])
.setFooter(client.user.username)
.setTimestamp()
);
} else {
channel.send(
new MessageEmbed()
.setTitle("SUCCESS!")
.setDescription(
2021-06-13 06:09:00 +02:00
"You have reported a bug.\nPlease wait for us to solve it"
2021-06-12 12:53:51 +02:00
)
.setColor("GREEN")
);
collector.stop("fulfilled");
}
});
2021-06-13 06:09:00 +02:00
const appsChannel = client.channels.cache.get(client.ReportLog);
2021-06-12 12:53:51 +02:00
collector.on("end", (collected, reason) => {
if (reason === "fulfilled") {
let index = 1;
const mapedResponses = collected
.map(msg => {
return `${questions[endCounter++]}**\n->** ${msg.content}`;
})
.join("\n\n");
appsChannel.send(
new MessageEmbed()
.setAuthor(
message.author.tag,
message.author.displayAvatarURL({ dynamic: true })
)
2021-06-13 06:09:00 +02:00
.setTitle("New Bug")
2021-06-12 12:53:51 +02:00
.setDescription(mapedResponses)
.setColor("ORANGE")
.setTimestamp()
);
}
});
},
};