Arreglando errores garrafales como bugs a la hora de crear la alianza o errores del displayComponent.
This commit is contained in:
@@ -1,8 +1,17 @@
|
||||
import {Guild, User} from "discord.js";
|
||||
import {Guild, Invite, User} from "discord.js";
|
||||
|
||||
export async function replaceVars(text: string, user: User | undefined, guild: Guild | undefined, stats?: any): Promise<string> {
|
||||
//@ts-ignore
|
||||
export async function replaceVars(text: string, user: User | undefined, guild: Guild | undefined, stats?: any, invite: Invite | undefined): Promise<string> {
|
||||
if(!text) return '';
|
||||
|
||||
// Crear inviteObject solo si invite existe y tiene guild
|
||||
const inviteObject = invite?.guild ? {
|
||||
guild: {
|
||||
//@ts-ignore
|
||||
icon: `https://cdn.discordapp.com/icons/${invite.guild.id}/${invite.guild.icon}.webp?size=256`
|
||||
}
|
||||
} : null;
|
||||
|
||||
return text
|
||||
/**
|
||||
* USER INFO
|
||||
@@ -12,9 +21,23 @@ export async function replaceVars(text: string, user: User | undefined, guild: G
|
||||
.replace(/(user\.mention)/g, user ? `<@${user.id}>` : '')
|
||||
.replace(/(user\.avatar)/g, user?.displayAvatarURL({ forceStatic: false }) ?? '')
|
||||
|
||||
/**
|
||||
* USER STATS
|
||||
*/
|
||||
.replace(/(user\.pointsAll)/g, stats?.totalPoints?.toString() ?? '0')
|
||||
.replace(/(user\.pointsWeekly)/g, stats?.weeklyPoints?.toString() ?? '0')
|
||||
.replace(/(user\.pointsMonthly)/g, stats?.monthlyPoints?.toString() ?? '0')
|
||||
|
||||
/**
|
||||
* GUILD INFO
|
||||
*/
|
||||
.replace(/(guild\.name)/g, guild?.name ?? '')
|
||||
.replace(/(guild\.icon)/g, guild?.iconURL({ forceStatic: false }) ?? '');
|
||||
.replace(/(guild\.icon)/g, guild?.iconURL({ forceStatic: false }) ?? '')
|
||||
|
||||
/**
|
||||
* INVITE INFO
|
||||
*/
|
||||
.replace(/(invite\.name)/g, invite?.guild?.name ?? "")
|
||||
.replace(/(invite\.icon)/g, inviteObject?.guild.icon ?? '0')
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user