From e92ef5539599d9e58786e0f3717948a80884c358 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Sat, 10 Oct 2020 13:34:36 -0600 Subject: [PATCH] n?dnd and user schema --- commands/dnd.js | 29 +++++++++++++++++++++++++++++ commands/prefix.js | 2 +- commands/staffrole.js | 1 + models/user.js | 17 +++++++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 commands/dnd.js diff --git a/commands/dnd.js b/commands/dnd.js new file mode 100644 index 0000000..3e97fd5 --- /dev/null +++ b/commands/dnd.js @@ -0,0 +1,29 @@ +const Discord = require('discord.js'); +const mongoose = require('mongoose'); +const UserData = require('../models/user'); + +module.exports = { + name: "dnd", + aliases: ['donotdisturb'], + help: new Discord.MessageEmbed() + .setTitle("Help -> Do Not Disturb") + .setDescription("Set your status within the bot as DnD and specify a reason. Then, when other people ping you, I can let them know that you don't want to be disturbed!") + .addField("Syntax", "`dnd [clearMode] `") + .addField("Notice","Your status clear mode can be set to either 'auto' or 'manual'. If not specified, it will clear when you use `n?clearstatus`."), + async execute(message, msg, args, cmd, prefix, mention, client) { + if (!args.length) {return message.channel.send(`Syntax: \`${prefix}dnd [clearMode] \``);} + let tu = await UserData.findOne({uid: message.author.id}) + ? await UserData.findOne({uid: message.author.id}) + : new UserData({uid: message.author.id}); + if (['m', 'manual', 'a', 'auto'].includes(args[0])) { + tu.statusclearmode = ['m', 'manual'].includes(args[0]) ? 'manual' : 'auto'; + args.shift(); + } else {tu.statusclearmode = 'manual';} + let reason = args.join(" "); + if (reason.length > 150) {return message.reply("That status a bit long; keep it under 150 characters.");} + tu.statustype = 'dnd'; + tu.statusmsg = reason.trim(); + tu.save(); + return message.reply(`I set your Do not Disturb message to: ${reason.trim()}`); + } +}; \ No newline at end of file diff --git a/commands/prefix.js b/commands/prefix.js index 2602530..e8d115f 100644 --- a/commands/prefix.js +++ b/commands/prefix.js @@ -1,4 +1,5 @@ const Discord = require('discord.js'); +const mongoose = require('mongoose'); const GuildSettings = require('../models/guild'); module.exports = { @@ -14,7 +15,6 @@ module.exports = { let tguild = await GuildSettings.findOne({gid: message.guild.id}) ? await GuildSettings.findOne({gid: message.guild.id}) : new GuildSettings({gid: message.guild.id}); - if (!tguild.prefix) {tguild.prefix = '';} if (!message.member.permissions.has("ADMINISTRATOR") && (!tguild.staffrole.length || !message.guild.roles.cache.has(tguild.staffrole) || !message.member.roles.cache.has(tguild.staffrole))) {return message.reply("You don't have the permissions to use this command here.");} if (!args.length) {return message.channel.send(`Syntax: \`${prefix} \`. My current prefix in this server is \`${tguild.prefix.length ? tguild.prefix : 'n?'}\``);} let np = args[0]; diff --git a/commands/staffrole.js b/commands/staffrole.js index 4adc215..188b9f7 100644 --- a/commands/staffrole.js +++ b/commands/staffrole.js @@ -1,4 +1,5 @@ const Discord = require('discord.js'); +const mongoose = require('mongoose'); const GuildSettings = require('../models/guild'); module.exports = { diff --git a/models/user.js b/models/user.js index e69de29..5562f2c 100644 --- a/models/user.js +++ b/models/user.js @@ -0,0 +1,17 @@ +const mongoose = require('mongoose'); + +const UserSchema = new mongoose.Schema({ + uid: {type: String, unique: true}, + commands: {type: Number, default: 0}, + statusmsg: {type: String, default: ''}, + statustype: {type: String, default: ''}, + statusclearmode: {type: String, default: 'auto'}, + support: {type: Boolean, default: false}, + staff: {type: Boolean, default: false}, + admin: {type: Boolean, default: false}, + developer: {type: Boolean, default: false}, + blacklisted: {type: Boolean, default: false}, + donator: {type: Boolean, default: false} +}); + +module.exports = mongoose.model("user", UserSchema); \ No newline at end of file