Unify mentionRole parsing
parent
a8580e1ef8
commit
f6825376c0
17
src/utils.js
17
src/utils.js
|
@ -251,12 +251,18 @@ function convertDelayStringToMS(str) {
|
||||||
return ms;
|
return ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInboxMention() {
|
function getValidMentionRoles() {
|
||||||
const mentionRoles = Array.isArray(config.mentionRole) ? config.mentionRole : [config.mentionRole];
|
const mentionRoles = Array.isArray(config.mentionRole) ? config.mentionRole : [config.mentionRole];
|
||||||
|
return mentionRoles.filter(roleStr => {
|
||||||
|
return (roleStr !== null && roleStr !== "none" && roleStr !== "off" && roleStr !== "");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInboxMention() {
|
||||||
|
const mentionRoles = getValidMentionRoles();
|
||||||
const mentions = [];
|
const mentions = [];
|
||||||
for (const role of mentionRoles) {
|
for (const role of mentionRoles) {
|
||||||
if (role == null || role === "none" || role === "off" || role === "") continue;
|
if (role === "here") mentions.push("@here");
|
||||||
else if (role === "here") mentions.push("@here");
|
|
||||||
else if (role === "everyone") mentions.push("@everyone");
|
else if (role === "everyone") mentions.push("@everyone");
|
||||||
else mentions.push(`<@&${role}>`);
|
else mentions.push(`<@&${role}>`);
|
||||||
}
|
}
|
||||||
|
@ -264,15 +270,14 @@ function getInboxMention() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInboxMentionAllowedMentions() {
|
function getInboxMentionAllowedMentions() {
|
||||||
const mentionRoles = Array.isArray(config.mentionRole) ? config.mentionRole : [config.mentionRole];
|
const mentionRoles = getValidMentionRoles();
|
||||||
const allowedMentions = {
|
const allowedMentions = {
|
||||||
everyone: false,
|
everyone: false,
|
||||||
roles: [],
|
roles: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const role of mentionRoles) {
|
for (const role of mentionRoles) {
|
||||||
if (role == null || role === "none" || role === "") continue;
|
if (role === "here" || role === "everyone") allowedMentions.everyone = true;
|
||||||
else if (role === "here" || role === "everyone") allowedMentions.everyone = true;
|
|
||||||
else allowedMentions.roles.push(role);
|
else allowedMentions.roles.push(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue