mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Allow deleting reminders
This commit is contained in:
@@ -268,7 +268,7 @@ in the appropriate channel's topic to use it.
|
||||
|
||||
## Commands
|
||||
|
||||
Total: 563
|
||||
Total: 564
|
||||
|
||||
### Utility:
|
||||
|
||||
@@ -849,6 +849,11 @@ Total: 563
|
||||
* **soundboard:** Plays a sound in a voice channel.
|
||||
* **vocodes:** Speak text like a variety of famous figures.
|
||||
|
||||
### Reminders:
|
||||
|
||||
* **delete-reminder:** Deletes your reminder.
|
||||
* **remind:** Sets a reminder.
|
||||
|
||||
### Phone:
|
||||
|
||||
* **admin-phone:** Starts an admin phone call with a server. (Owner-Only)
|
||||
@@ -870,7 +875,6 @@ Total: 563
|
||||
* **dating:** Find the person of your dreams with this dating system!
|
||||
* **portal-send:** Send a message to a portal channel.
|
||||
* **prune:** Deletes up to 99 messages from the current channel.
|
||||
* **remind:** Sets a reminder.
|
||||
* **rename-all:** Renames every member of the server. (Owner-Only)
|
||||
* **screenshot:** Takes a screenshot of any webpage.
|
||||
* **smilebasic:** Responds with a ZIP file for a SmileBASIC project.
|
||||
|
||||
@@ -36,6 +36,7 @@ client.registry
|
||||
['edit-text', 'Text Manipulation'],
|
||||
['edit-number', 'Number Manipulation'],
|
||||
['voice', 'Play Audio'],
|
||||
['remind', 'Reminders'],
|
||||
['phone', 'Phone'],
|
||||
['code', 'Coding Tools'],
|
||||
['other', 'Other'],
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
const Command = require('../../structures/Command');
|
||||
|
||||
module.exports = class DeleteReminderCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'delete-reminder',
|
||||
aliases: ['delete-remind', 'delete-timer', 'del-reminder', 'del-remind', 'del-timer'],
|
||||
group: 'remind',
|
||||
memberName: 'remind',
|
||||
description: 'Deletes your reminder.'
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
const exists = await this.client.timers.exists(msg.channel.id, msg.author.id);
|
||||
if (!exists) return msg.reply('You do not have a timer set in this channel.');
|
||||
await this.client.timers.deleteTimer(msg.channel.id, msg.author.id);
|
||||
return msg.say('🕰️ Your timer has been deleted.');
|
||||
}
|
||||
};
|
||||
@@ -7,7 +7,7 @@ module.exports = class RemindCommand extends Command {
|
||||
super(client, {
|
||||
name: 'remind',
|
||||
aliases: ['timer', 'remind-me'],
|
||||
group: 'other',
|
||||
group: 'remind',
|
||||
memberName: 'remind',
|
||||
description: 'Sets a reminder.',
|
||||
args: [
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "121.2.2",
|
||||
"version": "121.3.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -5,7 +5,7 @@ const winston = require('winston');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const Redis = require('./Redis');
|
||||
const TimerManager = require('./timer/TimerManager');
|
||||
const TimerManager = require('./remind/TimerManager');
|
||||
const PokemonStore = require('./pokemon/PokemonStore');
|
||||
const MemePosterClient = require('./MemePoster');
|
||||
const activities = require('../assets/json/activity');
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
module.exports = class TimerManager {
|
||||
constructor(client) {
|
||||
Object.defineProperty(this, 'client', { value: client });
|
||||
|
||||
this.timeouts = new Map();
|
||||
}
|
||||
|
||||
async fetchAll() {
|
||||
@@ -23,9 +25,16 @@ module.exports = class TimerManager {
|
||||
}
|
||||
}, time);
|
||||
if (updateRedis) await this.client.redis.hset('timer', { [`${channelID}-${userID}`]: JSON.stringify(data) });
|
||||
this.timeouts.set(`${channelID}-${userID}`, timeout);
|
||||
return timeout;
|
||||
}
|
||||
|
||||
deleteTimer(channelID, userID) {
|
||||
clearTimeout(this.timeouts.get(`${channelID}-${userID}`));
|
||||
this.timeouts.delete(`${channelID}-${userID}`);
|
||||
return this.client.redis.hdel('timer', `${channelID}-${userID}`);
|
||||
}
|
||||
|
||||
exists(channelID, userID) {
|
||||
return this.client.redis.hexists('timer', `${channelID}-${userID}`);
|
||||
}
|
||||
Reference in New Issue
Block a user