Make getUserSetting not return undefined
This commit is contained in:
parent
e24bdc2b6f
commit
76f8b0e38e
|
@ -50,7 +50,7 @@ export const UserSettings = findByFactoryCode<Record<PropertyKey, UserSettingDef
|
|||
* @param group The setting group
|
||||
* @param name The name of the setting
|
||||
*/
|
||||
export function getUserSetting<T = any>(group: string, name: string): UserSettingDefinition<T> | undefined {
|
||||
export function getUserSetting<T = any>(group: string, name: string): UserSettingDefinition<T> {
|
||||
if (!Vencord.Plugins.isPluginEnabled("UserSettingsAPI")) throw new Error("Cannot use UserSettingsAPI without setting as dependency.");
|
||||
|
||||
for (const key in UserSettings) {
|
||||
|
@ -60,6 +60,8 @@ export function getUserSetting<T = any>(group: string, name: string): UserSettin
|
|||
return userSetting;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`UserSettingsAPI: Setting ${group}.${name} not found.`);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -59,7 +59,7 @@ const TrustedRolesIds = [
|
|||
|
||||
const AsyncFunction = async function () { }.constructor;
|
||||
|
||||
const ShowCurrentGame = getUserSettingLazy<boolean>("status", "showCurrentGame")!;
|
||||
const ShowCurrentGame = getUserSettingLazy<boolean>("status", "showCurrentGame");
|
||||
|
||||
async function forceUpdate() {
|
||||
const outdated = await checkForUpdates();
|
||||
|
|
|
@ -15,7 +15,7 @@ import { Clipboard, GuildStore, Menu, PermissionStore } from "@webpack/common";
|
|||
|
||||
const GuildSettingsActions = findByProps("open", "selectRole", "updateGuild");
|
||||
|
||||
const DeveloperMode = getUserSettingLazy("appearance", "developerMode")!;
|
||||
const DeveloperMode = getUserSettingLazy("appearance", "developerMode");
|
||||
|
||||
function PencilIcon() {
|
||||
return (
|
||||
|
|
|
@ -33,7 +33,7 @@ const useProfileThemeStyle = findByCode("profileThemeStyle:", "--profile-gradien
|
|||
const ActivityComponent = findComponentByCode("onOpenGameProfile");
|
||||
const ActivityClassName = findByProps("activity", "buttonColor");
|
||||
|
||||
const ShowCurrentGame = getUserSettingLazy<boolean>("status", "showCurrentGame")!;
|
||||
const ShowCurrentGame = getUserSettingLazy<boolean>("status", "showCurrentGame");
|
||||
|
||||
async function getApplicationAsset(key: string): Promise<string> {
|
||||
if (/https?:\/\/(cdn|media)\.discordapp\.(com|net)\/attachments\//.test(key)) return "mp:" + key.replace(/https?:\/\/(cdn|media)\.discordapp\.(com|net)\//, "");
|
||||
|
|
|
@ -28,7 +28,7 @@ import style from "./style.css?managed";
|
|||
|
||||
const Button = findComponentByCode("Button.Sizes.NONE,disabled:");
|
||||
|
||||
const ShowCurrentGame = getUserSettingLazy<boolean>("status", "showCurrentGame")!;
|
||||
const ShowCurrentGame = getUserSettingLazy<boolean>("status", "showCurrentGame");
|
||||
|
||||
function makeIcon(showCurrentGame?: boolean) {
|
||||
const { oldIcon } = settings.use(["oldIcon"]);
|
||||
|
|
|
@ -28,7 +28,7 @@ interface IgnoredActivity {
|
|||
|
||||
const RunningGameStore = findStore("RunningGameStore");
|
||||
|
||||
const ShowCurrentGame = getUserSettingLazy("status", "showCurrentGame")!;
|
||||
const ShowCurrentGame = getUserSettingLazy("status", "showCurrentGame");
|
||||
|
||||
function ToggleIcon(activity: IgnoredActivity, tooltipText: string, path: string, fill: string) {
|
||||
return (
|
||||
|
|
|
@ -54,7 +54,7 @@ const ChannelMessage = findComponentByCode("childrenExecutedCommand:", ".hideAcc
|
|||
const SearchResultClasses = findByProps("message", "searchResult");
|
||||
const EmbedClasses = findByProps("embedAuthorIcon", "embedAuthor", "embedAuthor");
|
||||
|
||||
const MessageDisplayCompact = getUserSettingLazy("textAndImages", "messageDisplayCompact")!;
|
||||
const MessageDisplayCompact = getUserSettingLazy("textAndImages", "messageDisplayCompact");
|
||||
|
||||
const messageLinkRegex = /(?<!<)https?:\/\/(?:\w+\.)?discord(?:app)?\.com\/channels\/(?:\d{17,20}|@me)\/(\d{17,20})\/(\d{17,20})/g;
|
||||
const tenorRegex = /^https:\/\/(?:www\.)?tenor\.com\//;
|
||||
|
|
Loading…
Reference in a new issue