1 |
rakin |
25 |
const History = require("../src/History"); |
2 |
rakin |
5 |
const MessageEmbed = require("../src/MessageEmbed"); |
3 |
|
|
|
4 |
|
|
module.exports = { |
5 |
|
|
async handle(msg, cm) { |
6 |
|
|
if (typeof cm.args[0] === 'undefined') { |
7 |
|
|
await msg.reply({ |
8 |
|
|
embeds: [ |
9 |
|
|
new MessageEmbed() |
10 |
|
|
.setColor('#f14a60') |
11 |
|
|
.setDescription(`This command requires at least one argument.`) |
12 |
|
|
] |
13 |
|
|
}); |
14 |
|
|
|
15 |
|
|
return; |
16 |
|
|
} |
17 |
|
|
|
18 |
|
|
await app.db.get("SELECT * FROM notes WHERE id = ? AND guild_id = ?", [cm.args[0], msg.guild.id], async (err, data) => { |
19 |
|
|
if (err) { |
20 |
|
|
console.log(err); |
21 |
|
|
} |
22 |
|
|
|
23 |
|
|
if (data === undefined) { |
24 |
|
|
await msg.reply({ |
25 |
|
|
embeds: [ |
26 |
|
|
new MessageEmbed() |
27 |
|
|
.setColor('#f14a60') |
28 |
|
|
.setDescription('No note found') |
29 |
|
|
] |
30 |
|
|
}); |
31 |
|
|
|
32 |
|
|
return; |
33 |
|
|
} |
34 |
|
|
|
35 |
|
|
await app.db.get('DELETE FROM notes WHERE id = ? AND guild_id = ?', [cm.args[0], msg.guild.id], async (err) => { |
36 |
|
|
if (err) { |
37 |
|
|
console.log(err); |
38 |
|
|
} |
39 |
|
|
|
40 |
rakin |
25 |
|
41 |
|
|
await History.create(user.id, msg.guild, 'notedel', msg.author.id, async (data2) => { |
42 |
|
|
await msg.reply({ |
43 |
|
|
embeds: [ |
44 |
|
|
new MessageEmbed() |
45 |
|
|
.setDescription('Note has been deleted') |
46 |
|
|
] |
47 |
|
|
}); |
48 |
rakin |
5 |
}); |
49 |
|
|
}); |
50 |
|
|
}); |
51 |
|
|
|
52 |
|
|
} |
53 |
|
|
}; |