Skip to content

Commit

Permalink
Merge pull request #344 from discordextremelist/labels-feature
Browse files Browse the repository at this point in the history
Add the labels feature (NSFW and AI bot labelling), user preference to toggle showing NSFW bots, and blurring of NSFW bot profile picture's in botCards
  • Loading branch information
carolinaisslaying authored Mar 2, 2025
2 parents a6433d9 + ce34731 commit c2344e9
Show file tree
Hide file tree
Showing 18 changed files with 288 additions and 27 deletions.
5 changes: 5 additions & 0 deletions @types/del.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ declare global {
enableGames: boolean;
experiments: boolean;
theme: number;
hideNSFW: undefined | boolean;
};
profile: {
bio: string;
Expand Down Expand Up @@ -254,6 +255,10 @@ declare global {
approved: number;
edited: number;
};
labels: undefined | {
nsfw: boolean;
ai: boolean;
};
status: {
approved: boolean;
premium: boolean;
Expand Down
2 changes: 1 addition & 1 deletion assets/Public/css/themes/black.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/Public/css/themes/dark.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/Public/css/themes/light.css

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions assets/Sass/components/overwrite.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ html[data-deltheme=light] {
--del-button-outer-shadow-alpha: unset !important;
}

img.nsfw {
filter: blur(5px);
backdrop-filter: blur(5px);
}

img.nsfw:hover {
filter: unset;
backdrop-filter: unset;
}

.has-text-shadow-blue {
color: #a8b9bf;
}

.button {
&.is-outlined:not(.is-loading):not(.is-default) {
&:hover,
Expand Down
49 changes: 49 additions & 0 deletions assets/Sass/extensions/switch.sass
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,55 @@ $switch-focus: 1px dotted $grey !default
&:after
background: $color

// .switch.is-grey-lighter
$shadow-blue-name: "shadow-blue";
$shadow-blue-color: #7697a4;
&.is-#{$shadow-blue-name}
+ label
.switch-active
display: none
.switch-inactive
display: inline-block
&:checked
+ label
&::before,
&:before
background: $shadow-blue-color
.switch-active
display: inline-block
.switch-inactive
display: none
&.is-outlined
&:checked
+ label
&::before,
&:before
background-color: transparent
border-color: $shadow-blue-color !important
&::after,
&:after
background: $shadow-blue-color
&.is-thin
&.is-outlined
+ label
&::after,
&:after
box-shadow: none
&.is-unchecked-#{$shadow-blue-name}
+ label
&::before,
&:before
background: $shadow-blue-color
&.is-outlined
+ label
&::before,
&:before
background-color: transparent
border-color: $shadow-blue-color !important
&::after,
&:after
background: $shadow-blue-color

.field-body
.switch[type="checkbox"]
+ label
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

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

3 changes: 2 additions & 1 deletion src/Routes/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ router.get(
defaultForegroundColour: "#ffffff",
enableGames: true,
experiments: false,
theme: 0
theme: 0,
hideNSFW: false
},
profile: {
bio: "",
Expand Down
32 changes: 32 additions & 0 deletions src/Routes/bots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,10 @@ router.post(
archived: false,
hidden: false,
modHidden: false
},
labels: {
ai: req.body.ai ? true : false,
nsfw: req.body.nsfw ? true : false,
}
} satisfies delBot);

Expand Down Expand Up @@ -745,6 +749,10 @@ router.post(
archived: false,
hidden: false,
modHidden: false
},
labels: {
ai: req.body.ai ? true : false,
nsfw: req.body.nsfw ? true : false,
}
} satisfies delBot
}
Expand Down Expand Up @@ -1687,6 +1695,10 @@ router.post(
options: req.body.widgetOptions,
server: req.body.widgetServer
},
labels: {
ai: req.body.ai ? true : false,
nsfw: req.body.nsfw ? true : false,
},
"date.edited": Date.now()
}
}
Expand Down Expand Up @@ -1738,6 +1750,10 @@ router.post(
channel: botExists.widgetbot.channel,
options: botExists.widgetbot.options,
server: botExists.widgetbot.server
},
labels: {
ai: botExists.labels?.ai,
nsfw: botExists.labels?.nsfw,
}
} satisfies Partial<delBot>,
new: {
Expand Down Expand Up @@ -1778,6 +1794,10 @@ router.post(
channel: req.body.widgetChannel,
options: req.body.widgetOptions,
server: req.body.widgetServer
},
labels: {
ai: req.body.ai ? true : false,
nsfw: req.body.nsfw ? true : false,
}
} satisfies Partial<delBot>
}
Expand Down Expand Up @@ -3080,6 +3100,10 @@ router.post(
approved: 0,
edited: 0
},
labels: {
ai: req.body.ai ? true : false,
nsfw: req.body.nsfw ? true : false,
},
"status.archived": false
}
}
Expand Down Expand Up @@ -3134,6 +3158,10 @@ router.post(
},
status: {
archived: true
},
labels: {
ai: botExists.labels?.ai,
nsfw: botExists.labels?.nsfw,
}
} satisfies partialBot,
new: {
Expand Down Expand Up @@ -3177,6 +3205,10 @@ router.post(
},
status: {
archived: false
},
labels: {
ai: req.body.ai ? true : false,
nsfw: req.body.nsfw ? true : false,
}
} satisfies partialBot
}
Expand Down
43 changes: 30 additions & 13 deletions src/Routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,14 @@ function sortAll() {
router.get("/", variables, async (req: Request, res: Response) => {
res.locals.premidPageInfo = res.__("premid.home");

const bots = await featuring.getFeaturedBots();
let bots: delBot[];

if (req.user?.db?.preferences.hideNSFW) {
bots = await featuring.getFeaturedSFWBots();
} else {
bots = await featuring.getFeaturedBots();
}

const servers = await featuring.getFeaturedServers();
const templates = await featuring.getFeaturedTemplates();

Expand Down Expand Up @@ -146,12 +153,13 @@ router.get("/bots", variables, async (req: Request, res: Response) => {
}
);
bots = (await botCache.getAllBots()).filter(
({ status, scopes }) =>
({ status, scopes, labels }) =>
status.approved &&
!status.siteBot &&
!status.archived &&
!status.hidden &&
!status.modHidden &&
(!req.user?.db?.preferences.hideNSFW || !labels?.nsfw) &&
scopes?.slashCommands
);
break;
Expand All @@ -160,12 +168,13 @@ router.get("/bots", variables, async (req: Request, res: Response) => {
title = res.__("common.bots.title.fun");
subtitle = res.__("common.bots.subtitle.filter.fun");
bots = (await botCache.getAllBots()).filter(
({ status, tags }) =>
({ status, tags, labels }) =>
status.approved &&
!status.siteBot &&
!status.archived &&
!status.hidden &&
!status.modHidden &&
(!req.user?.db?.preferences.hideNSFW || !labels?.nsfw) &&
tags.includes("Fun")
);
break;
Expand All @@ -174,12 +183,13 @@ router.get("/bots", variables, async (req: Request, res: Response) => {
title = res.__("common.bots.title.social");
subtitle = res.__("common.bots.subtitle.filter.social");
bots = (await botCache.getAllBots()).filter(
({ status, tags }) =>
({ status, tags, labels }) =>
status.approved &&
!status.siteBot &&
!status.archived &&
!status.hidden &&
!status.modHidden &&
(!req.user?.db?.preferences.hideNSFW || !labels?.nsfw) &&
tags.includes("Social")
);
break;
Expand All @@ -188,12 +198,13 @@ router.get("/bots", variables, async (req: Request, res: Response) => {
title = res.__("common.bots.title.economy");
subtitle = res.__("common.bots.subtitle.filter.economy");
bots = (await botCache.getAllBots()).filter(
({ status, tags }) =>
({ status, tags, labels }) =>
status.approved &&
!status.siteBot &&
!status.archived &&
!status.hidden &&
!status.modHidden &&
(!req.user?.db?.preferences.hideNSFW || !labels?.nsfw) &&
tags.includes("Economy")
);
break;
Expand All @@ -202,12 +213,13 @@ router.get("/bots", variables, async (req: Request, res: Response) => {
title = res.__("common.bots.title.utility");
subtitle = res.__("common.bots.subtitle.filter.utility");
bots = (await botCache.getAllBots()).filter(
({ status, tags }) =>
({ status, tags, labels }) =>
status.approved &&
!status.siteBot &&
!status.archived &&
!status.hidden &&
!status.modHidden &&
(!req.user?.db?.preferences.hideNSFW || !labels?.nsfw) &&
tags.includes("Utility")
);
break;
Expand All @@ -216,12 +228,13 @@ router.get("/bots", variables, async (req: Request, res: Response) => {
title = res.__("common.bots.title.moderation");
subtitle = res.__("common.bots.subtitle.filter.moderation");
bots = (await botCache.getAllBots()).filter(
({ status, tags }) =>
({ status, tags, labels }) =>
status.approved &&
!status.siteBot &&
!status.archived &&
!status.hidden &&
!status.modHidden &&
(!req.user?.db?.preferences.hideNSFW || !labels?.nsfw) &&
tags.includes("Moderation")
);
break;
Expand All @@ -230,12 +243,13 @@ router.get("/bots", variables, async (req: Request, res: Response) => {
title = res.__("common.bots.title.multipurpose");
subtitle = res.__("common.bots.subtitle.filter.multipurpose");
bots = (await botCache.getAllBots()).filter(
({ status, tags }) =>
({ status, tags, labels }) =>
status.approved &&
!status.siteBot &&
!status.archived &&
!status.hidden &&
!status.modHidden &&
(!req.user?.db?.preferences.hideNSFW || !labels?.nsfw) &&
tags.includes("Multipurpose")
);
break;
Expand All @@ -244,33 +258,36 @@ router.get("/bots", variables, async (req: Request, res: Response) => {
title = res.__("common.bots.title.music");
subtitle = res.__("common.bots.subtitle.filter.music");
bots = (await botCache.getAllBots()).filter(
({ status, tags }) =>
({ status, tags, labels }) =>
status.approved &&
!status.siteBot &&
!status.archived &&
!status.hidden &&
!status.modHidden &&
(!req.user?.db?.preferences.hideNSFW || !labels?.nsfw) &&
tags.includes("Music")
);
break;
default:
bots = (await botCache.getAllBots()).filter(
({ status }) =>
({ status, labels }) =>
status.approved &&
!status.siteBot &&
!status.archived &&
!status.hidden &&
!status.modHidden
!status.modHidden &&
(!req.user?.db?.preferences.hideNSFW || !labels?.nsfw)
);
}
} else
bots = (await botCache.getAllBots()).filter(
({ status }) =>
({ status, labels }) =>
status.approved &&
!status.siteBot &&
!status.archived &&
!status.hidden &&
!status.modHidden
!status.modHidden &&
(!req.user?.db?.preferences.hideNSFW || !labels?.nsfw)
);

res.render("templates/bots/index", {
Expand Down
Loading

0 comments on commit c2344e9

Please sign in to comment.