From 63080bdb7f7c37a08e2b1f71dc52277e7b17ea38 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Fri, 30 Oct 2020 20:02:12 -0600 Subject: [PATCH] Added n?bio completely --- commands/bio.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ models/user.js | 4 +++- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 commands/bio.js diff --git a/commands/bio.js b/commands/bio.js new file mode 100644 index 0000000..c1324d7 --- /dev/null +++ b/commands/bio.js @@ -0,0 +1,49 @@ +const Discord = require('discord.js'); +const UserData = require('../models/user'); + +module.exports = { + name: "bio", + help: new Discord.MessageEmbed() + .setTitle("Help -> Bio") + .setDescription("Set and view user bios, which are fun ways to express yourself!") + .addField("Syntax", "`bio `"), + async execute(message, msg, args, cmd, prefix, mention, client) { + if (!args.length) {return message.channel.send(`Syntax: \`${prefix}bio \``);} + let tu = await UserData.findOne({uid: message.author.id}) ? await UserData.findOne({uid: message.author.id}) : new UserData({uid: message.author.id}); + + if (['v', 'view', 'check'].includes(args[0].toLowerCase())) { + let person = args[1] ? args[1].match(/<@(?:!?)(?:\d+)>/) && message.mentions.users.first() ? message.mentions.users.first().id : message.guild && message.guild.members.cache.has(args[1]) ? args[1] : message.author.id : message.author.id; + let pud = await UserData.findOne({uid: person}); + if (!pud || !pud.bio || !pud.bio.length) {return message.reply(person === message.author.id ? "You don't have a bio set!" : "That user has no bio for me to show you!");} + return message.channel.send(new Discord.MessageEmbed() + .setTitle(`Bio for ${message.guild ? message.guild.members.cache.get(person).displayName : message.author.username}`) + .setThumbnail(client.users.cache.get(person).avatarURL({size: 2048})) + .setDescription(pud.bio) + .setColor(pud.color && pud.color.length ? pud.color : 'c375f0') + .setFooter('Natsuki', client.user.avatarURL()) + .setTimestamp() + ); + } + if (['s', 'set'].includes(args[0].toLowerCase())) { + args.shift(); + if (!args.length) {return message.reply("Please specify a bio!");} + let bio = args.join(" "); + if (bio.length > 200) {return message.reply("Please keep your bio under 200 characters!");} + tu.bio = bio; + tu.save(); + return message.channel.send(new Discord.MessageEmbed() + .setTitle(`Bio Set!`) + .setThumbnail(message.author.avatarURL({size: 2048})) + .setDescription(tu.bio) + .setColor(tu.color && tu.color.length ? tu.color : 'c375f0') + .setFooter('Natsuki', client.user.avatarURL()) + .setTimestamp() + ); + } + if (['c', 'clear'].includes(args[0].toLowerCase())) { + tu.bio = ''; + tu.save(); + return message.reply("Bio cleared!"); + } + } +}; \ No newline at end of file diff --git a/models/user.js b/models/user.js index 29e5e29..9b6f51c 100644 --- a/models/user.js +++ b/models/user.js @@ -15,7 +15,9 @@ const UserSchema = new mongoose.Schema({ admin: {type: Boolean, default: false}, developer: {type: Boolean, default: false}, blacklisted: {type: Boolean, default: false}, - donator: {type: Boolean, default: false} + donator: {type: Boolean, default: false}, + bio: {type: String, default: ''}, + color: {type: String, default: ''} }); module.exports = mongoose.model("user", UserSchema); \ No newline at end of file