Skip to content

Commit 19461d4

Browse files
author
xyzjesper
committed
Added Permission System as Module and update interaction Module. Implemented Discovery to the Vanity Service.
Updated to discord.js 14.22 and bump package.json. Database update added.
1 parent 18bd2f6 commit 19461d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+10838
-8403
lines changed

bun.lock

Lines changed: 252 additions & 179 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,42 +20,41 @@
2020
"description": "DisBot",
2121
"type": "module",
2222
"dependencies": {
23-
"@napi-rs/canvas": "^0.1.73",
24-
"@prisma/client": "^6.11.1",
25-
"@sentry/cli": "^2.47.1",
26-
"@sentry/node": "^9.38.0",
23+
"@napi-rs/canvas": "^0.1.77",
24+
"@prisma/client": "^6.14.0",
25+
"@sentry/cli": "^2.52.0",
26+
"@sentry/node": "^10.5.0",
2727
"@t3-oss/env-nextjs": "^0.13.8",
2828
"@top-gg/sdk": "^3.1.6",
2929
"@types/body-parser": "^1.19.6",
3030
"@types/js-yaml": "^4.0.9",
3131
"axios": "1.11.0",
3232
"body-parser": "^2.2.0",
3333
"canvacord": "^6.0.2",
34-
"canvas": "^3.1.2",
34+
"canvas": "^3.2.0",
3535
"clsx": "^2.1.1",
3636
"colors": "^1.4.0",
3737
"copyfiles": "^2.4.1",
3838
"cors": "^2.8.5",
3939
"discord-html-transcripts": "^3.2.0",
4040
"discord-welcome-card": "^4.9.3",
41-
"discord.js": "^14.21.0",
41+
"discord.js": "^14.22.0",
4242
"discordbotlist": "^1.1.1",
43-
"dotenv": "^17.2.0",
43+
"dotenv": "^17.2.1",
4444
"ejs": "^3.1.10",
4545
"express": "^5.1.0",
4646
"js-yaml": "^4.1.0",
47-
"marked": "^16.0.0",
47+
"marked": "^16.2.0",
4848
"moment": "^2.30.1",
49-
"mongoose": "^8.16.3",
5049
"ms": "^2.1.3",
5150
"multer": "2.0.2",
5251
"ngrok": "^5.0.0-beta.2",
5352
"node-fetch": "^3.3.2",
54-
"node-gyp": "^11.2.0",
53+
"node-gyp": "^11.4.1",
5554
"node-superfetch": "^0.3.5",
5655
"nodemon": "^3.1.10",
57-
"ollama": "^0.5.16",
58-
"prisma": "^6.11.1",
56+
"ollama": "^0.5.17",
57+
"prisma": "^6.14.0",
5958
"punycode": "^2.3.1",
6059
"rss-parser": "^3.13.0",
6160
"short-uuid": "^5.2.0",
@@ -65,27 +64,27 @@
6564
"topgg-autoposter": "^2.0.2",
6665
"ts-node": "^10.9.2",
6766
"tsc-alias": "^1.8.16",
68-
"typedoc": "^0.28.9",
69-
"undici": "^7.11.0",
67+
"typedoc": "^0.28.10",
68+
"undici": "^7.14.0",
7069
"uuid": "^11.1.0",
7170
"winston": "^3.17.0",
7271
"yaml": "^2.8.1"
7372
},
7473
"devDependencies": {
75-
"@types/bcrypt": "^5.0.2",
74+
"@types/bcrypt": "^6.0.0",
7675
"@types/eslint-config-prettier": "^6.11.3",
7776
"@types/express": "^5.0.3",
7877
"@types/ms": "^2.1.0",
7978
"@types/multer": "^2.0.0",
80-
"@types/node": "^24.0.13",
81-
"@types/node-fetch": "^2.6.12",
79+
"@types/node": "^24.3.0",
80+
"@types/node-fetch": "^2.6.13",
8281
"@types/uuid": "^10.0.0",
83-
"esbuild": "^0.25.6",
82+
"esbuild": "^0.25.9",
8483
"postcss": "^8.5.6",
8584
"prettier": "^3.6.2",
8685
"tsconfig-paths": "^4.2.0",
8786
"ttypescript": "^1.5.15",
88-
"typescript": "^5.8.3",
87+
"typescript": "^5.9.2",
8988
"typescript-transform-paths": "^3.5.5"
9089
}
9190
}

prisma/schema.prisma

