-
Notifications
You must be signed in to change notification settings - Fork 0
/
echo.js
40 lines (35 loc) · 942 Bytes
/
echo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
module.exports = {
name: 'echo',
description: 'Send a message to a user or channel',
syntax: 'q.echo ( user / channel ) id content',
async execute(args) {
let [client, message] = args
let command = message.content.split(' ')
if (command.length < 4) {
await message.channel.send('# Error\nMinimum 3 arguments required')
return
}
let content = ""
for (let i = 3; i < command.length; i++) {
content += `${command[i]} `
}
let obj_id = command[2]
if (command[1] === 'user') {
client.guilds.cache.forEach(guild => {
let u = guild.members.cache.get(obj_id)
if (u) {
u.send(content)
message.channel.send(`**Sent to user:**\n${content}`)
}
})
} else if (command[1] === 'channel') {
client.guilds.cache.forEach(guild => {
let c = guild.channels.cache.get(obj_id)
if (c) {
c.send(content)
message.channel.send(`**Sent to channel:**\n${content}`)
}
})
}
}
}