Skip to content

Commit

Permalink
Merge branch 'main' into auto-relaunch
Browse files Browse the repository at this point in the history
  • Loading branch information
FedeIlLeone authored Oct 18, 2024
2 parents 4da86b0 + 3835e26 commit f4c66f0
Show file tree
Hide file tree
Showing 34 changed files with 211 additions and 320 deletions.
2 changes: 1 addition & 1 deletion bin/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ async function buildTheme({ watch, noInstall, production, noReload, addon }: Arg
),
);

manifest.plaintextPatches = "splash.css";
manifest.splash = "splash.css";
}

if (!existsSync(distPath)) mkdirSync(distPath, { recursive: true });
Expand Down
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"installdir",
"Jsonifiable",
"konami",
"leaderboard",
"lezer",
"LOCALAPPDATA",
"logname",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"lint": "pnpm run prettier:check && pnpm run eslint:check && pnpm run cspell:check && pnpm run typescript:check",
"lint:fix": "pnpm run prettier:fix && pnpm run eslint:fix && pnpm run cspell:check && pnpm run typescript:check",
"postinstall": "tsx scripts/build-bin.mts",
"prepublishOnly": "rm -rf dist; tsc --declaration --emitDeclarationOnly --noEmit false -p tsconfig.json --outDir dist; rm -rf dist/scripts; mv dist/src/* dist; rm -rf dist/src; cp src/*.d.ts dist; tsx scripts/create-import-wrappers.mts",
"postpublish": "rm -rf *.d.ts; rm -rf dist; npm run build",
"prepublishOnly": "rm -rf dist && tsc --declaration --emitDeclarationOnly --noEmit false -p tsconfig.json --outDir dist && rm -rf dist/scripts && mv dist/src/* dist && rm -rf dist/src && cp src/*.d.ts dist && tsx scripts/create-import-wrappers.mts",
"postpublish": "rm -rf *.d.ts && rm -rf dist && npm run build",
"release": "np",
"docs": "typedoc src/renderer/replugged.ts --excludeExternals",
"docs:watch": "pnpm run docs --watch"
Expand Down
22 changes: 13 additions & 9 deletions src/renderer/apis/commands.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Channel, Guild, User } from "discord-types/general";
import { REPLUGGED_CLYDE_ID } from "../../constants";
import type {
AnyRepluggedCommand,
CommandOptionReturn,
Expand All @@ -12,12 +13,12 @@ import type {
} from "../../types";
// eslint-disable-next-line no-duplicate-imports
import { ApplicationCommandOptionType } from "../../types";
import icon from "../assets/logo.png";
import { constants, i18n, messages, users } from "../modules/common";
import type { Store } from "../modules/common/flux";
import { Logger } from "../modules/logger";
import { filters, getByStoreName, waitForModule } from "../modules/webpack";
import icon from "../assets/logo.png";
import { REPLUGGED_CLYDE_ID } from "../../constants";

const logger = Logger.api("Commands");

let RepluggedUser: User | undefined;
Expand Down Expand Up @@ -204,9 +205,9 @@ export class CommandManager {
}

/**
* Code to register an slash command
* @param cmd Slash Command to be registered
* @returns An Callback to unregister the slash command
* Code to register a slash command
* @param command Slash command to be registered
* @returns A callback to unregister the slash command
*/
public registerCommand<const T extends CommandOptions>(command: RepluggedCommand<T>): () => void {
if (!commandAndSections.has(this.#section.id)) {
Expand All @@ -215,8 +216,10 @@ export class CommandManager {
commands: new Map<string, AnyRepluggedCommand>(),
});
}
const currentSection = commandAndSections.get(this.#section.id);
command.applicationId = currentSection?.section.id;

const currentSection = commandAndSections.get(this.#section.id)!; // Can't be undefined as we set it above
command.section = currentSection.section;
command.applicationId = currentSection.section.id;
command.displayName ??= command.name;
command.displayDescription ??= command.description;
command.type = 2;
Expand All @@ -233,15 +236,16 @@ export class CommandManager {
return option;
});

currentSection?.commands.set(command.id, command as AnyRepluggedCommand);
currentSection.commands.set(command.id, command as AnyRepluggedCommand);

const uninject = (): void => {
void currentSection?.commands.delete(command.id!);
void currentSection.commands.delete(command.id!);
this.#unregister = this.#unregister.filter((u) => u !== uninject);
};
this.#unregister.push(uninject);
return uninject;
}

/**
* Code to unregister all slash commands registered with this class
*/
Expand Down
6 changes: 0 additions & 6 deletions src/renderer/coremods/badges/badge.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
[class*="containerWithContent"] {
min-height: -webkit-fit-content;
min-height: -moz-fit-content;
min-height: fit-content;
}

.replugged-badge {
padding: 3px;
box-sizing: border-box;
Expand Down
8 changes: 5 additions & 3 deletions src/renderer/coremods/badges/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ interface APIRepluggedCustomBadge {
}

interface APIRepluggedBadges {
[key: string]: boolean | APIRepluggedCustomBadge;
developer: boolean;
staff: boolean;
support: boolean;
Expand Down Expand Up @@ -152,14 +151,17 @@ export async function start(): Promise<void> {
}

badgeElements.forEach((badgeElement) => {
if (badgeCache[badgeElement.id]) {
if (badgeCache[badgeElement.id as keyof APIRepluggedBadges]) {
const { component, ...props } = badgeElement;
const badgeColor = badgeCache.custom.color;

newBadges.push({
...props,
icon: "replugged",
component: React.createElement(component, {
color: badgeCache.custom.color ?? DISCORD_BLURPLE,
color:
(badgeColor && (badgeColor.startsWith("#") ? badgeColor : `#${badgeColor}`)) ??
DISCORD_BLURPLE,
}),
});
}
Expand Down
18 changes: 1 addition & 17 deletions src/renderer/coremods/badges/plaintextPatches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,7 @@ import type { PlaintextPatch } from "src/types";

export default [
{
// Edit the UserProfileBadgeList component
find: ".profileBadge2",
replacements: [
{
// Add the "replugged-badge" class if it's our custom badge
match: /src:(\w+)\.src,className:\w+\(\)\({/,
replace: `$&["replugged-badge"]:$1.component,`,
},
{
// Change to a div and add a children for our custom badge
match: /"img",({.+?src:(\w+)\.src,)/,
replace: `$2.component?"div":"img",$1children:$2.component,`,
},
],
},
{
// Edit the ProfileBadges component (new profile design)
// Edit the ProfileBadges component
find: /\.container,\w+\),"aria-label":\w+.\w+\.Messages\.PROFILE_USER_BADGES/,
replacements: [
// Add the "replugged-badge" class if it's our custom badge
Expand Down
Loading

0 comments on commit f4c66f0

Please sign in to comment.