fix some inefficient regex

master
Kit Kasune 3 years ago
parent 4181a315cc
commit 3fd08ad2f5
  1. 4
      commands/dev/blacklist.js
  2. 2
      commands/fun/bite.js
  3. 2
      commands/fun/slap.js
  4. 2
      commands/moderation/warn.js
  5. 2
      commands/social/bio.js
  6. 2
      commands/social/bonk.js
  7. 2
      commands/social/creampie.js
  8. 2
      commands/social/feed.js
  9. 2
      commands/social/handhold.js
  10. 2
      commands/social/heal.js
  11. 2
      commands/social/hug.js
  12. 2
      commands/social/kill.js
  13. 2
      commands/social/kiss.js
  14. 2
      commands/social/pat.js
  15. 2
      commands/social/simp.js
  16. 2
      commands/social/spank.js
  17. 2
      commands/social/wink.js
  18. 56
      slash/userinfo.js.dev
  19. 2
      slashtemplate.js

@ -61,7 +61,7 @@ module.exports = {
}
if (['a', 'add'].includes(args[0].toLowerCase())) {
let blacklistUser = args[1].match(/^<@(?:!?)(?:\d+)>$/) && mention && client.users.cache.has(mention.id) ? mention.id : client.users.cache.has(args[1]) ? client.users.cache.get(args[1]).id : null;
let blacklistUser = args[1].match(/^<@!?\d+>$/) && mention && client.users.cache.has(mention.id) ? mention.id : client.users.cache.has(args[1]) ? client.users.cache.get(args[1]).id : null;
if (!blacklistUser) {return message.reply("You must specify a user to blacklist!");}
let usersData = await UserData.findOne( { uid: blacklistUser } ) || new UserData({uid: blacklistUser});
@ -76,7 +76,7 @@ module.exports = {
}
if (['r', 'rem', 'remove', 'd', 'del', 'delete'].includes(args[0].toLowerCase())) {
let blacklistedUser = args[1].match(/^<@(?:!?)(?:\d+)>$/) && mention && client.users.cache.has(mention.id) ? mention.id : client.users.cache.has(args[1]) ? client.users.cache.get(args[1]).id : null;
let blacklistedUser = args[1].match(/^<@!?\d+>$/) && mention && client.users.cache.has(mention.id) ? mention.id : client.users.cache.has(args[1]) ? client.users.cache.get(args[1]).id : null;
if (!blacklistedUser) { return message.reply("You need to specify who you're letting free..." );}
let userData = await UserData.findOne( { uid: blacklistedUser } ) || new UserData({uid: blacklistedUser});

@ -20,7 +20,7 @@ module.exports = {
let saves = savess.saves;
if (!args.length) {
return message.channel.send(message.guild ? "Please mention someone to bite!" : "Oi! I get it if you don't like me but you can't just waltz into my DMs and bite me!");}
if (mention && args[0].match(/^<@(?:!?)(?:\d+)>$/)) {
if (mention && args[0].match(/^<@!?\d+>$/)) {
if (!message.guild) {return message.reply("Oi! I get it if you don't like me but you can't just waltz into my DMs and bite me!");}
if (!message.guild.members.cache.has(mention.id)) {return message.reply("That user is not in this server!");}
if (message.author.id === mention.id) {return message.reply("Ew quit tryna bite yourself, that's weird.");}

@ -21,7 +21,7 @@ module.exports = {
let saves = savess.saves;
if (!args.length) {
return message.channel.send(message.guild ? "Please mention someone to slap!" : "Oi! You don't get to waltz into my DM just to slap me!");}
if (mention && args[0].match(/^<@(?:!?)(?:\d+)>$/)) {
if (mention && args[0].match(/^<@!?\d+>$/)) {
if (!message.guild) {return message.reply("Oi! You don't get to waltz into my DM just to slap me!");}
if (!message.guild.members.cache.has(mention.id)) {return message.reply("That user is not in this server!");}
if (message.author.id === mention.id) {return message.reply("Wait wouldn't slapping yourself be a form of self-harm? ToS is that you??");}

@ -24,7 +24,7 @@ module.exports = {
if (!message.member.permissions.has("MANAGE_MESSAGES") && !message.member.permissions.has("MANAGE_GUILD")) {return message.reply("You must be a server moderator (manage messages or manage server permissions) to use this command.");}
if (args.length < 2 && !['check', 'c', 'list', 'l', 'clear', 'e', 'empty'].includes(args[0].toLowerCase())) {return message.channel.send("You must provide a reason for warning the user, or `check` or `clear`.");}
let user = message.mentions.members.first() && args[0].match(/^<@(?:!?)(?:\d+)>$/) ? message.mentions.members.first() : message.guild.members.cache.has(args[0]) ? message.guild.members.cache.get(args[0]) : null;
let user = message.mentions.members.first() && args[0].match(/^<@!?\d+>$/) ? message.mentions.members.first() : message.guild.members.cache.has(args[0]) ? message.guild.members.cache.get(args[0]) : null;
if (!user && args.length > 1) {return message.channel.send("Either you didn't mention a user, or I can't find that user!");}
if (args.length > 1) {args.shift();}

@ -18,7 +18,7 @@ module.exports = {
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 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({embeds: [new Discord.MessageEmbed()

@ -28,7 +28,7 @@ module.exports = {
.setTimestamp()]}
: "I fucking dare you to hit me."
);}
if (mention && args[0].match(/^<@(?:!?)(?:\d+)>$/)) {
if (mention && args[0].match(/^<@!?\d+>$/)) {
if (!message.guild) {return message.reply("I dare you to hit me.");}
if (!message.guild.members.cache.has(mention.id)) {return message.reply("You missed your bonk..");}
if (message.author.id === mention.id) {return message.reply("I should bonk you for attempting to self harm.");}

@ -27,7 +27,7 @@ module.exports = {
.setTimestamp()]}
: "Do. Not. Touch. Me."
);}
if (mention && args[0].match(/^<@(?:!?)(?:\d+)>$/)) {
if (mention && args[0].match(/^<@!?\d+>$/)) {
if (!message.guild) {return message.reply("No means no.");}
if (!message.guild.members.cache.has(mention.id)) {return message.reply("I guess they didn't want your creampie..");}
if (message.author.id === mention.id) {return message.reply("You can't give yourself a creampie..weirdo.");}

@ -27,7 +27,7 @@ module.exports = {
.setTimestamp()]}
: "Sorry..I'm kinda full right now."
);}
if (mention && args[0].match(/^<@(?:!?)(?:\d+)>$/)) {
if (mention && args[0].match(/^<@!?\d+>$/)) {
if (!message.guild) {return message.reply("weirdchamp.");}
if (!message.guild.members.cache.has(mention.id)) {return message.reply("I guess that person didn't want any food..");}
if (message.author.id === mention.id) {return message.reply("You can't feed yourself. **Starve.**");}

@ -27,7 +27,7 @@ module.exports = {
.setTimestamp()]}
: "Yikes... I'm kinda germaphobic you know. Maybe try asking in a server?"
);}
if (mention && args[0].match(/^<@(?:!?)(?:\d+)>$/)) {
if (mention && args[0].match(/^<@!?\d+>$/)) {
if (!message.guild) {return message.reply("Please make sure you're in a server so you can mention someone other than me to hold hands with!");}
if (!message.guild.members.cache.has(mention.id)) {return message.reply("That user is not in this server!");}
if (message.author.id === mention.id) {return message.reply("Holding your own hand... I mean it's possible? Same effect, though? Eh, not really.");}

@ -27,7 +27,7 @@ module.exports = {
.setTimestamp()]}
: "I am immortal, I don't need healing."
);}
if (mention && args[0].match(/^<@(?:!?)(?:\d+)>$/)) {
if (mention && args[0].match(/^<@!?\d+>$/)) {
if (!message.guild) {return message.reply("I am immortal, I don't need healing.");}
if (!message.guild.members.cache.has(mention.id)) {return message.reply("It's too late..they're already gone to a better place..");}
if (message.author.id === mention.id) {return message.reply("You can't heal yourself because....I SAID SO");}

@ -28,7 +28,7 @@ module.exports = {
.setTimestamp()]}
: "Sorry, but I'm a bot, and I can't hug you. Go into a server and ask for some hugs!"
);}
if (mention && args[0].match(/^<@(?:!?)(?:\d+)>$/)) {
if (mention && args[0].match(/^<@!?\d+>$/)) {
if (!message.guild) {return message.reply("Please make sure you're in a server so you can mention someone other than me to hug!");}
if (!message.guild.members.cache.has(mention.id)) {return message.reply("That user is not in this server!");}
if (message.author.id === mention.id) {return message.reply("Sorry if you're that lonely, but you can't hug yourself!");}

@ -27,7 +27,7 @@ module.exports = {
.setTimestamp()]}
: "You can't kill me..don't even try."
);}
if (mention && args[0].match(/^<@(?:!?)(?:\d+)>$/)) {
if (mention && args[0].match(/^<@!?\d+>$/)) {
if (!message.guild) {return message.reply("You can't kill me..don't even try.");}
if (!message.guild.members.cache.has(mention.id)) {return message.reply("The person must have ran from their inevitable death..");}
if (message.author.id === mention.id) {return message.reply("Uhhh no. Please don't try to hurt yourself..");}

@ -25,7 +25,7 @@ module.exports = {
.setTimestamp()]}
: "I'm not really into that kind of thing. Maybe try asking in a server?"
);}
if (mention && args[0].match(/^<@(?:!?)(?:\d+)>$/)) {
if (mention && args[0].match(/^<@!?\d+>$/)) {
if (!message.guild) {return message.reply("Please make sure you're in a server so you can mention someone other than me to kiss!");}
if (!message.guild.members.cache.has(mention.id)) {return message.reply("That user is not in this server!");}
if (message.author.id === mention.id) {return message.reply("A self-kiss ought to be a little hard, don't you think?");}

@ -29,7 +29,7 @@ module.exports = {
.setTimestamp()]}
: "Sorry, but I'm only able to pat one person, and it's not you ^^"
);}
if (mention && args[0].match(/^<@(?:!?)(?:\d+)>$/)) {
if (mention && args[0].match(/^<@!?\d+>$/)) {
if (!message.guild) {return message.reply("Please make sure you're in a server so you can mention someone other than me to pat!");}
if (!message.guild.members.cache.has(mention.id)) {return message.reply("That user is not in this server!");}
if (message.author.id === mention.id) {return message.reply("Self pats just don't work mate. Maybe try asking for some!");}

@ -27,7 +27,7 @@ module.exports = {
.setTimestamp()]}
: "Nobody simps for me. That's just weird. Be weird to someone else."
);}
if (mention && args[0].match(/^<@(?:!?)(?:\d+)>$/)) {
if (mention && args[0].match(/^<@!?\d+>$/)) {
if (!message.guild) {return message.reply("Listen I get it I get it you like me and all but I'm gonna have to get a restraining order real soon.");}
if (!message.guild.members.cache.has(mention.id)) {return message.reply("They already left you. Get over it.");}
if (message.author.id === mention.id) {return message.reply("You can't simp for yourself you lonely fuck.");}

@ -19,7 +19,7 @@ module.exports = {
let savess = await Saves.findOne({name: 'spank'}) ? await Saves.findOne({name: 'spank'}) : new Saves({name: 'spank'});
let saves = savess.saves;
if (!args.length) {return message.channel.send("You have to mention someone to spank!");}
if (mention && args[0].match(/^<@(?:!?)(?:\d+)>$/)) {
if (mention && args[0].match(/^<@!?\d+>$/)) {
if (!message.guild) {return message.reply("Please make sure you're in a server so you can mention someone other than me to spank!");}
if (!message.guild.members.cache.has(mention.id)) {return message.reply("That user is not in this server!");}
if (message.author.id === mention.id) {return message.reply("You turn around and... whoop your own ass? Nah, I don't think it really works.");}

@ -27,7 +27,7 @@ module.exports = {
.setTimestamp()]}
: "W-why are you winking at me privately..do it in a server! "
);}
if (mention && args[0].match(/^<@(?:!?)(?:\d+)>$/)) {
if (mention && args[0].match(/^<@!?\d+>$/)) {
if (!message.guild) {return message.reply("Please make sure you're in a server so you can mention someone other than me to hold hands with!");}
if (!message.guild.members.cache.has(mention.id)) {return message.reply("That user is not in this server!");}
if (message.author.id === mention.id) {return message.reply("Wow...you must really have a big ego to wink at yourself...");}

@ -0,0 +1,56 @@
const {SlashCommand} = require('../util/slash');
const {SlashCommandBuilder} = require('@discordjs/builders');
const Discord = require('discord.js');
const UserData = require("../models/user");
const moment = require('moment');
module.exports = (client) => {
return new SlashCommand(
'userinfo', client,
new SlashCommandBuilder()
.setName("userinfo")
.setDescription("Get info about yourself or another user!")
.addUserOption(option => {
return option
.setName("user")
.setDescription("A user to get the info of");
})
.addBooleanOption(option => {
return option
.setName('send')
.setDescription("If you want me to send the response to this channel.");
}),
async (client, interaction) => {
let person = interaction.options.getUser("user") ? interaction.options.getUser("user").id : interaction.user.id;
let name = interaction.guild ? person.displayName : person.username;
let tu = await UserData.findOne({uid: person.id});
let now = new Date();
let infoembed = new Discord.MessageEmbed()
.setTitle(`User Info for ${name}`)
.setDescription(`Requested by ${interaction.guild ? interaction.member.displayName : interaction.user.username}`)
.setThumbnail(client.users.cache.get(person.id).avatarURL({size: 2048}))
.addField("Account Created", moment(client.users.cache.get(person.id).createdAt).fromNow(), true)
.addField("Bot User?", client.users.cache.get(person.id).bot ? "Is a bot" : "Is not a bot", true)
.setColor('c375f0')
.setFooter('Natsuki', client.user.avatarURL())
.setTimestamp();
if (interaction.guild) {
infoembed.addField('In Server Since', `${moment(person.joinedAt).fromNow()}${!moment(person.joinedAt).fromNow().includes('days') ? ` | ${Math.floor((new Date().getTime() - person.joinedAt.getTime()) / (60 * 60 * 24 * 1000))} days` : ''}\nMember for **${Math.round(((now.getTime() - new Date(interaction.member.joinedAt.getTime()).getTime()) / (new Date(interaction.guild.createdAt).getTime() - now.getTime())) * -100)}%** of server lifetime`, false)
.addField('Roles', `**${person.roles.cache.size}** roles | [${person.roles.cache.size}/${interaction.guild.roles.cache.size}] - ${Math.round((person.roles.cache.size / interaction.guild.roles.cache.size) * 100)}%\nHighest: ${person.roles.highest ? `<@&${person.roles.highest.id}>` : 'No roles!'}`, true)
if (interaction.guild.ownerId === person.id) {infoembed.addField("Extra", "User is the server's owner!");}
else if (person.permissions.has("ADMINISTRATOR")) {infoembed.addField("Extra", "User is an admin! Watch out :eyes:");}
}
if (tu) {
infoembed.addField('Natsuki Commands Executed', tu.commands)
.addField('Donator?', tu.developer ? `Well, ${name} makes me work, so they're a supporter in my book!` : tu.donator ? 'Yes! They have donated or supported me in the past!' : 'No', true)
.addField('Natsuki Staff Level', tu.developer ? 'Developer' : tu.admin ? 'Admin; Audit access to the bot' : tu.staff ? 'Staff; Support but with maintenance permissions' : tu.support ? 'Support; Answers tickets and help queries' : 'Member; Does not have a staff rank.', true);
}
return interaction.reply({embeds: [infoembed]});
}
);
}

@ -0,0 +1,2 @@
const Discord = require('discord.js');
Loading…
Cancel
Save