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

Annotation of /trunk/commands/note.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 11 - (hide annotations)
Mon Jul 29 17:28:13 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: text/javascript
File size: 1649 byte(s)
Initial release v1.0.0
1 rakin 5 const MessageEmbed = require("../src/MessageEmbed");
2    
3     module.exports = {
4     async handle(msg, cm) {
5     if (typeof cm.args[1] === 'undefined') {
6     await msg.reply({
7     embeds: [
8     new MessageEmbed()
9     .setColor('#f14a60')
10     .setDescription(`This command requires at least two arguments.`)
11     ]
12     });
13    
14     return;
15     }
16    
17     var user = await msg.mentions.members.first();
18     let content;
19    
20     let args = [...cm.args];
21     args.shift();
22    
23     await (content = args.join(' '));
24    
25     if (typeof user !== 'object') {
26     try {
27     user = await msg.guild.members.fetch(cm.args[0]);
28     }
29     catch(e) {
30    
31     }
32     }
33    
34     if (typeof user !== 'object') {
35     await msg.reply({
36     embeds: [
37     new MessageEmbed()
38     .setColor('#f14a60')
39     .setDescription(`Invalid user given.`)
40     ]
41     });
42    
43     return;
44     }
45    
46     this.note(user, content, msg);
47    
48     await msg.reply({
49     embeds: [
50     new MessageEmbed()
51 rakin 11 .setDescription(`A note has been added for ${user.user.tag}`) // TODO
52 rakin 5 ]
53     });
54     },
55     async note(user, content, msg) {
56     await app.db.get("INSERT INTO notes(user_id, guild_id, content, date) VALUES(?, ?, ?, ?)", [user.id, msg.guild.id, content, (new Date().toISOString())], async (err) => {
57     if (err) {
58     console.log(err);
59     }
60     });
61     }
62     };

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26