Status warning toggling

master
Kit Kasune 4 years ago
parent f6645d6520
commit d31c9a336c
  1. 21
      commands/togglestatuses.js
  2. 3
      models/guild.js
  3. 2
      models/user.js
  4. 2
      template.js
  5. 3
      util/mention.js

@ -0,0 +1,21 @@
const Discord = require('discord.js');
const GuildSettings = require('../models/guild');
module.exports = {
name: "togglestatuses",
aliases: ['ts', 'tsw', 'togglestatuswarnings', 'togglestatus', 'statustoggle', 'statusestoggle'],
help: new Discord.MessageEmbed()
.setTitle("Help -> Server Status-Toggling")
.setDescription("Disables or enables the warning that appears when you ping someone that has a status set.")
.addField("Syntax", "`togglestatuses [c]` (add `c` to the end of the message if you want to check if they're enabled or not.)"),
async execute(message, msg, args, cmd, prefix, mention, client) {
if (!message.guild) {return message.reply('You must be in a server to use this command.');}
let tg = await GuildSettings.findOne({gid: message.guild.id});
if (!message.member.permissions.has('ADMINISTRATOR') && (tg && tg.staffrole.length && !message.member.roles.cache.has(tg.staffrole))) {return message.reply("You don't have permissions to use this command in your server.");}
if (['c', 'check', 'v', 'view'].includes(args[0].toLowerCase())) {return message.channel.send(`I ${tg && !tg.nostatus ? 'will' : 'will not'} send a warning when pinging a member with a status.`);}
if (!tg) {tg = new GuildSettings({gid: message.guild.id});}
tg.nostatus = !tg.nostatus;
tg.save();
return message.channel.send(`I ${!tg.nostatus ? 'will' : 'will not'} send a warning when pinging a member with a status.`);
}
};

@ -14,7 +14,8 @@ const guildSchema = new mongoose.Schema({
cooldowns: {type: Boolean, default: false}, cooldowns: {type: Boolean, default: false},
levelmessage: {type: String, default: '**{{u}}** has reached level **{{l}}**! :tada:'}, levelmessage: {type: String, default: '**{{u}}** has reached level **{{l}}**! :tada:'},
levelmessages: {type: Boolean, default: false}, levelmessages: {type: Boolean, default: false},
prefix: {type: String, default: ''} prefix: {type: String, default: ''},
nostatus: {type: Boolean, default: false}
}); });
module.exports = mongoose.model("guild", guildSchema); module.exports = mongoose.model("guild", guildSchema);

@ -6,6 +6,8 @@ const UserSchema = new mongoose.Schema({
statusmsg: {type: String, default: ''}, statusmsg: {type: String, default: ''},
statustype: {type: String, default: ''}, statustype: {type: String, default: ''},
statusclearmode: {type: String, default: 'auto'}, statusclearmode: {type: String, default: 'auto'},
statusclearat: {type: Date, default: null},
statussetat: {type: Date, default: null},
support: {type: Boolean, default: false}, support: {type: Boolean, default: false},
staff: {type: Boolean, default: false}, staff: {type: Boolean, default: false},
admin: {type: Boolean, default: false}, admin: {type: Boolean, default: false},

@ -6,7 +6,7 @@ module.exports = {
help: new Discord.MessageEmbed() help: new Discord.MessageEmbed()
.setTitle("Help -> ") .setTitle("Help -> ")
.setDescription("") .setDescription("")
.addField("Syntax", ""), .addField("Syntax", "``"),
async execute(message, msg, args, cmd, prefix, mention, client) { async execute(message, msg, args, cmd, prefix, mention, client) {
if (!args.length) {return message.channel.send(`Syntax: \`${prefix}\``);} if (!args.length) {return message.channel.send(`Syntax: \`${prefix}\``);}
} }

@ -1,7 +1,10 @@
const mongooes= require('mongoose'); const mongooes= require('mongoose');
const UserData = require('../models/user'); const UserData = require('../models/user');
const GuildSettings = require('../models/guild');
module.exports = async(message, msg, args, cmd, prefix, mention, client) => { module.exports = async(message, msg, args, cmd, prefix, mention, client) => {
let tu = await UserData.findOne({uid: mention.id}); 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 (tu) {if (tu.statusmsg.length) {return message.reply(`That user ${tu.statustype === 'dnd' ? 'wishes not to be disturbed' : 'is AFK'}. Reason: ${tu.statusmsg}`);}} if (tu) {if (tu.statusmsg.length) {return message.reply(`That user ${tu.statustype === 'dnd' ? 'wishes not to be disturbed' : 'is AFK'}. Reason: ${tu.statusmsg}`);}}
}; };
Loading…
Cancel
Save