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

Contents of /trunk/commands/expire.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 45 - (show annotations)
Mon Jul 29 17:28:20 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: text/javascript
File size: 1777 byte(s)
Release version 1.8.0

* Added setTimeout() and DB combination support so that the timeouts would never get lost even if the bot stops
* Added messages scheduling, expiring and both in one support
1 const MessageEmbed = require("../src/MessageEmbed");
2 const { setTimeoutv2 } = require("../src/setTimeout");
3 const path = require('path');
4 const ms = require("ms");
5
6 module.exports = {
7 async handle(msg, cm) {
8 if (typeof cm.args[1] === 'undefined') {
9 await msg.reply({
10 embeds: [
11 new MessageEmbed()
12 .setColor('#f14a60')
13 .setDescription(`This command requires at least two arguments.`)
14 ]
15 });
16
17 return;
18 }
19
20 const time = ms(cm.args[0]);
21
22 if (!time) {
23 await msg.reply({
24 embeds: [
25 new MessageEmbed()
26 .setColor('#f14a60')
27 .setDescription(`Invalid time interval given.`)
28 ]
29 });
30
31 return;
32 }
33
34 var ch = await msg.mentions?.channels?.last();
35 let text;
36 let args = [...cm.args];
37 args.shift();
38
39 if (typeof ch !== 'object' || ch === null) {
40 ch = msg.channel;
41 }
42 else {
43 args.pop();
44 }
45
46 text = args.join(' ');
47
48 try {
49 const message = await ch.send({
50 content: text
51 });
52
53 await setTimeoutv2('expire.js', time, message.id, ch.id, msg.guild.id);
54 }
55 catch(e) {
56 console.log(e);
57
58 await msg.reply({
59 embeds: [
60 new MessageEmbed()
61 .setColor('#f14a60')
62 .setDescription(`I don't have enough permission to send messages on this channel.`)
63 ]
64 });
65
66 return;
67 }
68
69 await msg.react('⏰');
70 }
71 };

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26