Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"date-fns": "^4.1.0",
"dayjs": "^1.11.18",
"deepl-node": "1.20.0",
"discord.js": "14.24.0",
"discord.js": "^14.24.0",
"discordx": "^11.13.2",
"elysia": "^1.4.13"
},
Expand Down
8 changes: 0 additions & 8 deletions prisma/migrations/20240211152331_init/migration.sql

This file was deleted.

2 changes: 0 additions & 2 deletions prisma/migrations/20241101171530_init/migration.sql

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
-- CreateTable
CREATE TABLE "backList" (
"userID" TEXT NOT NULL,
"AddedBy" TEXT NOT NULL,

CONSTRAINT "backList_pkey" PRIMARY KEY ("userID")
);

-- CreateTable
CREATE TABLE "Guild" (
"guildId" TEXT NOT NULL,
Expand Down Expand Up @@ -77,6 +85,7 @@ CREATE TABLE "MemberRole" (
"roleId" TEXT NOT NULL,
"guildId" TEXT NOT NULL,
"memberId" TEXT NOT NULL,
"name" TEXT,

CONSTRAINT "MemberRole_pkey" PRIMARY KEY ("id")
);
Expand All @@ -86,6 +95,7 @@ CREATE TABLE "MemberCommandHistory" (
"id" SERIAL NOT NULL,
"memberId" TEXT NOT NULL,
"guildId" TEXT NOT NULL,
"channelId" TEXT NOT NULL,
"command" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

Expand All @@ -106,6 +116,9 @@ CREATE TABLE "MemberDeletedMessages" (
CONSTRAINT "MemberDeletedMessages_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "backList_userID_key" ON "backList"("userID");

-- CreateIndex
CREATE UNIQUE INDEX "Guild_guildId_key" ON "Guild"("guildId");

Expand Down
4 changes: 2 additions & 2 deletions prisma/migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"
# It should be added in your version-control system (e.g., Git)
provider = "postgresql"
6 changes: 6 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ datasource db {
url = env("DATABASE_URL")
}


model backList {
userID String @id @unique
AddedBy String
}

model Guild {
guildId String @id @unique
guildName String
Expand Down
57 changes: 57 additions & 0 deletions src/commands/mod/add-to-blacklist.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// WHY?
// Well, i want that the bot ignore u.

import type { CommandInteraction } from "discord.js";
import { ApplicationCommandOptionType, PermissionFlagsBits } from "discord.js";
import { Discord, Slash, SlashOption } from "discordx";
import { LogService } from "../../lib/logs/log.service";
import { prisma } from "../../prisma";

@Discord()
export class AddToBlacklist {
@Slash({
name: "add-to-blacklist",
description: `Add a user to bot's blacklist`,
defaultMemberPermissions: PermissionFlagsBits.ManageRoles,
dmPermission: false,
})
async addToBlacklist(
@SlashOption({
name: "user_id",
description: "ID to add to blacklist",
required: true,
type: ApplicationCommandOptionType.String,
})
userId: string,
interaction: CommandInteraction
) {
// LogService.logCommandHistory(interaction, "add-to-blacklist");


const existingEntry = await prisma.backList.findFirst({
where: {
userID: userId,
},
});

if (existingEntry) {
return await interaction.reply({
content: `The user with ID \`${userId}\` is already blacklisted.`,
ephemeral: true,
});
}

await prisma.backList.create({
data: {
userID: userId,
AddedBy: interaction.user.id,
AddedAt: ''
},
});

await interaction.reply({
content: `Successfully added user with ID \`${userId}\` to the blacklist.`,
ephemeral: true,
});
}
}
53 changes: 53 additions & 0 deletions src/commands/mod/remove-from-blacklist.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import type { CommandInteraction } from "discord.js";
import { ApplicationCommandOptionType, PermissionFlagsBits } from "discord.js";
import { Discord, Slash, SlashOption } from "discordx";
import { LogService } from "../../lib/logs/log.service";
import { prisma } from "../../prisma";


@Discord()
export class RemoveFromBlackList {
@Slash({
name: "remove-from-blacklist",
description: `Add a user to bot's blacklist`,
defaultMemberPermissions: PermissionFlagsBits.ManageRoles,
dmPermission: false,
})
async addToBlacklist(
@SlashOption({
name: "user_id",
description: "user ID",
required: true,
type: ApplicationCommandOptionType.String,
})
userId: string,
interaction: CommandInteraction
) {
// LogService.logCommandHistory(interaction, "add-to-blacklist");


const existingEntry = await prisma.backList.findUnique({
where: {
userID: userId,
},
});

if (existingEntry) {
return await interaction.reply({
content: `The user with ID \`${userId}\` is already blacklisted.`,
ephemeral: true,
});
}

await prisma.backList.delete({
where: {
userID: userId,
},
});

await interaction.reply({
content: `Successfully added user with ID \`${userId}\` to the blacklist.`,
ephemeral: true,
});
}
}
16 changes: 14 additions & 2 deletions src/events/ai/ai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { ArgsOf, Client } from "discordx";
import { Discord, On } from "discordx";
import { ConfigValidator } from "../../lib/config-validator";
import { StatsService } from "../../lib/stats/stats.service";
import { prisma } from "../../prisma";
import { AI_SYSTEM_PROMPT } from "./prompt";
import {
channelMessages,
Expand All @@ -26,7 +27,18 @@ export class AiChat {
async messageCreate(
[message]: ArgsOf<"messageCreate">,
client: Client
): Promise<void> {
): Promise<void> {
const isBlacklisted = await prisma.backList.findFirst({
where: {
userID: message.author.id,
},
});

if (isBlacklisted) {
// Si está en la blacklist, ignorar el mensaje y salir
return;
}

if (
message.author.bot ||
!ConfigValidator.isFeatureEnabled("GOOGLE_GENERATIVE_AI_API_KEY")
Expand Down Expand Up @@ -295,4 +307,4 @@ export class AiChat {
}
return null;
}
}
}