Haha-Yes/commands/utility/feedback.js

60 lines
1.6 KiB
JavaScript
Raw Normal View History

2018-12-30 01:20:24 +01:00
const { Command } = require('discord-akairo');
2018-09-27 15:22:36 +02:00
const { feedbackChannel } = require('../../config.json');
const feedbackID = require('../../json/feedbackID.json');
2018-12-25 19:17:07 +01:00
2018-12-30 01:20:24 +01:00
class FeedbackCommand extends Command {
2019-01-02 08:09:45 +01:00
constructor() {
super('feedback', {
aliases: ['feedback'],
category: 'utility',
2019-11-09 12:04:01 +01:00
clientPermissions: ['SEND_MESSAGES'],
2019-01-02 08:09:45 +01:00
args: [
{
id: 'text',
2019-01-10 20:45:29 +01:00
type: 'string',
2019-06-23 03:41:59 +02:00
prompt: {
start: 'What do you want to say to the owner?',
},
2019-01-10 20:45:29 +01:00
match: 'rest'
},
{
id: 'reply',
match: 'option',
flag: '--reply',
},
2019-01-02 08:09:45 +01:00
],
description: {
2018-12-30 01:20:24 +01:00
content: 'Send feedback to the bot owner',
usage: '[What do you want to say]',
examples: ['Hello, i just wanted to say hi!']
}
2019-01-02 08:09:45 +01:00
});
}
2018-09-27 15:22:36 +02:00
2019-01-02 08:09:45 +01:00
async exec(message,args) {
const Embed = this.client.util.embed()
.setAuthor(`${message.author.tag} (${message.author.id})`, message.author.displayAvatarURL())
.setTimestamp();
if (message.guild) Embed.addField('Guild', `${message.guild.name} (${message.guild.id})`, true);
Embed.addField('Feedback', args.text);
if (feedbackID[args.reply]) {
Embed.addField('Responding to', feedbackID[args.reply]);
}
// Don't let new account use this command to prevent spam, if they have an UUID its fine to skip it
2019-10-05 22:17:19 +02:00
let date = new Date();
if (message.author.createdAt > date.setDate(date.getDate() - 7)) {
return message.channel.send('Your account is too new to be able to use this command!');
}
const channel = this.client.channels.resolve(feedbackChannel);
2019-03-30 15:19:29 +01:00
channel.send({embed: Embed});
2019-11-09 12:04:01 +01:00
2019-01-02 08:09:45 +01:00
message.channel.send('Your feedback has been sent!');
}
2018-12-30 01:20:24 +01:00
}
module.exports = FeedbackCommand;