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 ] ) {
2020-03-04 02:08:04 +01:00
this . client . users . resolve ( user . id ) . send ( ` **Message from the dev:** \n ${ text } \n **If you wish to respond use the feedback command** ` , { files : [ Attachment [ 0 ] . url ] } )
2019-04-15 22:23:26 +02:00
. 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 {
2020-03-04 02:08:04 +01:00
this . client . users . resolve ( user . id ) . send ( ` **Message from the dev:** \n ${ text } \n **If you wish to respond use the feedback command** ` )
2019-04-15 22:23:26 +02:00
. 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 ;