Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Commit 0326735

Browse files
committed
fix(*): fix the bug with blacklist list, removed extra command from husky and more idk lmao
1 parent e507123 commit 0326735

File tree

3 files changed

+58
-36
lines changed

3 files changed

+58
-36
lines changed

.husky/pre-commit

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
npx lint-staged
5-
npx lint-staged
4+
npx lint-staged
File renamed without changes.

src/Scripts/blacklist/list.ts

Lines changed: 57 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,76 @@
11
import { PrismaClient } from '@prisma/client';
2-
import { ChatInputCommandInteraction, EmbedBuilder } from 'discord.js';
2+
import { APIEmbedField, ChatInputCommandInteraction, EmbedBuilder } from 'discord.js';
3+
import { paginate } from '../../Utils/functions/paginator';
4+
import { colors } from '../../Utils/functions/utils';
35

46
module.exports = {
57
async execute(interaction: ChatInputCommandInteraction, database: PrismaClient) {
68
const serverOpt = interaction.options.getString('type');
79

8-
if (serverOpt == 'server') displayServers();
9-
else if (serverOpt == 'user') displayUsers();
10+
const embeds: EmbedBuilder[] = [];
11+
let fields: APIEmbedField[] = [];
1012

11-
async function displayServers() {
13+
const LIMIT = 5;
14+
let counter = 0;
15+
16+
17+
// loop through all data
18+
// after counter hits limit (5) assign fields to an embed and push to to embeds array
19+
// reset counter & clear fields array
20+
// repeat until you reach the end
21+
22+
if (serverOpt == 'server') {
1223
const result = await database.blacklistedServers.findMany();
1324

14-
const Embed = new EmbedBuilder()
15-
.setColor('#0099ff')
16-
.setAuthor({
17-
name: 'Blacklisted Servers:',
18-
iconURL: interaction.client.user?.avatarURL()?.toString(),
25+
result.forEach((data, index) => {
26+
console.log(data);
27+
28+
fields.push({
29+
name: data.serverName,
30+
value: `${interaction.client.emoji.icons.id}: ${data.serverId}\nReason: ${data.reason}\n\n`,
1931
});
20-
for (let i = 0; i < result.length; i++) {
21-
Embed.addFields([
22-
{
23-
name: result[i].serverName,
24-
value: `${interaction.client.emoji.icons.id}: ${result[i].serverId}\nReason: ${result[i].reason}\n\n`,
25-
},
26-
]);
27-
}
28-
interaction.reply({ embeds: [Embed] });
29-
}
3032

33+
counter++;
34+
if (counter >= LIMIT || index === result.length - 1) {
35+
embeds.push(new EmbedBuilder()
36+
.setFields(fields)
37+
.setColor('#0099ff')
38+
.setAuthor({
39+
name: 'Blacklisted Servers:',
40+
iconURL: interaction.client.user?.avatarURL()?.toString(),
41+
}));
3142

32-
async function displayUsers() {
43+
counter = 0;
44+
fields = [];
45+
}
46+
});
47+
}
48+
else if (serverOpt == 'user') {
3349
const result = await database.blacklistedUsers.findMany();
3450

35-
const Embed = new EmbedBuilder()
36-
.setColor('#0099ff')
37-
.setAuthor({
38-
name: 'Blacklisted Users:',
39-
iconURL: interaction.client.user?.avatarURL()?.toString(),
51+
result.forEach((data, index) => {
52+
fields.push({
53+
name: data.username,
54+
value: `${interaction.client.emoji.icons.id}: ${data.userId}\nReason: ${data.reason}`,
4055
});
4156

42-
for (let i = 0; i < result.length; i++) {
43-
Embed.addFields([
44-
{
45-
name: result[i].username,
46-
value: `${interaction.client.emoji.icons.id}: ${result[i].userId}\nReason: ${result[i].reason}\n\n`,
47-
},
48-
]);
49-
}
50-
interaction.reply({ embeds: [Embed] });
57+
counter++;
58+
if (counter >= LIMIT || index === result.length - 1) {
59+
embeds.push(new EmbedBuilder()
60+
.setFields(fields)
61+
.setColor(colors('chatbot'))
62+
.setAuthor({
63+
name: 'Blacklisted Users:',
64+
iconURL: interaction.client.user?.avatarURL()?.toString(),
65+
}));
66+
67+
counter = 0;
68+
fields = [];
69+
}
70+
});
5171
}
72+
73+
paginate(interaction, embeds);
74+
5275
},
5376
};

0 commit comments

Comments
 (0)