@ -1,5 +1,6 @@
const { Command } = require ( 'discord-akairo' ) ;
const { feedbackChannel } = require ( '../../config.json' ) ;
const feedbackID = require ( '../../json/feedbackID.json' ) ;
class FeedbackCommand extends Command {
constructor ( ) {
@ -15,7 +16,12 @@ class FeedbackCommand extends Command {
start : 'What do you want to say to the owner?' ,
} ,
match : 'rest'
}
} ,
{
id : 'reply' ,
match : 'option' ,
flag : '--reply' ,
} ,
] ,
description : {
content : 'Send feedback to the bot owner' ,
@ -26,19 +32,25 @@ class FeedbackCommand extends Command {
}
async exec ( message , args ) {
// Don't let account new account use this command to prevent spam
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
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 ) ;
const Embed = this . client . util . embed ( )
. setAuthor ( ` ${ message . author . username } ( ${ message . author . id } ) ` , message . author . displayAvatarURL ( ) ) ;
if ( message . guild ) Embed . addField ( 'Guild' , ` ${ message . guild . name } ( ${ message . guild . id } ) ` , true ) ;
Embed . addField ( 'Feedback' , args . text )
. setTimestamp ( ) ;
channel . send ( { embed : Embed } ) ;
message . channel . send ( 'Your feedback has been sent!' ) ;