Skip to content

Commit

Permalink
Actually important fix (#714)
Browse files Browse the repository at this point in the history
* Some fixes

Make profile and levels display server avatar.
Fix for username length limit
Fix for username filter
Critical RPG fix

* Make rpg footer display server avatar
  • Loading branch information
Hipperooni authored Nov 21, 2023
1 parent ee5ca57 commit ee02457
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 37 deletions.
8 changes: 4 additions & 4 deletions src/discord/commands/guild/d.levels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export const dLevels: SlashCommand = {
await levels(target.id),
// Load Images
await Canvas.loadImage(await getAsset('cardLevelIcons')),
await Canvas.loadImage(target.user.displayAvatarURL({ extension: 'jpg' })),
await Canvas.loadImage(target.displayAvatarURL({ extension: 'jpg' })),
await Canvas.loadImage(await getAsset('teamtripsitIcon')),
await Canvas.loadImage(await getAsset('premiumIcon')),
await Canvas.loadImage(await getAsset('boosterIcon')),
Expand Down Expand Up @@ -607,15 +607,15 @@ export const dLevels: SlashCommand = {
const applyUsername = (canvas:Canvas.Canvas, text:string) => {
const usernameContext = canvas.getContext('2d');
do {
fontSize -= 2;
fontSize -= 1;
usernameContext.font = `${fontSize}px ${userFont}`;
} while (usernameContext.measureText(text).width > 530);
} while (usernameContext.measureText(text).width > 508);
return usernameContext.font;
};

// Username Text
// Temporary code for user flairs
const filteredDisplayName = target.displayName.replace(/[^A-Za-z0-9]/g, '');
const filteredDisplayName = target.displayName.replace(/[^\x20-\x7E]/g, '');
context.fillStyle = textColor;
context.font = `40px ${userFont}`;
context.textAlign = 'left';
Expand Down
8 changes: 4 additions & 4 deletions src/discord/commands/guild/d.profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export const dProfile: SlashCommand = {
// Get the status icon
// await Canvas.loadImage(await imageGet(`icon_${target.presence?.status ?? 'offline'}`)),
// Get the avatar image
await Canvas.loadImage(target.user.displayAvatarURL({ extension: 'jpg' })),
await Canvas.loadImage(target.displayAvatarURL({ extension: 'jpg' })),
// Get the birthday card overlay
await Canvas.loadImage(await getAsset('cardBirthday')),
await Canvas.loadImage(await getAsset('teamtripsitIcon')),
Expand Down Expand Up @@ -447,14 +447,14 @@ export const dProfile: SlashCommand = {
const applyUsername = (canvas:Canvas.Canvas, text:string) => {
const usernameContext = canvas.getContext('2d');
do {
fontSize -= 2;
fontSize -= 1;
usernameContext.font = `${fontSize}px ${userFont}`;
} while (usernameContext.measureText(text).width > 530);
} while (usernameContext.measureText(text).width > 508);
return usernameContext.font;
};

// Username Text
const filteredDisplayName = target.displayName.replace(/[^A-Za-z0-9]/g, '');
const filteredDisplayName = target.displayName.replace(/[^\x20-\x7E]/g, '');
context.font = `40px ${userFont}`;
context.fillStyle = textColor;
context.textBaseline = 'middle';
Expand Down
Loading

0 comments on commit ee02457

Please sign in to comment.