Update setPresence custom variable logic
All checks were successful
CI / CI (push) Successful in 1m25s
All checks were successful
CI / CI (push) Successful in 1m25s
This commit is contained in:
parent
69c7fd8d53
commit
ba99719c20
1 changed files with 16 additions and 4 deletions
|
@ -18,10 +18,22 @@ module.exports = function ({presenceText, presenceType, client}) {
|
||||||
uptimeFormat = `less than a minute`
|
uptimeFormat = `less than a minute`
|
||||||
}
|
}
|
||||||
|
|
||||||
let regex = [/\${guilds}/g,/\${prefix}/g,/\${uptime}/g, /\${members}/g];
|
let presenceVariables = {
|
||||||
let replaceValue = [guildInfo.guildCount, globalPrefix, uptimeFormat, guildInfo.totalMembers];
|
guilds: guildInfo.guildCount,
|
||||||
for(let i = 0; i < regex.length; i++){
|
prefix: globalPrefix,
|
||||||
presenceText = presenceText.replace(regex[i], replaceValue[i]);
|
uptime: uptimeFormat,
|
||||||
|
members: guildInfo.totalMembers
|
||||||
|
}
|
||||||
|
|
||||||
|
const regex = /(?<=\${)(.*?)(?=})/g;
|
||||||
|
const matches = presenceText.match(regex);
|
||||||
|
|
||||||
|
if(matches){
|
||||||
|
matches.forEach(match => {
|
||||||
|
if(presenceVariables[match]){
|
||||||
|
presenceText = presenceText.replace(`\${${match}}`, presenceVariables[match]);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue