Skip to content

Commit

Permalink
Trip Town flairs (#745)
Browse files Browse the repository at this point in the history
* Proof of concept

* Working POC

* Added flair override function for mods

* Added /voice ping

Can only be used once per 3 hours for a single user.
Can only be used once per hour globally.

* Adding AI mod to flairs

* Final touches for flairs

Seems to be working. Almost ready to be pushed?

* Update for vip-lounge being lvl 20

* Flairs ready to go

* Fix to rejections passing as adjustments

* Add preview image for flair

* I love linting

* I am good at linting

---------

Co-authored-by: LunaUrsa <[email protected]>
  • Loading branch information
Hipperooni and LunaUrsa authored Jan 18, 2024
1 parent fd1f85c commit 6b7c709
Show file tree
Hide file tree
Showing 8 changed files with 794 additions and 90 deletions.
38 changes: 24 additions & 14 deletions src/discord/commands/guild/d.levels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ export const dLevels: SlashCommand = {
// Check get fresh persona data
// log.debug(F, `personaData home (Change) ${JSON.stringify(personaData, null, 2)}`);
let userFont = 'futura';
let userFlair = '';
if (personaData) {
// Get the existing inventory data
const inventoryData = await db.rpg_inventory.findMany({
Expand All @@ -366,6 +367,7 @@ export const dLevels: SlashCommand = {

const equippedBackground = inventoryData.find(item => item.equipped === true && item.effect === 'background');
const equippedFont = inventoryData.find(item => item.equipped === true && item.effect === 'font');
const equippedFlair = inventoryData.find(item => item.equipped === true && item.effect === 'userflair');
// log.debug(F, `equippedBackground: ${JSON.stringify(equippedBackground, null, 2)} `);
if (equippedBackground) {
const imagePath = await getAsset(equippedBackground.value);
Expand All @@ -384,6 +386,9 @@ export const dLevels: SlashCommand = {
await getAsset(equippedFont.value);
userFont = equippedFont.value;
}
if (equippedFlair) {
userFlair = equippedFlair.effect_value;
}
}
// Top Right Chips
context.fillStyle = chipColor;
Expand Down Expand Up @@ -480,25 +485,30 @@ export const dLevels: SlashCommand = {
// If so, move Username Text up so the title can fit underneath

// Username Text
// Temporary code for user flairs
const filteredDisplayName = await deFuckifyText(target.displayName);
let filteredDisplayName = await deFuckifyText(target.displayName);
// If the filteredDisplayName is much shorter than what was input, display their username as a fallback
if (filteredDisplayName.length < target.displayName.length / 2) {
filteredDisplayName = target.user.username.charAt(0).toUpperCase() + target.user.username.slice(1);
}

context.fillStyle = textColor;
context.font = `50px ${userFont}`;
context.textAlign = 'left';
// const flair = null;
const usernameHeight = 76;
context.textBaseline = 'middle';
// if (flair) {
// usernameHeight = 72;
// fontSize = 25;
// context.font = fontSizeFamily;
// context.textBaseline = 'top';
// context.font = applyUsername(canvasObj, `${flair}`);
// context.fillText(`${flair}`, 146, 90);
// context.textBaseline = 'bottom';
// }
let usernameHeight = 76;
let fontSize = 50;
const maxLength = 508;

if (userFlair) {
usernameHeight = 62;
fontSize = 25;
context.textBaseline = 'top';
context.font = resizeText(canvasObj, userFlair, fontSize, userFont, maxLength);
context.fillText(`${userFlair}`, 146, 97);
context.textBaseline = 'bottom';
}

fontSize = 50;
context.textBaseline = 'middle';
context.font = resizeText(canvasObj, filteredDisplayName, fontSize, userFont, maxLength);
context.fillText(`${filteredDisplayName}`, 146, usernameHeight);

Expand Down
74 changes: 51 additions & 23 deletions src/discord/commands/guild/d.profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export const dProfile: SlashCommand = {

// log.debug(F, `personaData home (Change) ${JSON.stringify(personaData, null, 2)}`);
let userFont = 'futura';
let userFlair = '';
if (personaData) {
// Get the existing inventory data
const inventoryData = await db.rpg_inventory.findMany({
Expand All @@ -197,6 +198,7 @@ export const dProfile: SlashCommand = {

const equippedBackground = inventoryData.find(item => item.equipped === true && item.effect === 'background');
const equippedFont = inventoryData.find(item => item.equipped === true && item.effect === 'font');
const equippedFlair = inventoryData.find(item => item.equipped === true && item.effect === 'userflair');
// log.debug(F, `equippedBackground: ${JSON.stringify(equippedBackground, null, 2)} `);
if (equippedBackground) {
const imagePath = await getAsset(equippedBackground.value);
Expand All @@ -215,6 +217,9 @@ export const dProfile: SlashCommand = {
await getAsset(equippedFont.value);
userFont = equippedFont.value;
}
if (equippedFlair) {
userFlair = equippedFlair.effect_value;
}
}

// Draw the chips
Expand Down Expand Up @@ -311,18 +316,33 @@ export const dProfile: SlashCommand = {
// const CampIcon = await Canvas.loadImage(await imageGet('campIconA'));
// context.drawImage(CampIcon, 547, 17);

// WIP: Check to see if a user has bought a title in the shop
// If so, move Username Text up so the title can fit underneath

// Username Text
const filteredDisplayName = await deFuckifyText(target.displayName);
context.font = `50px ${userFont}`;
let filteredDisplayName = await deFuckifyText(target.displayName);
// If the filteredDisplayName is much shorter than what was input, display their username as a fallback
if (filteredDisplayName.length < target.displayName.length / 2) {
filteredDisplayName = target.user.username.charAt(0).toUpperCase() + target.user.username.slice(1);
}

context.fillStyle = textColor;
context.textBaseline = 'middle';
const fontSize = 50;
context.font = `50px ${userFont}`;
context.textAlign = 'left';
let usernameHeight = 76;
let fontSize = 50;
const maxLength = 508;

if (userFlair) {
usernameHeight = 62;
fontSize = 25;
context.textBaseline = 'top';
context.font = resizeText(canvasObj, userFlair, fontSize, userFont, maxLength);
context.fillText(`${userFlair}`, 146, 97);
context.textBaseline = 'bottom';
}

fontSize = 50;
context.textBaseline = 'middle';
context.font = resizeText(canvasObj, filteredDisplayName, fontSize, userFont, maxLength);
context.fillText(`${filteredDisplayName}`, 146, 76);
context.fillText(`${filteredDisplayName}`, 146, usernameHeight);

// User Timezone
context.font = '25px futura';
Expand Down Expand Up @@ -585,26 +605,34 @@ export async function getProfilePreview(target: GuildMember, option: string, ima
userFont = fontName;
}
// Username Text
const filteredDisplayName = await deFuckifyText(target.displayName);
context.font = `50px ${userFont}`;
let filteredDisplayName = await deFuckifyText(target.displayName);
// If the filteredDisplayName is much shorter than what was input, display their username as a fallback
if (filteredDisplayName.length < target.displayName.length / 2) {
filteredDisplayName = target.user.username.charAt(0).toUpperCase() + target.user.username.slice(1);
}

context.fillStyle = textColor;
context.textBaseline = 'middle';
const fontSize = 50;
context.font = `50px ${userFont}`;
context.textAlign = 'left';
let usernameHeight = 76;
let fontSize = 50;
const maxLength = 508;
context.font = resizeText(canvasObj, filteredDisplayName, fontSize, userFont, maxLength);
context.fillText(`${filteredDisplayName}`, 146, 76);
context.fillStyle = textColor;
if (option === 'profileTitle') {
context.textBaseline = 'bottom';
context.fillText(`${filteredDisplayName}`, 146, 76);
context.font = '30px futura';
const userFlair = 'Your Custom Flair Here';

if (option === 'userflair') {
usernameHeight = 62;
fontSize = 25;
context.textBaseline = 'top';
context.fillText('Your Custom Title Here', 146, 86);
} else {
context.textBaseline = 'middle';
context.fillText(`${filteredDisplayName}`, 146, 76);
context.font = resizeText(canvasObj, userFlair, fontSize, userFont, maxLength);
context.fillText(`${userFlair}`, 146, 97);
context.textBaseline = 'bottom';
}

fontSize = 50;
context.textBaseline = 'middle';
context.font = resizeText(canvasObj, filteredDisplayName, fontSize, userFont, maxLength);
context.fillText(`${filteredDisplayName}`, 146, usernameHeight);

/* User Timezone
context.font = '25px futura';
context.textAlign = 'right';
Expand Down
Loading

0 comments on commit 6b7c709

Please sign in to comment.