2022-08-28 17:03:15 +02:00
import { SlashCommandBuilder } from 'discord.js' ;
import { EmbedBuilder } from 'discord.js' ;
2022-06-17 12:50:07 +02:00
const { feedbackChannelId } = process . env ;
export default {
data : new SlashCommandBuilder ( )
. setName ( 'feedback' )
. setDescription ( 'Send a feedback to the developer.' )
. addStringOption ( option =>
option . setName ( 'feedback' )
. setDescription ( 'The message you want to send me.' )
2022-09-14 11:30:45 +02:00
. setRequired ( true ) )
. addAttachmentOption ( option =>
option . setName ( 'image' )
. setDescription ( 'Optional attachment.' )
. setRequired ( false ) ) ,
2022-08-28 17:03:15 +02:00
category : 'utility' ,
async execute ( interaction , args ) {
const Embed = new EmbedBuilder ( )
2023-09-13 20:56:06 +02:00
. setAuthor ( { name : ` ${ interaction . user . username } ( ${ interaction . user . id } ) ` , iconURL : interaction . user . avatarURL ( ) } )
2022-06-17 12:50:07 +02:00
. setTimestamp ( ) ;
2022-08-28 17:03:15 +02:00
if ( interaction . guild ) Embed . addFields ( { name : 'Guild' , value : ` ${ interaction . guild . name } ( ${ interaction . guild . id } ) ` , inline : true } ) ;
2022-09-01 01:43:59 +02:00
Embed . addFields ( { name : 'Feedback' , value : args . feedback , inline : true } ) ;
2022-06-17 12:50:07 +02:00
// Don't let new account use this command to prevent spam
const date = new Date ( ) ;
if ( interaction . user . createdAt > date . setDate ( date . getDate ( ) - 7 ) ) {
2022-07-01 21:24:39 +02:00
return interaction . reply ( { content : '❌ Your account is too new to be able to use this command!' , ephemeral : true } ) ;
2022-06-17 12:50:07 +02:00
}
const channel = interaction . client . channels . resolve ( feedbackChannelId ) ;
2022-09-14 11:30:45 +02:00
if ( args . image ) {
channel . send ( { embeds : [ Embed ] , files : [ args . image ] } ) ;
}
else {
channel . send ( { embeds : [ Embed ] } ) ;
}
2022-06-17 12:50:07 +02:00
await interaction . reply ( { content : 'Your feedback has been sent! Don\'t forget to have dm open if you want to get an answer from the dev!' , ephemeral : true } ) ;
} ,
} ;