You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
3.2 KiB
73 lines
3.2 KiB
const {Command, Random, ErrorMessage, ErrorType} = require('../../lib.js');
|
|
const {EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle} = require('discord.js');
|
|
|
|
var Job = require('cron').CronJob;
|
|
|
|
class remind extends Command{
|
|
constructor(client){
|
|
super(client, {
|
|
name: 'remind',
|
|
aliases: ['remindme', 'reminder'],
|
|
description: `It will send you a message after the ammount of minutes you specified. Ex: !remindme "message" 5`
|
|
|
|
})
|
|
}
|
|
async run(message, args)
|
|
{
|
|
if(!args[1]) return new ErrorMessage(this.client).send(ErrorType.NoArguments, message);
|
|
if(isNaN(parseInt(args[1]))) return new ErrorMessage(this.client).send(ErrorType.Arguments,message);
|
|
var reminderMessage = args.slice(0,-1);
|
|
reminderMessage = new Array(reminderMessage).join(" ")
|
|
console.log('Reminder:', message.author.id, 'wants to be reminded of', reminderMessage, 'in', args[args.length-1]);
|
|
const embed = new EmbedBuilder()
|
|
const randomID = Random();
|
|
embed.setFooter({text:'Rem-chan on ', iconURL:"https://i.imgur.com/g6FSNhL.png"})
|
|
embed.setAuthor({name:"Rem-chan", iconURL:"https://i.imgur.com/g6FSNhL.png",url:'https://rem.wordfights.com/addtodiscord'});
|
|
embed.setColor(0x110809);
|
|
embed.setTimestamp()
|
|
embed.setTitle(`Reminder set.`)
|
|
embed.addFields({name:'With the message:', value:reminderMessage})
|
|
const row = new ActionRowBuilder()
|
|
.addComponents(
|
|
new ButtonBuilder()
|
|
.setCustomId(randomID+0)
|
|
.setLabel('Remove message.')
|
|
.setStyle(ButtonStyle.Primary),
|
|
);
|
|
const row1 = new ActionRowBuilder()
|
|
.addComponents(
|
|
new ButtonBuilder()
|
|
.setCustomId(randomID+1)
|
|
.setLabel('Remove reminder.')
|
|
.setStyle(ButtonStyle.Danger),
|
|
);
|
|
const filter = i => i.customId.slice(0, i.customId.length-1) === randomID;
|
|
message.channel.send({embeds: [embed], components: [row, row1] });
|
|
|
|
var timer = new Job(
|
|
new Date(new Date().setMinutes(new Date().getMinutes()+parseInt(args[args.length-1]))),
|
|
function() {
|
|
console.log('Reminder:', message.author.id, 'is being reminded of', reminderMessage, 'in', args[args.length-1]);
|
|
message.author.send(reminderMessage)
|
|
},
|
|
null,
|
|
true
|
|
);
|
|
|
|
const collector = message.channel.createMessageComponentCollector({ filter, time: 60000 });
|
|
collector.on('collect', async m =>
|
|
{
|
|
if(m.customId[m.customId.length-1]==1) timer.stop();
|
|
collector.stop();
|
|
message.delete();
|
|
m.message.delete();
|
|
});
|
|
collector.on('end', async m=>
|
|
{
|
|
message.delete();
|
|
m.message.delete()
|
|
})
|
|
|
|
}
|
|
}
|
|
module.exports = remind; |