1 |
const MessageEmbed = require("../src/MessageEmbed"); |
2 |
|
3 |
module.exports = { |
4 |
async handle(msg, cm) { |
5 |
if (typeof cm.args[0] === 'undefined') { |
6 |
await msg.reply({ |
7 |
embeds: [ |
8 |
new MessageEmbed() |
9 |
.setColor('#f14a60') |
10 |
.setDescription(`This command requires at least one argument.`) |
11 |
] |
12 |
}); |
13 |
|
14 |
return; |
15 |
} |
16 |
|
17 |
var user = await msg.mentions.members.first(); |
18 |
|
19 |
if (typeof user !== 'object') { |
20 |
try { |
21 |
user = await msg.guild.members.fetch(cm.args[0]); |
22 |
} |
23 |
catch(e) { |
24 |
|
25 |
} |
26 |
} |
27 |
|
28 |
if (typeof user !== 'object') { |
29 |
await msg.reply({ |
30 |
embeds: [ |
31 |
new MessageEmbed() |
32 |
.setColor('#f14a60') |
33 |
.setDescription(`Invalid user given.`) |
34 |
] |
35 |
}); |
36 |
|
37 |
return; |
38 |
} |
39 |
|
40 |
await app.db.all("SELECT * FROM notes WHERE user_id = ? AND guild_id = ?", [user.id, msg.guild.id], async (err, data) => { |
41 |
if (err) { |
42 |
console.log(err); |
43 |
} |
44 |
|
45 |
if (data === undefined || data.length < 1) { |
46 |
await msg.reply({ |
47 |
embeds: [ |
48 |
new MessageEmbed() |
49 |
.setColor('#f14a60') |
50 |
.setDescription('No notes found for user ' + user.user.tag) |
51 |
] |
52 |
}); |
53 |
|
54 |
return; |
55 |
} |
56 |
|
57 |
let desc = ''; |
58 |
let i = 1; |
59 |
|
60 |
for (let row of data) { |
61 |
desc += `\n\n**Note #${i}**\n${row.content}\nDate: ${new Date(row.date).toUTCString()}`; |
62 |
i++; |
63 |
} |
64 |
|
65 |
desc = desc.substring(1); |
66 |
|
67 |
await msg.reply({ |
68 |
embeds: [ |
69 |
new MessageEmbed() |
70 |
.setAuthor({ |
71 |
iconURL: user.displayAvatarURL(), |
72 |
name: user.user.tag |
73 |
}) |
74 |
.setDescription(desc) |
75 |
] |
76 |
}); |
77 |
}); |
78 |
|
79 |
} |
80 |
}; |