1 |
rakin |
27 |
const { emoji } = require('../src/emoji'); |
2 |
|
|
const MessageEmbed = require('../src/MessageEmbed'); |
3 |
rakin |
49 |
const { getUser } = require('../src/UserInput'); |
4 |
rakin |
27 |
|
5 |
|
|
module.exports = { |
6 |
|
|
async handle(msg, cm) { |
7 |
|
|
if (cm.args[0] === undefined) { |
8 |
|
|
await msg.reply({ |
9 |
|
|
embeds: [ |
10 |
|
|
new MessageEmbed() |
11 |
|
|
.setColor('#f14a60') |
12 |
|
|
.setDescription('This command requires at least 2 arguments') |
13 |
|
|
] |
14 |
|
|
}); |
15 |
|
|
|
16 |
|
|
return; |
17 |
|
|
} |
18 |
|
|
|
19 |
rakin |
49 |
try { |
20 |
|
|
var user = await getUser(cm.args[0], msg); |
21 |
rakin |
27 |
|
22 |
rakin |
49 |
console.log(user); |
23 |
|
|
|
24 |
|
|
if (!user) { |
25 |
|
|
throw new Error('Invalid User'); |
26 |
|
|
} |
27 |
rakin |
27 |
} |
28 |
rakin |
49 |
catch (e) { |
29 |
|
|
console.log(e); |
30 |
rakin |
27 |
|
31 |
|
|
await msg.reply({ |
32 |
|
|
embeds: [ |
33 |
|
|
new MessageEmbed() |
34 |
|
|
.setColor('#f14a60') |
35 |
rakin |
49 |
.setDescription(`Invalid user given.`) |
36 |
rakin |
27 |
] |
37 |
|
|
}); |
38 |
|
|
|
39 |
|
|
return; |
40 |
|
|
} |
41 |
|
|
|
42 |
|
|
const args = [...cm.args]; |
43 |
|
|
args.shift(); |
44 |
|
|
|
45 |
|
|
if (msg.attachments.size < 1 && args.length < 1) { |
46 |
|
|
await msg.reply({ |
47 |
|
|
embeds: [ |
48 |
|
|
new MessageEmbed() |
49 |
|
|
.setColor('#f14a60') |
50 |
|
|
.setDescription('This command requires at least 2 arguments') |
51 |
|
|
] |
52 |
|
|
}); |
53 |
|
|
|
54 |
|
|
return; |
55 |
|
|
} |
56 |
|
|
|
57 |
|
|
const content = args.join(' '); |
58 |
|
|
|
59 |
|
|
try { |
60 |
|
|
let message = {}; |
61 |
|
|
|
62 |
|
|
if (content.trim() != '') { |
63 |
|
|
message.content = content; |
64 |
|
|
} |
65 |
|
|
|
66 |
|
|
if (msg.attachments && msg.attachments.size > 0) { |
67 |
|
|
message.files = msg.attachments.map(a => { |
68 |
|
|
return { |
69 |
|
|
attachment: a.proxyURL, |
70 |
|
|
name: a.name |
71 |
|
|
} |
72 |
|
|
}); |
73 |
|
|
} |
74 |
|
|
|
75 |
|
|
await user.send(message); |
76 |
|
|
|
77 |
|
|
await msg.reply({ |
78 |
|
|
content: (await emoji('check'))?.toString() + " Message Sent!" |
79 |
|
|
}); |
80 |
|
|
} |
81 |
|
|
catch(e) { |
82 |
|
|
console.log(e); |
83 |
|
|
|
84 |
|
|
await msg.reply({ |
85 |
|
|
content: "Message could not be sent, maybe the user has disabled DMs?" |
86 |
|
|
}); |
87 |
|
|
} |
88 |
|
|
} |
89 |
|
|
}; |