mirror of
https://github.com/pieartsy/PluralFlux.git
synced 2026-04-16 17:45:28 +10:00
removed some overzealous error handling
This commit is contained in:
@@ -414,9 +414,6 @@ mh.getMembersByAuthor = async function(authorId) {
|
|||||||
* @throws {Error} When an empty proxy was provided, or no proxy exists.
|
* @throws {Error} When an empty proxy was provided, or no proxy exists.
|
||||||
*/
|
*/
|
||||||
mh.checkIfProxyExists = async function(authorId, proxy) {
|
mh.checkIfProxyExists = async function(authorId, proxy) {
|
||||||
const trimmedProxy = proxy ? proxy.trim() : null;
|
|
||||||
|
|
||||||
if (trimmedProxy == null) throw new RangeError(`Proxy ${enums.err.NO_VALUE}`);
|
|
||||||
const splitProxy = proxy.trim().split("text");
|
const splitProxy = proxy.trim().split("text");
|
||||||
if(splitProxy.length < 2) throw new Error(enums.err.NO_TEXT_FOR_PROXY);
|
if(splitProxy.length < 2) throw new Error(enums.err.NO_TEXT_FOR_PROXY);
|
||||||
if(!splitProxy[0] && !splitProxy[1]) throw new Error(enums.err.NO_PROXY_WRAPPER);
|
if(!splitProxy[0] && !splitProxy[1]) throw new Error(enums.err.NO_PROXY_WRAPPER);
|
||||||
|
|||||||
@@ -55,7 +55,8 @@ msgh.parseProxyTags = async function (authorId, attachment, content){
|
|||||||
const removePrefix = new RegExp("^" + splitProxy[0]);
|
const removePrefix = new RegExp("^" + splitProxy[0]);
|
||||||
const removeSuffix = new RegExp(splitProxy[1] + "$");
|
const removeSuffix = new RegExp(splitProxy[1] + "$");
|
||||||
proxyMessage.message = content.replace(removePrefix, "").replace(removeSuffix, "");
|
proxyMessage.message = content.replace(removePrefix, "").replace(removeSuffix, "");
|
||||||
if (proxyMessage.message.length <= splitProxy[0].length + splitProxy[1].length && !attachment) throw new Error(enums.err.NO_MESSAGE_SENT_WITH_PROXY);
|
|
||||||
|
if (proxyMessage.message.length === 0 && !attachment) throw new Error(enums.err.NO_MESSAGE_SENT_WITH_PROXY);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return proxyMessage;
|
return proxyMessage;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const name = 'PluralFlux Proxy Webhook';
|
|||||||
wh.sendMessageAsMember = async function(client, message, content) {
|
wh.sendMessageAsMember = async function(client, message, content) {
|
||||||
const proxyMatch = await messageHelper.parseProxyTags(message.author.id, message.attachments[0] ?? null, content).catch(e =>{throw e});
|
const proxyMatch = await messageHelper.parseProxyTags(message.author.id, message.attachments[0] ?? null, content).catch(e =>{throw e});
|
||||||
// If the message doesn't match a proxy, just return.
|
// If the message doesn't match a proxy, just return.
|
||||||
if (!proxyMatch.proxy) {
|
if (!proxyMatch || !proxyMatch.proxy) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// If the message does match a proxy but is in a guild server
|
// If the message does match a proxy but is in a guild server
|
||||||
|
|||||||
Reference in New Issue
Block a user