nodbot/dot-commands/request.js
Skylar Grant 7b504a2312
All checks were successful
NodBot PE Dockerization / build (push) Successful in 21s
Re-fix variable ref
2026-10-01 15:32:38 -04:00

29 lines
1.1 KiB
JavaScript

const fn = require('../functions.js');
module.exports = {
name: 'request',
description: 'Submit a request to the bot developer.',
usage: '<request or feedback>.request',
execute(message, commandData) {
// Get the request information from the command data that was passed in
const requestText = commandData.args;
const messageUrl = message.url;
const requester = message.author.username;
try {
fn.upload.request(requester, requestText, messageUrl, message.client);
// Set the content to sent a text embed notifying the user of success
commandData.content = `Your request has been submitted!\nRequest: ${requestText}`;
const replyEmbed = fn.embeds.text(commandData);
message.reply({ embeds: [ replyEmbed ]});
} catch(err) {
console.error(err);
commandData.content = "An error occurred while saving the request, please try again later.";
const replyEmbed = fn.embeds.text(commandData);
message.reply({ embeds: [ replyEmbed ]});
const errorEmbed = fn.embeds.error(`An error has occurred in command ${this.name}:\n${err}`);
fn.sendAlert(errorEmbed, message.client);
}
},
};