From 904c83b20c33985e0b6f3b49f99b1d7ca748e727 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Fri, 9 Oct 2020 23:42:02 -0600 Subject: [PATCH] merge conflicts yay --- commands/prefix.js | 26 ++++++++++++++++++++++++++ commands/staffrole.js | 12 ++++++------ 2 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 commands/prefix.js diff --git a/commands/prefix.js b/commands/prefix.js new file mode 100644 index 0000000..224da32 --- /dev/null +++ b/commands/prefix.js @@ -0,0 +1,26 @@ +const Discord = require('discord.js'); +const GuildSettings = require('../util/guild'); + +module.exports = { + name: "prefix", + help: new Discord.MessageEmbed() + .setTitle("Help -> Prefix") + .setDescription("Changes your server's prefix.") + .addField("Syntax", "`prefix `") + .addField("Staff Command", "This command requires you to either be admin, or to have the designated staff role.") + .addField("Noticed", "Prefixes are cached, and may take up to a minute to update."), + async execute(message, msg, args, cmd, prefix, mention, client) { + if (!message.guild) {return message.reply("This is a guild-only command!");} + let tguild = await GuildSettings.findOne({gid: message.guild.id}) + ? await GuildSettings.findOne({gid: message.guild.id}) + : new GuildSettings({gid: message.guild.id}); + 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]; + if (np.length > 7) {return message.reply("Hmmm, that prefix is a bit long. Try making something smaller!");} + if (!np.match(/^[a-zA-Z0-9,.!?<>\-_+=/;$#%^&*]$/m)) {return message.reply('Your custom prefix contains some *wonky* characters. Please use only alphanumerics and basic symbols.');} + tguild.prefix = ['c', 'clear', 'n', 'none'].includes(np.trim().toLowerCase()) ? '' : np; + tguild.save(); + + } +}; \ No newline at end of file diff --git a/commands/staffrole.js b/commands/staffrole.js index 7fd0acc..133ea35 100644 --- a/commands/staffrole.js +++ b/commands/staffrole.js @@ -17,9 +17,9 @@ module.exports = { if (['view', 'v'].includes(args[0].trim().toLocaleLowerCase())) {return message.reply( tguild.staffrole.length ? message.guild.roles.cache.has(tguild.staffrole) - ? `\`People with the ${message.guild.roles.cache.get(tguild.staffrole).name}\` role can edit my setting here.` + ? `\`people with the ${message.guild.roles.cache.get(tguild.staffrole).name}\` role can edit my setting here.` : `I have a role stored for this server, but it doesn't seem to exist anymore, so only admins can edit my settings right now.` - : 'Only admins may edit settings in this server.' + : 'only admins may edit settings in this server.' );} let role = !['c', 'clear', 'n', 'none'].includes(args[0].trim().toLowerCase()) ? message.mentions.roles.size ? message.mentions.roles.first() : message.guild.roles.cache.has(args[0]) ? message.guild.roles.cache.get(args[0]) : null : 'c'; @@ -28,17 +28,17 @@ module.exports = { if (role === "c") { tguild.staffrole = ''; tguild.save(); - return message.reply("Got it, only admins can edit my settings in this server."); + return message.reply("got it, only admins can edit my settings in this server."); } else { tguild.staffrole = role.id; tguild.save(); - let upm = message.reply("Sure thing!"); + let upm = message.reply("sure thing!"); await require('../util/wait')(1750); return upm.edit(new Discord.MessageEmbed() .setAuthor('Staff role updated!', message.author.avatarURL()) .setDescription(`<@${tguild.staffrole}> can now edit my settings in this server.`) - .addField('Auditing Admin', message.member.displayName, true) - .addField('Role-Holders', `${message.guild.members.cache.filter(m => m.roles.cache.has(tguild.staffrole) && !client.users.cache.get(m.id).bot)}+ members have this role`) + .addField('Auditing Admin', `<@${message.member.id}>`, true) + .addField('Role-Holders', `${message.guild.members.cache.filter(m => m.roles.cache.has(tguild.staffrole) && !client.users.cache.get(m.id).bot)}+ members have this role`, true) .setColor('c375f0') .setFooter('Natsuki', client.user.avatarURL()) .setTimestamp()