Skip to content

Commit

Permalink
Fix badges
Browse files Browse the repository at this point in the history
  • Loading branch information
DonovanDMC committed Jun 3, 2024
1 parent 8071cb6 commit f8da0db
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ COPY package.json package-lock.json ./
RUN npm install
COPY . .
RUN npm run build
RUN npx patch-package
RUN npm prune --prod
CMD ["node", "--no-warnings", "--no-deprecation", "--experimental-specifier-resolution=node", "dist/src/index.js"]
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"up:dev": "sudo docker compose up",
"dev": "pnpm run down && pnpm run up:dev",
"dev:build": "pnpm run down && pnpm run up",
"update": "git pull && git submodule update --init --recursive && docker compose pull && pnpm run down && pnpm run up:d"
"update": "git pull && git submodule update --init --recursive && docker compose pull && pnpm run down && pnpm run up:d",
"postinstall": "patch-package"
},
"repository": {
"type": "git",
Expand Down
7 changes: 3 additions & 4 deletions patches/@napi-rs+canvas+0.1.52.patch
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
diff --git a/node_modules/@napi-rs/canvas/load-image.js b/node_modules/@napi-rs/canvas/load-image.js
index 09e74f0..c7fecb6 100644
index 09e74f0..5d10642 100644
--- a/node_modules/@napi-rs/canvas/load-image.js
+++ b/node_modules/@napi-rs/canvas/load-image.js
@@ -59,6 +59,13 @@ function makeRequest(url, resolve, reject, redirectCount, requestOptions) {
@@ -59,6 +59,12 @@ function makeRequest(url, resolve, reject, redirectCount, requestOptions) {
// lazy load the lib
const lib = isHttps ? (!https ? (https = require('https')) : https) : !http ? (http = require('http')) : http

+ requestOptions ??= {};
+ if (url.host === "i.imgur.com") {
+ requestOptions ??= {};
+ requestOptions.headers ??= {};
+ requestOptions.headers.Authorization = process.env.YR_PROXY_AUTH;
+ url = new URL(`https://proxy.yiff.rocks/get?url=${url.href}`);
+ }
+ console.log(url.href);
lib
.get(url.toString(), requestOptions || {}, (res) => {
const shouldRedirect = REDIRECT_STATUSES.has(res.statusCode) && typeof res.headers.location === 'string'
10 changes: 8 additions & 2 deletions src/interactions/applicationCommands/misc/rank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Command, { ValidLocation } from "../../../util/cmd/Command.js";
import Leveling from "../../../util/Leveling.js";
import Util from "../../../util/Util.js";
import UserConfig from "../../../db/Models/UserConfig.js";
import { Colors } from "../../../util/Constants.js";
import { ApplicationCommandOptionTypes } from "oceanic.js";
import { profileImage } from "discord-arts";

Expand All @@ -19,14 +20,18 @@ export default new Command(import.meta.url, "rank")
const { rank, total } = await Leveling.getUserRank(user.id, interaction.guildID);
const xp = await UserConfig.getXP(user.id, interaction.guildID);
const { level, leftover, needed } = Leveling.calcLevel(xp);
const img = await profileImage("242843345402069002", {
const customBadges: Array<string> = [];
if (user.id === "242843345402069002") {
customBadges.push("https://cdn.discordapp.com/emojis/851308838959579152.png?size=4096");
}
const img = await profileImage(user.id, {
badgesFrame: true,
rankData: {
currentXp: leftover,
requiredXp: leftover + needed,
rank,
level,
barColor: "#A7A4AA",
barColor: Colors.violet.toString(16).padStart(6, "0"),
autoColorRank: true
}
});
Expand All @@ -38,6 +43,7 @@ export default new Command(import.meta.url, "rank")
`EXP: ${xp.toLocaleString()}`,
`Local Rank: **${rank}**/**${total}**`
])
.setImage("attachment://rank.png")
.toJSON(true),
files: [
{
Expand Down

0 comments on commit f8da0db

Please sign in to comment.