Merge branch 'main' of https://github.com/Vendicated/Vencord
This commit is contained in:
commit
8085325814
14 changed files with 45 additions and 34 deletions
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "vencord",
|
"name": "vencord",
|
||||||
"private": "true",
|
"private": "true",
|
||||||
"version": "1.11.6",
|
"version": "1.11.7",
|
||||||
"description": "The cutest Discord client mod",
|
"description": "The cutest Discord client mod",
|
||||||
"homepage": "https://github.com/Vendicated/Vencord#readme",
|
"homepage": "https://github.com/Vendicated/Vencord#readme",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
|
|
@ -31,6 +31,7 @@ export const commands = {} as Record<string, Command>;
|
||||||
// hack for plugins being evaluated before we can grab these from webpack
|
// hack for plugins being evaluated before we can grab these from webpack
|
||||||
const OptPlaceholder = Symbol("OptionalMessageOption") as any as Option;
|
const OptPlaceholder = Symbol("OptionalMessageOption") as any as Option;
|
||||||
const ReqPlaceholder = Symbol("RequiredMessageOption") as any as Option;
|
const ReqPlaceholder = Symbol("RequiredMessageOption") as any as Option;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional message option named "message" you can use in commands.
|
* Optional message option named "message" you can use in commands.
|
||||||
* Used in "tableflip" or "shrug"
|
* Used in "tableflip" or "shrug"
|
||||||
|
@ -44,11 +45,16 @@ export let OptionalMessageOption: Option = OptPlaceholder;
|
||||||
*/
|
*/
|
||||||
export let RequiredMessageOption: Option = ReqPlaceholder;
|
export let RequiredMessageOption: Option = ReqPlaceholder;
|
||||||
|
|
||||||
|
// Discord's command list has random gaps for some reason, which can cause issues while rendering the commands
|
||||||
|
// Add this offset to every added command to keep them unique
|
||||||
|
let commandIdOffset: number;
|
||||||
|
|
||||||
export const _init = function (cmds: Command[]) {
|
export const _init = function (cmds: Command[]) {
|
||||||
try {
|
try {
|
||||||
BUILT_IN = cmds;
|
BUILT_IN = cmds;
|
||||||
OptionalMessageOption = cmds.find(c => (c.untranslatedName || c.displayName) === "shrug")!.options![0];
|
OptionalMessageOption = cmds.find(c => (c.untranslatedName || c.displayName) === "shrug")!.options![0];
|
||||||
RequiredMessageOption = cmds.find(c => (c.untranslatedName || c.displayName) === "me")!.options![0];
|
RequiredMessageOption = cmds.find(c => (c.untranslatedName || c.displayName) === "me")!.options![0];
|
||||||
|
commandIdOffset = Math.abs(BUILT_IN.map(x => Number(x.id)).sort((x, y) => x - y)[0]) - BUILT_IN.length;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
new Logger("CommandsAPI").error("Failed to load CommandsApi", e, " - cmds is", cmds);
|
new Logger("CommandsAPI").error("Failed to load CommandsApi", e, " - cmds is", cmds);
|
||||||
}
|
}
|
||||||
|
@ -142,7 +148,7 @@ export function registerCommand<C extends Command>(command: C, plugin: string) {
|
||||||
command.isVencordCommand = true;
|
command.isVencordCommand = true;
|
||||||
command.untranslatedName ??= command.name;
|
command.untranslatedName ??= command.name;
|
||||||
command.untranslatedDescription ??= command.description;
|
command.untranslatedDescription ??= command.description;
|
||||||
command.id ??= `-${BUILT_IN.length + 1}`;
|
command.id ??= `-${BUILT_IN.length + commandIdOffset + 1}`;
|
||||||
command.applicationId ??= "-1"; // BUILT_IN;
|
command.applicationId ??= "-1"; // BUILT_IN;
|
||||||
command.type ??= ApplicationCommandType.CHAT_INPUT;
|
command.type ??= ApplicationCommandType.CHAT_INPUT;
|
||||||
command.inputType ??= ApplicationCommandInputType.BUILT_IN_TEXT;
|
command.inputType ??= ApplicationCommandInputType.BUILT_IN_TEXT;
|
||||||
|
|
|
@ -101,7 +101,7 @@ if (IS_VESKTOP || !IS_VANILLA) {
|
||||||
// TODO: Restrict this to only imported packages with fixed version.
|
// TODO: Restrict this to only imported packages with fixed version.
|
||||||
// Perhaps auto generate with esbuild
|
// Perhaps auto generate with esbuild
|
||||||
csp["script-src"] ??= [];
|
csp["script-src"] ??= [];
|
||||||
csp["script-src"].push("'unsafe-eval'", "https://unpkg.com", "https://cdnjs.cloudflare.com");
|
csp["script-src"].push("'unsafe-eval'", "https://cdn.jsdelivr.net", "https://cdnjs.cloudflare.com");
|
||||||
headers[header] = [stringifyPolicy(csp)];
|
headers[header] = [stringifyPolicy(csp)];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -73,7 +73,7 @@ export default definePlugin({
|
||||||
find: "#{intl::PROFILE_USER_BADGES}",
|
find: "#{intl::PROFILE_USER_BADGES}",
|
||||||
replacement: [
|
replacement: [
|
||||||
{
|
{
|
||||||
match: /(alt:" ","aria-hidden":!0,src:)(.{0,20}(\i)\.icon\))/,
|
match: /(alt:" ","aria-hidden":!0,src:)(.+?)(?=,)(?<=href:(\i)\.link.+?)/,
|
||||||
replace: (_, rest, originalSrc, badge) => `...${badge}.props,${rest}${badge}.image??(${originalSrc})`
|
replace: (_, rest, originalSrc, badge) => `...${badge}.props,${rest}${badge}.image??(${originalSrc})`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,8 +73,8 @@ export default definePlugin({
|
||||||
group: true,
|
group: true,
|
||||||
replacement: [
|
replacement: [
|
||||||
{
|
{
|
||||||
match: /(?<=\.AVATAR_SIZE\).{0,100};)(?=return)/,
|
match: /let{speaking:\i/,
|
||||||
replace: "$self.useAccountPanelRef();"
|
replace: "$self.useAccountPanelRef();$&"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
match: /(\.AVATAR,children:.+?renderPopout:(\i)=>){(.+?)}(?=,position)(?<=currentUser:(\i).+?)/,
|
match: /(\.AVATAR,children:.+?renderPopout:(\i)=>){(.+?)}(?=,position)(?<=currentUser:(\i).+?)/,
|
||||||
|
|
|
@ -44,15 +44,15 @@ export default definePlugin({
|
||||||
find: "#{intl::GUILD_OWNER}),children:",
|
find: "#{intl::GUILD_OWNER}),children:",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /(\.CUSTOM_STATUS.+?animate:)\i/,
|
match: /(\.CUSTOM_STATUS.+?animate:)\i/,
|
||||||
replace: (_, rest) => `${rest}!0`
|
replace: "$1!0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Guild Banner
|
// Guild Banner
|
||||||
find: ".animatedBannerHoverLayer,onMouseEnter:",
|
find: ".animatedBannerHoverLayer,onMouseEnter:",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /(?<=guildBanner:\i,animate:)\i(?=}\))/,
|
match: /(\.headerContent.+?guildBanner:\i,animate:)\i/,
|
||||||
replace: "!0"
|
replace: "$1!0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -99,7 +99,7 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
// Current user area, at bottom of channels/dm list
|
// Current user area, at bottom of channels/dm list
|
||||||
{
|
{
|
||||||
find: "renderAvatarWithPopout(){",
|
find: "#{intl::ACCOUNT_SPEAKING_WHILE_MUTED}",
|
||||||
replacement: [
|
replacement: [
|
||||||
// Use Decor avatar decoration hook
|
// Use Decor avatar decoration hook
|
||||||
{
|
{
|
||||||
|
|
|
@ -260,14 +260,7 @@ export default definePlugin({
|
||||||
replace: (m, props, nowPlaying) => `${m}$self.renderToggleGameActivityButton(${props},${nowPlaying}),`
|
replace: (m, props, nowPlaying) => `${m}$self.renderToggleGameActivityButton(${props},${nowPlaying}),`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Discord has 2 different components for activities. Currently, the last is the one being used
|
// Activities from the apps launcher in the bottom right of the chat bar
|
||||||
{
|
|
||||||
find: ".activityTitleText,variant",
|
|
||||||
replacement: {
|
|
||||||
match: /\.activityTitleText.+?children:(\i)\.name.*?}\),/,
|
|
||||||
replace: (m, props) => `${m}$self.renderToggleActivityButton(${props}),`
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
find: ".promotedLabelWrapperNonBanner,children",
|
find: ".promotedLabelWrapperNonBanner,children",
|
||||||
replacement: {
|
replacement: {
|
||||||
|
|
|
@ -149,6 +149,12 @@ export default definePlugin({
|
||||||
|
|
||||||
renderChatBarButton: ChatBarIcon,
|
renderChatBarButton: ChatBarIcon,
|
||||||
|
|
||||||
|
colorCodeFromNumber(color: number): string {
|
||||||
|
return `#${[color >> 16, color >> 8, color]
|
||||||
|
.map(x => (x & 0xFF).toString(16))
|
||||||
|
.join("")}`;
|
||||||
|
},
|
||||||
|
|
||||||
// Gets the Embed of a Link
|
// Gets the Embed of a Link
|
||||||
async getEmbed(url: URL): Promise<Object | {}> {
|
async getEmbed(url: URL): Promise<Object | {}> {
|
||||||
const { body } = await RestAPI.post({
|
const { body } = await RestAPI.post({
|
||||||
|
@ -157,6 +163,8 @@ export default definePlugin({
|
||||||
urls: [url]
|
urls: [url]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// The endpoint returns the color as a number, but Discord expects a string
|
||||||
|
body.embeds[0].color = this.colorCodeFromNumber(body.embeds[0].color);
|
||||||
return await body.embeds[0];
|
return await body.embeds[0];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -166,7 +174,7 @@ export default definePlugin({
|
||||||
message.embeds.push({
|
message.embeds.push({
|
||||||
type: "rich",
|
type: "rich",
|
||||||
rawTitle: "Decrypted Message",
|
rawTitle: "Decrypted Message",
|
||||||
color: "0x45f5f5",
|
color: "#45f5f5",
|
||||||
rawDescription: revealed,
|
rawDescription: revealed,
|
||||||
footer: {
|
footer: {
|
||||||
text: "Made with ❤️ by c0dine and Sammy!",
|
text: "Made with ❤️ by c0dine and Sammy!",
|
||||||
|
|
|
@ -73,17 +73,21 @@ export default definePlugin({
|
||||||
{
|
{
|
||||||
find: "#{intl::GUILD_OWNER}),children:",
|
find: "#{intl::GUILD_OWNER}),children:",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /(?<=\.MEMBER_LIST}\),\[\]\),)(.+?color:)null!=.{0,50}?(?=,)/,
|
match: /(typingIndicatorRef:.+?},)(\i=.+?)color:null!=.{0,50}?(?=,)/,
|
||||||
replace: (_, rest) => `ircColor=$self.calculateNameColorForListContext(arguments[0]),${rest}ircColor`
|
replace: (_, rest1, rest2) => `${rest1}ircColor=$self.calculateNameColorForListContext(arguments[0]),${rest2}color:ircColor`
|
||||||
},
|
},
|
||||||
predicate: () => settings.store.memberListColors
|
predicate: () => settings.store.memberListColors
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
calculateNameColorForMessageContext(context: any) {
|
calculateNameColorForMessageContext(context: any) {
|
||||||
const id = context?.message?.author?.id;
|
const userId: string | undefined = context?.message?.author?.id;
|
||||||
const colorString = context?.author?.colorString;
|
const colorString = context?.author?.colorString;
|
||||||
const color = calculateNameColorForUser(id);
|
const color = calculateNameColorForUser(userId);
|
||||||
|
|
||||||
|
// Color preview in role settings
|
||||||
|
if (context?.message?.channel_id === "1337" && userId === "313337")
|
||||||
|
return colorString;
|
||||||
|
|
||||||
if (settings.store.applyColorOnlyInDms && !context?.channel?.isPrivate()) {
|
if (settings.store.applyColorOnlyInDms && !context?.channel?.isPrivate()) {
|
||||||
return colorString;
|
return colorString;
|
||||||
|
|
|
@ -63,11 +63,11 @@ export default definePlugin({
|
||||||
|
|
||||||
stringDelta(delta: number, showMillis: boolean) {
|
stringDelta(delta: number, showMillis: boolean) {
|
||||||
const diff: Diff = {
|
const diff: Diff = {
|
||||||
days: Math.round(delta / (60 * 60 * 24 * 1000)),
|
days: Math.floor(delta / (60 * 60 * 24 * 1000)),
|
||||||
hours: Math.round((delta / (60 * 60 * 1000)) % 24),
|
hours: Math.floor((delta / (60 * 60 * 1000)) % 24),
|
||||||
minutes: Math.round((delta / (60 * 1000)) % 60),
|
minutes: Math.floor((delta / (60 * 1000)) % 60),
|
||||||
seconds: Math.round(delta / 1000 % 60),
|
seconds: Math.floor(delta / 1000 % 60),
|
||||||
milliseconds: Math.round(delta % 1000)
|
milliseconds: Math.floor(delta % 1000)
|
||||||
};
|
};
|
||||||
|
|
||||||
const str = (k: DiffKey) => diff[k] > 0 ? `${diff[k]} ${diff[k] > 1 ? k : k.substring(0, k.length - 1)}` : null;
|
const str = (k: DiffKey) => diff[k] > 0 ? `${diff[k]} ${diff[k] > 1 ? k : k.substring(0, k.length - 1)}` : null;
|
||||||
|
|
|
@ -57,10 +57,10 @@ export default definePlugin({
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
find: "#{intl::BLOCKED_MESSAGES_HIDE}",
|
find: ".__invalid_blocked,",
|
||||||
replacement: [
|
replacement: [
|
||||||
{
|
{
|
||||||
match: /let\{[^}]*collapsedReason[^}]*\}/,
|
match: /let{expanded:\i,[^}]*?collapsedReason[^}]*}/,
|
||||||
replace: "if($self.shouldHide(arguments[0]))return null;$&"
|
replace: "if($self.shouldHide(arguments[0]))return null;$&"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -136,7 +136,7 @@ export default definePlugin({
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
if (data.sinkId != null && data.sinkId !== data.audioContext.sinkId && "setSinkId" in AudioContext.prototype) {
|
if (data.sinkId != null && data.sinkId !== data.audioContext.sinkId && "setSinkId" in AudioContext.prototype) {
|
||||||
// @ts-expect-error https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/setSinkId
|
// @ts-expect-error https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/setSinkId
|
||||||
data.audioContext.setSinkId(data.sinkId);
|
data.audioContext.setSinkId(data.sinkId === "default" ? "" : data.sinkId);
|
||||||
}
|
}
|
||||||
|
|
||||||
data.gainNode.gain.value = data._mute
|
data.gainNode.gain.value = data._mute
|
||||||
|
|
|
@ -69,8 +69,8 @@ export interface ApngFrameData {
|
||||||
// The below code is only used on the Desktop (electron) build of Vencord.
|
// The below code is only used on the Desktop (electron) build of Vencord.
|
||||||
// Browser (extension) builds do not contain these remote imports.
|
// Browser (extension) builds do not contain these remote imports.
|
||||||
|
|
||||||
export const shikiWorkerSrc = `https://unpkg.com/@vap/shiki-worker@0.0.8/dist/${IS_DEV ? "index.js" : "index.min.js"}`;
|
export const shikiWorkerSrc = `https://cdn.jsdelivr.net/npm/@vap/shiki-worker@0.0.8/dist/${IS_DEV ? "index.js" : "index.min.js"}`;
|
||||||
export const shikiOnigasmSrc = "https://unpkg.com/@vap/shiki@0.10.3/dist/onig.wasm";
|
export const shikiOnigasmSrc = "https://cdn.jsdelivr.net/npm/@vap/shiki@0.10.3/dist/onig.wasm";
|
||||||
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
export const getStegCloak = /* #__PURE__*/ makeLazy(() => import("https://unpkg.com/stegcloak-dist@1.0.0/index.js"));
|
export const getStegCloak = /* #__PURE__*/ makeLazy(() => import("https://cdn.jsdelivr.net/npm/stegcloak-dist@1.0.0/index.js"));
|
||||||
|
|
Loading…
Add table
Reference in a new issue