Status clearing and user command tracking

master
Kit Kasune 4 years ago
parent c3b3c0840e
commit c3be0dbc13
  1. 20
      commands/clearstatus.js
  2. 9
      events/message.js
  3. 7
      util/oncommand.js

@ -0,0 +1,20 @@
const Discord = require('discord.js');
const mongooes = require('mongoose');
const UserData = require('../models/user');
module.exports = {
name: "clearstatus",
aliases: ['statusclear', 'cs'],
help: "Clears your status, if you have one set. Does not take any arguments.",
async execute(message, msg, args, cmd, prefix, mention, client) {
let tu = await UserData.findOne({uid: message.author.id});
if (!tu && !tu.statusmsg.length) {
return message.reply("you have no status for me to clear");
}
if (tu.statusclearmode === "auto") {return;}
tu.statusmsg = '';
tu.statustype = '';
tu.save();
return message.reply("welcome back! I cleared your status.");
}
};

@ -1,6 +1,8 @@
const Discord = require('discord.js');
const mongoose = require('mongoose');
const chalk = require('chalk');
const wait = require('../util/wait');
const UserData = require('../models/user');
module.exports = async (client, message) => {
if (message.author.bot) {return undefined;}
@ -23,6 +25,13 @@ module.exports = async (client, message) => {
var cmd = args.shift().toLowerCase().trim();
if (mention && message.guild) {require('../util/mention')(message, msg, args, cmd, prefix, mention, client);}
let tu = await UserData.findOne({uid: message.author.id});
if (tu && tu.statusmsg.length && tu.statusclearmode === 'auto') {
tu.statusmsg = '';
tu.statustype = '';
tu.save();
message.reply('Hey there! You asked me to clear your status when you send a message next, so I went ahead and did that for you.');
}
try {
if (msg.startsWith(prefix) || msg.startsWith(`<@${client.user.id}>`) || msg.startsWith(`<@!${client.user.id}>`)) {

@ -1,6 +1,7 @@
const Discord = require('discord.js');
const mongoose = require('mongoose');
const chalk = require('chalk');
const UserData = require('../models/user');
module.exports = async (message, msg, args, cmd, prefix, mention, client) => {
/*const config = client.config;
@ -15,6 +16,10 @@ module.exports = async (message, msg, args, cmd, prefix, mention, client) => {
let botData = await require('../models/bot').findOne({finder: 'lel'});
botData.commands = botData.commands + 1;
botData.save();
let tu = await UserData.findOne({uid: message.author.id})
? await UserData.findOne({uid: message.author.id})
: new UserData({uid: message.author.id});
tu.commands = tu.commands + 1;
tu.save();
};
Loading…
Cancel
Save