/[sudobot]/trunk/commands/noteget.js
ViewVC logotype

Annotation of /trunk/commands/noteget.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5 - (hide annotations)
Mon Jul 29 17:28:11 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: text/javascript
File size: 1846 byte(s)
Added base commands
1 rakin 5 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     await app.db.get("SELECT * FROM notes WHERE id = ? AND guild_id = ?", [cm.args[0], msg.guild.id], async (err, data) => {
18     if (err) {
19     console.log(err);
20     }
21    
22     if (data === undefined) {
23     await msg.reply({
24     embeds: [
25     new MessageEmbed()
26     .setColor('#f14a60')
27     .setDescription('No note found')
28     ]
29     });
30    
31     return;
32     }
33    
34     let user;
35    
36     try {
37     user = await msg.guild.members.fetch(data.user_id);
38     user = {
39     name: user.user.tag,
40     iconURL: user.displayAvatarURL()
41     };
42     }
43     catch(e) {
44     user = {
45     name: "User " + data.user_id
46     };
47     }
48    
49     await msg.reply({
50     embeds: [
51     new MessageEmbed()
52     .setDescription(data.content)
53     .setAuthor(user)
54     .setFields([
55     {
56     name: "ID",
57     value: data.id + ''
58     }
59     ])
60     .setTimestamp(new Date(data.date))
61     ]
62     });
63     });
64    
65     }
66     };

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26