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

Annotation of /trunk/commands/afk.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 30 - (hide annotations)
Mon Jul 29 17:28:17 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: text/javascript
File size: 1347 byte(s)
Improved AFK engine
1 rakin 26 const MessageEmbed = require("../src/MessageEmbed");
2    
3     module.exports = {
4     async handle(msg, cm) {
5     app.db.get("SELECT * FROM afk WHERE user_id = ?", [msg.author.id], async (err, data) => {
6     if (data) {
7     this.notAFK(msg, data);
8     }
9     else {
10 rakin 30 this.AFK(msg, cm);
11 rakin 26 }
12     });
13     },
14     async notAFK(msg, data) {
15     app.db.get('DELETE FROM afk WHERE user_id = ?', [msg.author.id], async (err) => {
16     await msg.channel.send({
17     embeds: [
18     new MessageEmbed()
19     .setDescription('You\'re no longer AFK. You had **' + data.mentions + '** mentions in the servers where SudoBot is joined.')
20     ]
21     });
22     });
23     },
24 rakin 30 async AFK(msg, cm) {
25     app.db.get('INSERT INTO afk(user_id, date, mentions, reason) VALUES(?, ?, ?, ?)', [msg.author.id, new Date().toISOString(), '0', cm.args[0] === undefined ? '' : cm.args.join(' ')], async (err) => {
26 rakin 26 await msg.channel.send({
27     embeds: [
28     new MessageEmbed()
29 rakin 30 .setDescription('Your\'re AFK now.' + (cm.args[0] === undefined ? '' : ` Your status has been updated to: **${cm.args.join(' ').replace(/\*/g, '\\*')}**`))
30 rakin 26 ]
31     });
32     });
33     }
34     };

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26