Skip to content

Commit

Permalink
add: start of internal API
Browse files Browse the repository at this point in the history
  • Loading branch information
maamokun committed Aug 12, 2024
1 parent 96de5d9 commit dbdf88e
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 41 deletions.
Binary file modified bun.lockb
Binary file not shown.
1 change: 0 additions & 1 deletion index.ts

This file was deleted.

40 changes: 19 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
{
"name": "mikanbot-project",
"module": "index.ts",
"type": "module",
"scripts": {
"format": "biome format --write ."
},
"devDependencies": {
"@types/bun": "latest",
"prisma": "5.15.1"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"@biomejs/biome": "^1.8.2",
"@prisma/client": "^5.15.1",
"canvafy": "^7.1.0",
"discord.js": "^14.15.3",
"elysia": "^1.0.25",
"quick.db": "^9.1.7"
}
"name": "mikanbot-project",
"module": "index.ts",
"type": "module",
"scripts": {
"format": "biome format --write ."
},
"devDependencies": {
"@types/bun": "latest",
"prisma": "5.15.1"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"@biomejs/biome": "^1.8.2",
"@prisma/client": "^5.15.1",
"discord.js": "^14.15.3",
"elysia": "^1.1.5"
}
}
24 changes: 24 additions & 0 deletions src/api/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Elysia } from "elysia";

const app = new Elysia();

app.post("/accLink", async ({ query, body }) => {
const key = query.key
const json = body

const uid = json.uid
const acc = json.acc

if(!key) return { status: 400, message: "No key provided" }
if(!uid) return { status: 400, message: "No uid provided" }
if(!acc) return { status: 400, message: "No acc provided" }

if(key !== process.env.API_SIGNING_KEY) return { status: 401, message: "Invalid key" }

})

export function start () {
app.listen(process.env.API_PORT || 3000, () => {
console.log(`Server started on port ${process.env.API_PORT || 3000}`)
})
}
7 changes: 5 additions & 2 deletions src/handlers/initGuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export async function initGuild(guild: Guild) {
});
}

const channel = await guild.channels.create({ name: "bot-commands", type: ChannelType.GuildText });
const channel = await guild.channels.create({
name: "bot-commands",
type: ChannelType.GuildText,
});
const id = channel.id;
}
}
4 changes: 1 addition & 3 deletions src/handlers/lvl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,4 @@ export async function handleLevel(message: Message) {
const xp = lvlDB?.xp;
//@ts-ignore
const lvl = lvlDB?.level;


}
}
7 changes: 3 additions & 4 deletions src/handlers/ratelimit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ const { QuickDB, MemoryDriver } = require("quick.db");
const memoryDriver = new MemoryDriver();
const db = new QuickDB({ driver: memoryDriver });

export default function setRatelimit (type, time, user) {
if(type == "msg") {

export default function setRatelimit(type, time, user) {
if (type == "msg") {
}
}
}
15 changes: 5 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { start } from "./api/server";
import { deployCommands } from "./deploy";
import { setPresence } from "./presence";
import { handleCommand } from "./handlers/command";
import { Client, GatewayIntentBits } from "discord.js";
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.MessageContent,
],
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.DirectMessages, GatewayIntentBits.GuildMessages],
});

client.on("ready", () => {
Expand All @@ -24,12 +21,10 @@ client.on("interactionCreate", async (interaction) => {

client.on("messageCreate", async (message) => {
if (message.author.bot) return;

});

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

console.log("Received message!");
});

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

client.login(process.env.BOT_TOKEN);
start();

0 comments on commit dbdf88e

Please sign in to comment.