Skip to content

Commit

Permalink
feat: new stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
maamokun committed Jun 25, 2024
1 parent fe9a04a commit 96de5d9
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 3 deletions.
10 changes: 10 additions & 0 deletions prisma/migrations/20240625124929_mew4/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
Warnings:
- Added the required column `levelsEnabled` to the `server` table without a default value. This is not possible if the table is not empty.
- Added the required column `levelsMessage` to the `server` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "server" ADD COLUMN "levelsEnabled" BOOLEAN NOT NULL,
ADD COLUMN "levelsMessage" TEXT NOT NULL;
3 changes: 3 additions & 0 deletions prisma/migrations/20240625125401_new5/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE "guildLvl" ALTER COLUMN "level" SET DATA TYPE TEXT,
ALTER COLUMN "xp" SET DATA TYPE TEXT;
6 changes: 4 additions & 2 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ model User {

model guildLvl {
id String @id
level Int
xp Int
level String
xp String
}

model server {
Expand All @@ -40,4 +40,6 @@ model server {
autoRoleChannel String
verificationRole String
verificationChannel String
levelsEnabled Boolean
levelsMessage String
}
23 changes: 23 additions & 0 deletions src/handlers/initGuild.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { PrismaClient } from "@prisma/client";
import { type Guild, ChannelType, GuildChannel, Options } from "discord.js";

const prisma = new PrismaClient();

export async function initGuild(guild: Guild) {
const guildDb = await prisma.server.findUnique({
where: {
id: guild.id,
},
});

if (!guildDb) {
await prisma.server.create({
data: {
id: guild.id,
},
});
}

const channel = await guild.channels.create({ name: "bot-commands", type: ChannelType.GuildText });
const id = channel.id;
}
29 changes: 28 additions & 1 deletion src/handlers/lvl.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
import { PrismaClient } from "@prisma/client";
import type { Message } from "discord.js";

const prisma = new PrismaClient();
const prisma = new PrismaClient();
const messageLimit = new Map();

export async function handleLevel(message: Message) {
const lvlDB = prisma.guildLvl.findUnique({
where: {
id: `${message.guild?.id}-${message.author.id}`,
},
});

if (!lvlDB) {
await prisma.guildLvl.create({
data: {
id: `${message.guild?.id}-${message.author.id}`,
xp: "0",
level: "0",
},
});
}

//@ts-ignore
const xp = lvlDB?.xp;
//@ts-ignore
const lvl = lvlDB?.level;


}
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,11 @@ client.on("interactionCreate", async (interaction) => {
client.on("messageCreate", async (message) => {
if (message.author.bot) return;

});

client.on("guildCreate", async (guild) => {

});


client.login(process.env.BOT_TOKEN);

0 comments on commit 96de5d9

Please sign in to comment.