2018-12-30 03:35:25 +01:00
const { Command } = require ( 'discord-akairo' ) ;
class EvalCommand extends Command {
2019-01-02 08:09:45 +01:00
constructor ( ) {
super ( 'dm' , {
aliases : [ 'dm' , 'pm' ] ,
category : 'owner' ,
args : [
{
id : 'user' ,
type : 'user'
} ,
{
id : 'text' ,
2019-01-10 20:45:29 +01:00
type : 'string' ,
match : 'rest'
2019-01-02 08:09:45 +01:00
}
] ,
ownerOnly : 'true' ,
description : {
2018-12-30 03:35:25 +01:00
content : 'DM users' ,
usage : '[user id] [message]' ,
examples : [ '267065637183029248 hello i recived your feedback and...' ]
}
2019-01-02 08:09:45 +01:00
} ) ;
}
2018-12-30 03:35:25 +01:00
2019-01-02 08:09:45 +01:00
async exec ( message , args ) {
let user = args . user ;
let text = args . text ;
2018-12-30 03:39:59 +01:00
2019-01-02 08:09:45 +01:00
let Attachment = ( message . attachments ) . array ( ) ;
if ( Attachment [ 0 ] ) {
2019-04-15 22:23:26 +02:00
this . client . users . get ( user . id ) . send ( ` **Message from the dev:** \n ${ text } \n **If you wish to respond use the feedback command** ` , { files : [ Attachment [ 0 ] . url ] } )
. then ( ( ) => {
return message . channel . send ( ` DM sent to ${ user . username } ` ) ;
} )
. catch ( ( ) => {
return message . channel . send ( ` Could not send a DM to ${ user . username } ` ) ;
} ) ;
2019-01-02 08:09:45 +01:00
}
else {
2019-04-15 22:23:26 +02:00
this . client . users . get ( user . id ) . send ( ` **Message from the dev:** \n ${ text } \n **If you wish to respond use the feedback command** ` )
. then ( ( ) => {
return message . channel . send ( ` DM sent to ${ user . username } ` ) ;
} )
. catch ( ( ) => {
return message . channel . send ( ` Could not send a DM to ${ user . username } ` ) ;
} ) ;
2019-01-02 08:09:45 +01:00
}
2018-12-30 03:35:25 +01:00
2019-01-02 08:09:45 +01:00
}
2018-12-30 03:35:25 +01:00
}
module . exports = EvalCommand ;