mirror of
https://github.com/pieartsy/PluralFlux.git
synced 2026-04-16 17:45:28 +10:00
hopefully added support for wrapping of proxies (at beginning, around, and end)
This commit is contained in:
6
enums.js
6
enums.js
@@ -14,7 +14,9 @@ helperEnums.err = {
|
|||||||
PROPIC_CANNOT_LOAD: "Profile picture could not be loaded from URL.",
|
PROPIC_CANNOT_LOAD: "Profile picture could not be loaded from URL.",
|
||||||
NO_WEBHOOKS_ALLOWED: "Channel does not support webhooks.",
|
NO_WEBHOOKS_ALLOWED: "Channel does not support webhooks.",
|
||||||
NOT_IN_SERVER: "You can only proxy in a server.",
|
NOT_IN_SERVER: "You can only proxy in a server.",
|
||||||
NO_MESSAGE_SENT_WITH_PROXY: 'Proxied message has no content.'
|
NO_MESSAGE_SENT_WITH_PROXY: 'Proxied message has no content.',
|
||||||
|
NO_TEXT_FOR_PROXY: "You need the word 'text' for the bot to detect proxy tags with.\nCorrect usage examples: `pf;member jane proxy J:text`, `pf;member jane [text]`",
|
||||||
|
NO_PROXY_WRAPPER: "You need at least one proxy tag surrounding 'text', either before or after.\nCorrect usage examples: `pf;member jane proxy J:text`, `pf;member jane [text]`"
|
||||||
}
|
}
|
||||||
|
|
||||||
helperEnums.help = {
|
helperEnums.help = {
|
||||||
@@ -27,7 +29,7 @@ helperEnums.help = {
|
|||||||
REMOVE: "Removes a member based on their name, for example: `pf;member remove jane`.",
|
REMOVE: "Removes a member based on their name, for example: `pf;member remove jane`.",
|
||||||
NAME: "Updates the name for a specific member based on their current name, for ex: `pf;member jane name jane`. The member name should ideally be short so you can write other commands with it easily.",
|
NAME: "Updates the name for a specific member based on their current name, for ex: `pf;member jane name jane`. The member name should ideally be short so you can write other commands with it easily.",
|
||||||
DISPLAY_NAME: "Updates the display name for a specific member based on their name, for example: `pf;member jane \"Jane Doe | ze/hir\"`.This can be up to 32 characters long. If it has spaces, put it in __double quotes__.",
|
DISPLAY_NAME: "Updates the display name for a specific member based on their name, for example: `pf;member jane \"Jane Doe | ze/hir\"`.This can be up to 32 characters long. If it has spaces, put it in __double quotes__.",
|
||||||
PROXY: "Updates the proxy tag for a specific member based on their name, for example: `pf;member jane proxy Jane:` or `pf;member amal proxy A=`. This is put at *the start* of a message to allow it to be proxied. Proxies that wrap around text or go at the end are *not* currently supported.",
|
PROXY: "Updates the proxy tag for a specific member based on their name. The proxy must be formatted with the tags surrounding the word 'text', for example: `pf;member jane proxy Jane:text` or `pf;member amal proxy [text]` This is so the bot can detect what the proxy tags are.",
|
||||||
PROPIC: "Updates the profile picture for the member. Must be in JPG or PNG format. The two options are:\n1. Pass in a direct remote image URL, for example: `pf;member jane propic <https://cdn.pixabay.com/photo/2020/05/02/02/54/animal-5119676_1280.jpg>`. You can upload images on sites like <https://imgbb.com/>.\n2. Upload an attachment directly.\n\n**NOTE:** Fluxer does not save your attachments forever, so option #1 is recommended.",
|
PROPIC: "Updates the profile picture for the member. Must be in JPG or PNG format. The two options are:\n1. Pass in a direct remote image URL, for example: `pf;member jane propic <https://cdn.pixabay.com/photo/2020/05/02/02/54/animal-5119676_1280.jpg>`. You can upload images on sites like <https://imgbb.com/>.\n2. Upload an attachment directly.\n\n**NOTE:** Fluxer does not save your attachments forever, so option #1 is recommended.",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import {enums} from "../enums.js";
|
|||||||
import { loadImage } from "canvas";
|
import { loadImage } from "canvas";
|
||||||
import {EmptyResultError} from "sequelize";
|
import {EmptyResultError} from "sequelize";
|
||||||
import {EmbedBuilder, User} from "@fluxerjs/core";
|
import {EmbedBuilder, User} from "@fluxerjs/core";
|
||||||
import {messageHelper} from "./messageHelper.js";
|
|
||||||
|
|
||||||
const mh = {};
|
const mh = {};
|
||||||
|
|
||||||
@@ -68,7 +67,7 @@ mh.parseMemberCommand = async function(author, args, attachmentUrl){
|
|||||||
* @param {string} authorId - The author of the message
|
* @param {string} authorId - The author of the message
|
||||||
* @param {string[]} args - The message arguments
|
* @param {string[]} args - The message arguments
|
||||||
* @returns {Promise<string>} A successful addition.
|
* @returns {Promise<string>} A successful addition.
|
||||||
* @throws {Error} When creating a member doesn't work.
|
* @throws {Error} When the member exists, or creating a member doesn't work.
|
||||||
*/
|
*/
|
||||||
async function addNewMember(authorId, args) {
|
async function addNewMember(authorId, args) {
|
||||||
if (args[1] && args[1] === "--help" || !args[1]) {
|
if (args[1] && args[1] === "--help" || !args[1]) {
|
||||||
@@ -77,6 +76,10 @@ async function addNewMember(authorId, args) {
|
|||||||
const memberName = args[1];
|
const memberName = args[1];
|
||||||
const displayName = args[2];
|
const displayName = args[2];
|
||||||
|
|
||||||
|
const member = await mh.getMemberByName(authorId, memberName);
|
||||||
|
if (member) {
|
||||||
|
throw new Error(enums.err.MEMBER_EXISTS);
|
||||||
|
}
|
||||||
const trimmedName = displayName ? displayName.replaceAll(' ', '') : null;
|
const trimmedName = displayName ? displayName.replaceAll(' ', '') : null;
|
||||||
return await db.members.create({
|
return await db.members.create({
|
||||||
name: memberName,
|
name: memberName,
|
||||||
@@ -157,9 +160,10 @@ async function updateProxy(authorId, args) {
|
|||||||
const proxy = args[2];
|
const proxy = args[2];
|
||||||
const trimmedProxy = proxy ? proxy.replaceAll(' ', '') : null;
|
const trimmedProxy = proxy ? proxy.replaceAll(' ', '') : null;
|
||||||
|
|
||||||
if (trimmedProxy == null) {
|
if (trimmedProxy == null) throw new RangeError(`Proxy ${enums.err.NO_VALUE}`);
|
||||||
throw new RangeError(`Proxy ${enums.err.NO_VALUE}`);
|
const splitProxy = proxy.trim().split("text");
|
||||||
}
|
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);
|
||||||
|
|
||||||
const members = await mh.getMembersByAuthor(authorId);
|
const members = await mh.getMembersByAuthor(authorId);
|
||||||
const proxyExists = members.some(member => member.proxy === proxy);
|
const proxyExists = members.some(member => member.proxy === proxy);
|
||||||
|
|||||||
Reference in New Issue
Block a user