Lines changed: 57 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,50 @@ datasource db {
1111

1212
// Guilds
1313
model Guilds {
14-
id String @id @default(auto()) @map("_id") @db.ObjectId
15-
GuildId String @unique
16-
GuildName String
17-
GuildOwner String
18-
AutoAutoDeletes AutoDeletes[]
19-
AutoPublish AutoPublish?
20-
AutoReacts AutoReacts[]
21-
AutoRoles AutoRoles[]
22-
GuildBans GuildBans[]
23-
ChatModerations ChatModerations?
24-
ChannelLinks ChannelLinks[]
25-
DiscordAddons DiscordAddons?
26-
Giveaways Giveaways[]
27-
TempVoices TempVoices[]
28-
GuildLeaveSetup GuildLeaveSetups?
29-
GuildLogging GuildLoggings?
30-
MessageTemplates MessageTemplates[]
31-
Permissions Permissions?
32-
ReactionRole ReactionRoles[]
33-
Security Securitys?
34-
SpotifyNotifications SpotifyNotifications[]
35-
Tags Tags[]
36-
TicketSetups TicketSetups[]
37-
GuildFeatureToggle GuildFeatureToggles?
38-
TwitchNotifications TwitchNotifications[]
39-
GuildWelcomeSetup GuildWelcomeSetups?
40-
YoutubeNotifications YoutubeNotifications[]
41-
GuildLoggers GuildLoggers[]
14+
id String @id @default(auto()) @map("_id") @db.ObjectId
15+
GuildId String @unique
16+
GuildName String
17+
GuildOwner String
18+
AutoAutoDeletes AutoDeletes[]
19+
AutoPublish AutoPublish?
20+
AutoReacts AutoReacts[]
21+
AutoRoles AutoRoles[]
22+
GuildBans GuildBans[]
23+
ChatModerations ChatModerations?
24+
ChannelLinks ChannelLinks[]
25+
DiscordAddons DiscordAddons?
26+
Giveaways Giveaways[]
27+
TempVoices TempVoices[]
28+
GuildLeaveSetup GuildLeaveSetups?
29+
GuildLogging GuildLoggings?
30+
MessageTemplates MessageTemplates[]
31+
ReactionRole ReactionRoles[]
32+
Security Securitys?
33+
SpotifyNotifications SpotifyNotifications[]
34+
Tags Tags[]
35+
TicketSetups TicketSetups[]
36+
GuildFeatureToggle GuildFeatureToggles?
37+
TwitchNotifications TwitchNotifications[]
38+
GuildWelcomeSetup GuildWelcomeSetups?
39+
YoutubeNotifications YoutubeNotifications[]
40+
GuildLoggers GuildLoggers[]
41+
GuildInteractionPermissions GuildInteractionPermissions[]
42+
}
43+
44+
model GuildInteractionPermissions {
45+
id String @id @default(auto()) @map("_id") @db.ObjectId
46+
UUID String @unique
47+
RoleIds String[]
48+
UserIds String[]
49+
ChannelIds String[]
50+
CustomId String?
51+
CommandName String?
52+
Type String // BUTTON, SELECTMENU, COMMAND, SUBCOMMAND, SUBCOMMANDGROUP, MODAL (GuildPermissionType)
53+
DisableInternalUserPermission Boolean? @default(false)
54+
NeedsGuildOwner Boolean?
55+
Cooldown Int?
56+
GuildId String
57+
Guilds Guilds @relation(fields: [GuildId], references: [GuildId])
4258
}
4359

4460
model AutoDeletes {
@@ -256,18 +272,6 @@ model MessageTemplates {
256272
Guilds Guilds @relation(fields: [GuildId], references: [GuildId])
257273
}
258274

259-
model Permissions {
260-
id String @id @default(auto()) @map("_id") @db.ObjectId
261-
Permissions PermissionData[]
262-
GuildId String @unique
263-
Guilds Guilds @relation(fields: [GuildId], references: [GuildId])
264-
}
265-
266-
type PermissionData {
267-
RoleId String
268-
Type String
269-
}
270-
271275
model ReactionRoles {
272276
id String @id @default(auto()) @map("_id") @db.ObjectId
273277
UUID String @unique
@@ -564,17 +568,19 @@ model Customers {
564568
}
565569

566570
model Vanitys {
567-
id String @id @default(auto()) @map("_id") @db.ObjectId
568-
UUID String @unique
569-
Slug String
570-
Host String
571-
GuildId String
572-
Invite String
573-
Analytics VanityAnalytics?
574-
CreatedAt DateTime
575-
Embed VanityEmbeds?
576-
UserId String
577-
Users Users @relation(fields: [UserId], references: [UserId])
571+
id String @id @default(auto()) @map("_id") @db.ObjectId
572+
UUID String @unique
573+
Slug String
574+
Host String
575+
GuildId String
576+
Invite String
577+
InDiscovery Boolean? @default(false)
578+
IsBannedFromDiscover Boolean? @default(false)
579+
Analytics VanityAnalytics?
580+
CreatedAt DateTime
581+
Embed VanityEmbeds?
582+
UserId String
583+
Users Users @relation(fields: [UserId], references: [UserId])
578584
}
579585

580586
model VanityEmbeds {

src/api/restAPI/api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {LoggingAction} from "../../enums/loggingTypes.js";
2424
import cors from "cors";
2525
import {botData} from "../../main/version.js";
2626
import {Config} from "../../main/config.js";
27+
import {discoveryApi} from "./routes/get/discovery.js";
2728

2829
export const APIServer = express();
2930

@@ -50,6 +51,7 @@ export async function api(client: ExtendedClient) {
5051

5152
// Open Stats Route
5253
APIServer.get("/v2/bot/stats", disbotstatsRoute);
54+
APIServer.get("/v2/bot/discovery", discoveryApi);
5355

5456
// Customer Routes
5557
APIServer.get(
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import {database} from "../../../../main/database.js";
2+
import {Request, Response} from "express";
3+
import {ExtendedClient} from "../../../../types/client.js";
4+
5+
const bannedWords = [
6+
"hitler", "heil", "nazi", "fascist", "racist", "slavery", "genocide", "holocaust", "ss",
7+
"nigger", "negro", "coon", "chink", "spic", "kike", "paki", "gook", "faggot", "tranny", "dyke",
8+
"retard", "cripple", "mong", "gypsy", "towelhead", "raghead", "sandnigger", "white trash",
9+
"fuck", "shit", "bitch", "cunt", "asshole", "dick", "cock", "pussy", "slut", "whore", "bastard",
10+
"motherfucker", "dumbass", "jackass", "douchebag", "prick", "bollocks", "wanker", "twat",
11+
"kys", "suicide", "hang yourself", "cut yourself", "kill yourself", "die", "murder",
12+
"massacre", "shoot yourself", "jump off", "overdose", "self harm", "gas yourself",
13+
"rape", "rapist", "molest", "incest", "child porn", "cp", "bestiality", "zoophile",
14+
"pedophile", "pedo", "groomer", "porn", "pornhub", "xvideos", "xnxx", "redtube",
15+
"anal", "oral", "cum", "semen", "clit", "dildo", "vibrator", "boobs", "tits", "fisting",
16+
"handjob", "blowjob", "gangbang", "deepthroat", "bukkake", "stripper", "escort",
17+
"drug", "weed", "cocaine", "crack", "heroin", "meth", "lsd", "ecstasy", "molly", "ketamine",
18+
"addict", "stoner", "junkie", "overdose", "cartel", "dealer", "smack",
19+
"terrorist", "isis", "al qaeda", "taliban", "jihad", "bomber", "bombing",
20+
"school shooter", "mass shooting", "columbine", "9/11", "beheading", "execute",
21+
"slave", "whip", "lynch", "burn", "hang", "torture", "blood", "gore", "snuff", "kill",
22+
"sodomize", "necrophilia", "beastiality", "zoophilia", "pedo shit", "pedo scum"
23+
]
24+
25+
26+
function validateContent(text?: string): boolean {
27+
if (!text) return true;
28+
const lower = text.toLowerCase();
29+
return !bannedWords.some((w) => lower.includes(w));
30+
}
31+
32+
export const discoveryApi = async (
33+
req: Request,
34+
res: Response
35+
): Promise<void> => {
36+
try {
37+
const client = req.app.get("client") as ExtendedClient;
38+
const dData = await database.vanitys.findMany({
39+
include: {
40+
Embed: {
41+
include: {
42+
Author: true
43+
}
44+
}
45+
},
46+
where: {
47+
InDiscovery: true,
48+
IsBannedFromDiscover: false
49+
}
50+
});
51+
52+
if (dData.length === 0) {
53+
res.status(404).json({
54+
success: false,
55+
error: "No discovery data"
56+
});
57+
return;
58+
}
59+
60+
// Daten + Validation
61+
const data = dData
62+
.map((s) => {
63+
return {
64+
UUID: s.UUID,
65+
Slug: s.Slug,
66+
Host: s.Host,
67+
GuildId: s.GuildId,
68+
Invite: s.Invite,
69+
InDiscovery: s.InDiscovery,
70+
Embed: s.Embed,
71+
UserId: s.UserId,
72+
MemberCount: client.guilds.cache.get(s.GuildId)?.memberCount ?? 0
73+
};
74+
})
75+
// Filter: nur Server erlauben, die keine Hass-Sachen enthalten
76+
.filter((s) => {
77+
return (
78+
validateContent(s.Slug) &&
79+
validateContent(s.Embed?.Title) &&
80+
validateContent(s.Embed?.Description) &&
81+
validateContent(s.Embed?.Author?.Name)
82+
);
83+
});
84+
85+
if (data.length === 0) {
86+
res.status(403).json({
87+
success: false,
88+
error: "All discovery entries contained blocked content"
89+
});
90+
return;
91+
}
92+
93+
res.status(200).json({
94+
success: true,
95+
data
96+
});
97+
} catch (error) {
98+
res.status(500).json({
99+
success: false,
100+
error: error instanceof Error ? error.message : "Unknown error"
101+
});
102+
}
103+
};

src/enums/permissionType.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,12 @@ export enum PermissionType {
2929
Economy = "Economy",
3030
IgnoreDiscordPermissionRequirement = "IgnoreDiscordPermissionRequirement",
3131
}
32+
33+
export enum GuildPermissionType {
34+
BUTTON = "BUTTON",
35+
SELECTMENU = "SELECTMENU",
36+
COMMAND = "COMMAND",
37+
SUBCOMMAND = "SUBCOMMAND",
38+
SUBCOMMANDGROUP = "SUBCOMMANDGROUP",
39+
MODAL = "MODAL",
40+
}

0 commit comments

Comments
 (0)