diff --git a/package.json b/package.json index b837a90ed..14160f140 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "db:validateSchema": "docker exec -it tripbot npx prisma validate", "db:generateClient": "npx prisma generate && docker exec -it tripbot npx prisma generate", "db:pushDev": "docker exec -it tripbot npx prisma db push && npm run tripbot:db:generate", - "db:migrateDev": "docker exec -it tripbot npx prisma migrate dev -n ai_ui_fix", + "db:migrateDev": "docker exec -it tripbot npx prisma migrate dev -n welcome_fix", "db:seed": "docker exec -it tripbot npx prisma db seed", "## PGADMIN ##": "", "pgadmin": "docker compose --project-name tripbot up -d --force-recreate --build tripbot_pgadmin", diff --git a/src/discord/events/guildMemberAdd.ts b/src/discord/events/guildMemberAdd.ts index 560e7c0e1..45547be62 100644 --- a/src/discord/events/guildMemberAdd.ts +++ b/src/discord/events/guildMemberAdd.ts @@ -10,6 +10,7 @@ const F = f(__filename); export const guildMemberAdd: GuildMemberAddEvent = { name: 'guildMemberAdd', async execute(member) { + await member.fetch(true); const guildData = await db.discord_guilds.upsert({ where: { id: member.guild.id, @@ -26,7 +27,7 @@ export const guildMemberAdd: GuildMemberAddEvent = { if (!guildData) return; if (member.guild.id !== env.DISCORD_GUILD_ID) return; - await trust(member); + // await trust(member); }, }; diff --git a/src/prisma/tripbot/migrations/20240219221538_welcome_fix/migration.sql b/src/prisma/tripbot/migrations/20240219221538_welcome_fix/migration.sql new file mode 100644 index 000000000..f100f0a8e --- /dev/null +++ b/src/prisma/tripbot/migrations/20240219221538_welcome_fix/migration.sql @@ -0,0 +1,17 @@ +-- CreateTable +CREATE TABLE "members" ( + "id" TEXT NOT NULL, + "guild_id" TEXT NOT NULL, + "trusted" BOOLEAN NOT NULL DEFAULT false, + + CONSTRAINT "members_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "members_id_guildid_unique" ON "members"("id", "guild_id"); + +-- AddForeignKey +ALTER TABLE "members" ADD CONSTRAINT "members_id_foreign" FOREIGN KEY ("id") REFERENCES "users"("discord_id") ON DELETE NO ACTION ON UPDATE NO ACTION; + +-- AddForeignKey +ALTER TABLE "members" ADD CONSTRAINT "members_guildid_foreign" FOREIGN KEY ("guild_id") REFERENCES "discord_guilds"("id") ON DELETE NO ACTION ON UPDATE NO ACTION;