parent
65def95ee0
commit
5da56dfa60
@ -0,0 +1,23 @@ |
||||
const Discord = require('discord.js'); |
||||
const GuildData = require('../models/guild'); |
||||
|
||||
const sendResponse = require('../util/sendresponse'); |
||||
const parseResponse = require('../util/parseresponse'); |
||||
|
||||
module.exports = { |
||||
name: "response", |
||||
aliases: ['r', 'resp'], |
||||
help: new Discord.MessageEmbed() |
||||
.setTitle("Help -> Responses") |
||||
.setDescription("Configure your server's saved responses. These are reusable and editable, and can be placed in things like welcome messages and used for announcements.") |
||||
.addField("Syntax", "`response <new|edit|view|list|delete|test|quick>`") |
||||
.addField("Notice", "You must have your server's staff role or be an admin to use this command."), |
||||
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 GuildData.findOne({gid: message.guild.id}); |
||||
if (!tg && !['q', 'quick'].includes(args[0].toLowerCase()) && (tg.staffrole.length && !message.member.roles.cache.has(tg.staffrole)) && message.member.permissions.has("ADMINISTRATOR")) {return message.reply("you need to be staff or admin in this server in order to edit those settings.");} |
||||
if (!args.length) {return message.channel.send(`Syntax: \`${prefix}response <new|edit|view|list|delete|test|quick>\``);} |
||||
|
||||
if (['q', 'quick'].includes(args[0].toLowerCase())) {return sendResponse(message.channel, 'quick', client, await parseResponse(message, client, args));} |
||||
} |
||||
}; |
@ -0,0 +1,55 @@ |
||||
const {Tag} = require('./tag'); |
||||
const {TagFilter} = require('./tagfilter'); |
||||
|
||||
module.exports = async (message, client, args) => { |
||||
let options = new TagFilter([ |
||||
new Tag(['em', '-embed'], 'embed', 'toggle'), |
||||
new Tag(['-msg', 'message'], 'message', 'toggle'), |
||||
|
||||
new Tag(['name', 'n'], 'name', 'append'), |
||||
new Tag(['ch', 'channel'], 'channel', 'append'), |
||||
|
||||
new Tag(['text', 'txt'], 'text', 'append'), |
||||
|
||||
new Tag(['title', 't'], 'title', 'append'), |
||||
new Tag(['description', 'desc', 'd'], 'description', 'append'), |
||||
new Tag(['fieldname', 'fn', 'newfield', 'nf'], 'fieldnames', 'listAppend'), |
||||
new Tag(['fieldtext', 'ft', 'fieldcontent', 'fc'], 'fieldtexts', 'listAppend'), |
||||
new Tag(['image', 'i'], 'image', 'append'), |
||||
new Tag(['thumbnail', 'thumb', 'th'], 'thumbnail', 'append'), |
||||
new Tag(['servericonthumbnail', 'serverthumbnail', 'sit', 'st'], 'guildthumb', 'toggle'), |
||||
new Tag(['servericonimage', 'serverimage', 'sii', 'si'], 'guildimage', 'toggle'), |
||||
new Tag(['color', 'colour', 'col', 'c'], 'color', 'append'), |
||||
]).test(args.join(" ")); |
||||
|
||||
if (options.fieldnames && options.fieldnames.length) { |
||||
if (!options.fieldtexts || !options.fieldtexts.length || options.fieldnames.length !== options.fieldtexts.length) { |
||||
message.reply("You must have the same amount of field names as you do field texts."); return null; |
||||
} |
||||
} |
||||
if (options.embed) { |
||||
if (options.fieldnames && options.fieldnames.length > 10) {message.reply("You can't have more than 10 fields!"); return null;} |
||||
if (options.color && options.color.length && (![3, 6].includes(options.color.length))) {message.reply("Your color must be a hex value 3 or 6 digits long."); return null;} |
||||
if (options.title && options.title.length > 65) {message.reply("Your title should be less than 65 characters, please :)"); return null;} |
||||
if (options.description && options.description.length > 750) {message.reply("Your description should be less than 750 characters."); return null;} |
||||
if ((!options.title || !options.title.length) || (!options.description || !options.description.length)) {message.reply("You need have a title and a description!"); return null;} |
||||
if (options.image && options.image.length > 300) {message.reply("Your image URL is a bit too long. Try shortening the URL or hosting it somewhere like imgur."); return null;} |
||||
if (options.thumbnail && options.image.thumbnail > 300) {message.reply("Your thumbnail URL is a bit too long. Try shortening the URL or hosting it somewhere like imgur."); return null;} |
||||
if (options.fieldnames) { |
||||
let fn; let ft; |
||||
for (fn of options.fieldnames) { |
||||
if (fn.length > 65) {message.reply("One of your field names is longer than 65 characters. Please shorten it!"); return null;} |
||||
} for (ft of options.fieldtexts) { |
||||
if (ft.length > 500) {message.reply("One of your field texts is longer than 500 characters. Please shorten it!"); return null;} |
||||
} |
||||
} |
||||
if (options.guildthumb) {options.thumbnail = message.guild.iconURL({size: 2048});} |
||||
if (options.guildimage) {options.image = message.guild.iconURL({size: 2048});} |
||||
} else if (options.message) { |
||||
if (options.text && options.text.length > 750) {message.reply("Please keep your message text under 750 characters!"); return null;} |
||||
} else {message.reply("You must specify either '-message' or '-embed' for the format of your response."); return null;} |
||||
|
||||
if (options.channel && options.channel.length) {if (!options.channel.match(/^<#(?:\d+)>$/) && !message.guild.channels.cache.has(options.channel.slice(options.channel.search(/\d/), options.channel.search(">")))) {message.reply("You must use a valid channel in this server."); return null;}} |
||||
|
||||
return options; |
||||
}; |
@ -0,0 +1,20 @@ |
||||
const Discord = require('discord.js'); |
||||
|
||||
module.exports = async(channel, mode, client, options) => { |
||||
if (!options) {return;} |
||||
if (options.channel && options.channel.length) {channel = channel.guild.channels.cache.get(options.channel.slice(options.channel.search(/\d/), options.channel.search('>')));} |
||||
try { |
||||
if (mode === "welcome") {} else if (mode === "leave") {} else { |
||||
if (options.embed) { |
||||
var responseEmbed = new Discord.MessageEmbed().setTitle(options.title).setDescription(options.description); |
||||
if (options.fieldnames && options.fieldnames.length) {let i; for (i=0;i<options.fieldnames.length;i++) {responseEmbed.addField(options.fieldnames[i], options.fieldtexts[i]);}} |
||||
if (options.color) {responseEmbed.setColor(options.color);} |
||||
if (options.image) {responseEmbed.setImage(options.image);} |
||||
if (options.thumbnail) {responseEmbed.setThumbnail(options.thumbnail);} |
||||
} |
||||
if (channel.permissionsFor(client.user.id).has("SEND_MESSAGES")) {return channel.send( |
||||
options.message ? options.text : responseEmbed |
||||
);} |
||||
} |
||||
} catch {} |
||||
}; |
Loading…
Reference in new issue