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.
Luno/util/mention.js

24 lines
1.4 KiB

4 years ago
const Discord = require('discord.js');
const moment = require('moment');
const UserData = require('../models/user');
const GuildSettings = require('../models/guild');
module.exports = async(message, msg, args, cmd, prefix, mention, client) => {
let tu = await UserData.findOne({uid: mention.id});
let tg = message.guild ? await GuildSettings.findOne({gid: message.guild.id}) : null;
if (tg && tg.nostatus) {return;}
if (client.misc.statusPings.has(message.guild.id) && client.misc.statusPings.get(message.guild.id).has(mention.id) && new Date().getTime() - client.misc.statusPings.get(message.guild.id).get(mention.id).getTime() < 300000) {return;}
if (tu && tu.statusmsg.length) {
if (!client.misc.statusPings.has(message.guild.id)) {client.misc.statusPings.set(message.guild.id, new Discord.Collection());}
client.misc.statusPings.get(message.guild.id).set(mention.id, new Date());
4 years ago
let m = await message.channel.send(new Discord.MessageEmbed()
.setAuthor(mention.tag, mention.avatarURL())
.setDescription(`That user ${tu.statustype === 'dnd' ? 'wishes not to be disturbed' : 'is AFK'}. Reason: ${tu.statusmsg}.${tu.statussetat ? `\n\n(This status was set ${moment(tu.statussetat.getTime()).fromNow()})` : ''}`)
4 years ago
.setColor('328ba8')
);
4 years ago
await require('../util/wait')(10000);
m.delete().catch((e) => {console.log(e);});
//console.log(m);
}
};