mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-25 14:21:41 +02:00
Limit Reminder Title Length
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
|
const { shorten } = require('../../util/Util');
|
||||||
|
|
||||||
module.exports = class RemindCommand extends Command {
|
module.exports = class RemindCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -24,7 +25,7 @@ module.exports = class RemindCommand extends Command {
|
|||||||
if (exists) return msg.reply('Only one reminder can be set per channel per user.');
|
if (exists) return msg.reply('Only one reminder can be set per channel per user.');
|
||||||
const timeMs = time.startDate.getTime() - Date.now();
|
const timeMs = time.startDate.getTime() - Date.now();
|
||||||
const display = moment().add(timeMs, 'ms').fromNow();
|
const display = moment().add(timeMs, 'ms').fromNow();
|
||||||
const title = time.eventTitle || 'something';
|
const title = time.eventTitle ? shorten(time.eventTitle, 500) : 'something';
|
||||||
await this.client.timers.setTimer(msg.channel.id, timeMs, msg.author.id, title);
|
await this.client.timers.setTimer(msg.channel.id, timeMs, msg.author.id, title);
|
||||||
return msg.say(`🕰️ Okay, I will remind you **"${title}"** ${display}.`);
|
return msg.say(`🕰️ Okay, I will remind you **"${title}"** ${display}.`);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "119.44.1",
|
"version": "119.44.2",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
const Redis = require('../Redis');
|
|
||||||
|
|
||||||
module.exports = class TimerManager {
|
module.exports = class TimerManager {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
Object.defineProperty(this, 'client', { value: client });
|
Object.defineProperty(this, 'client', { value: client });
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchAll() {
|
async fetchAll() {
|
||||||
const timers = await Redis.db.hgetall('timer');
|
const timers = await this.client.redis.hgetall('timer');
|
||||||
for (let data of Object.values(timers)) {
|
for (let data of Object.values(timers)) {
|
||||||
data = JSON.parse(data);
|
data = JSON.parse(data);
|
||||||
await this.setTimer(data.channelID, new Date(data.time) - new Date(), data.userID, data.title, false);
|
await this.setTimer(data.channelID, new Date(data.time) - new Date(), data.userID, data.title, false);
|
||||||
@@ -21,14 +19,14 @@ module.exports = class TimerManager {
|
|||||||
const channel = await this.client.channels.fetch(channelID);
|
const channel = await this.client.channels.fetch(channelID);
|
||||||
await channel.send(`🕰️ <@${userID}>, you wanted me to remind you of: **"${title}"**.`);
|
await channel.send(`🕰️ <@${userID}>, you wanted me to remind you of: **"${title}"**.`);
|
||||||
} finally {
|
} finally {
|
||||||
await Redis.db.hdel('timer', `${channelID}-${userID}`);
|
await this.client.redis.hdel('timer', `${channelID}-${userID}`);
|
||||||
}
|
}
|
||||||
}, time);
|
}, time);
|
||||||
if (updateRedis) await Redis.db.hset('timer', { [`${channelID}-${userID}`]: JSON.stringify(data) });
|
if (updateRedis) await this.client.redis.hset('timer', { [`${channelID}-${userID}`]: JSON.stringify(data) });
|
||||||
return timeout;
|
return timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
exists(channelID, userID) {
|
exists(channelID, userID) {
|
||||||
return Redis.db.hexists('timer', `${channelID}-${userID}`);
|
return this.client.redis.hexists('timer', `${channelID}-${userID}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user