Skip to content

Commit 8614f35

Browse files
authored
Add files via upload
0 parents  commit 8614f35

18 files changed

+379
-0
lines changed

README.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
# or
12+
pnpm dev
13+
# or
14+
bun dev
15+
```
16+
17+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18+
19+
You can start editing the page by modifying `app/page.js`. The page auto-updates as you edit the file.
20+
21+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
22+
23+
## Learn More
24+
25+
To learn more about Next.js, take a look at the following resources:
26+
27+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29+
30+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
31+
32+
## Deploy on Vercel
33+
34+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35+
36+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.

app/api/users/[userId]/route.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { NextResponse } from 'next/server';
2+
3+
export async function GET(request, { params }) {
4+
const userId = params.userId;
5+
6+
try {
7+
const botResponse = await fetch(`http://localhost:3002/users/${userId}`);
8+
9+
if (!botResponse.ok) {
10+
const errorData = await botResponse.json();
11+
throw new Error(errorData.error || `hata: ${botResponse.status}`);
12+
}
13+
14+
const userData = await botResponse.json();
15+
return NextResponse.json(userData);
16+
17+
} catch (error) {
18+
console.error(error);
19+
return new NextResponse(error.message || 'hata', { status: 500 });
20+
}
21+
}

app/favicon.ico

25.3 KB
Binary file not shown.

app/globals.css

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
4+
5+
:root {
6+
--background: #ffffff;
7+
--foreground: #171717;
8+
}
9+
10+
@media (prefers-color-scheme: dark) {
11+
:root {
12+
--background: #0a0a0a;
13+
--foreground: #ededed;
14+
}
15+
}
16+
17+
body {
18+
color: var(--foreground);
19+
background: var(--background);
20+
font-family: Arial, Helvetica, sans-serif;
21+
}

app/layout.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { Geist, Geist_Mono } from "next/font/google";
2+
import "./globals.css";
3+
4+
const geistSans = Geist({
5+
variable: "--font-geist-sans",
6+
subsets: ["latin"],
7+
});
8+
9+
const geistMono = Geist_Mono({
10+
variable: "--font-geist-mono",
11+
subsets: ["latin"],
12+
});
13+
14+
export const metadata = {
15+
title: "Create Next App",
16+
description: "Generated by create next app",
17+
};
18+
19+
export default function RootLayout({ children }) {
20+
return (
21+
<html lang="en">
22+
<body
23+
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
24+
>
25+
{children}
26+
</body>
27+
</html>
28+
);
29+
}

app/page.js

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import Image from "next/image";
2+
3+
export default function Home() {
4+
return (
5+
<div className="grid grid-rows-[20px_1fr_20px] items-center justify-items-center min-h-screen p-8 pb-20 gap-16 sm:p-20 font-[family-name:var(--font-geist-sans)]">
6+
<main className="flex flex-col gap-8 row-start-2 items-center sm:items-start">
7+
<Image
8+
className="dark:invert"
9+
src="/next.svg"
10+
alt="Next.js logo"
11+
width={180}
12+
height={38}
13+
priority
14+
/>
15+
<ol className="list-inside list-decimal text-sm text-center sm:text-left font-[family-name:var(--font-geist-mono)]">
16+
<li className="mb-2">
17+
Get started by editing{" "}
18+
<code className="bg-black/[.05] dark:bg-white/[.06] px-1 py-0.5 rounded font-semibold">
19+
app/page.js
20+
</code>
21+
.
22+
</li>
23+
<li>Save and see your changes instantly.</li>
24+
</ol>
25+
26+
<div className="flex gap-4 items-center flex-col sm:flex-row">
27+
<a
28+
className="rounded-full border border-solid border-transparent transition-colors flex items-center justify-center bg-foreground text-background gap-2 hover:bg-[#383838] dark:hover:bg-[#ccc] text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5"
29+
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
30+
target="_blank"
31+
rel="noopener noreferrer"
32+
>
33+
<Image
34+
className="dark:invert"
35+
src="/vercel.svg"
36+
alt="Vercel logomark"
37+
width={20}
38+
height={20}
39+
/>
40+
Deploy now
41+
</a>
42+
<a
43+
className="rounded-full border border-solid border-black/[.08] dark:border-white/[.145] transition-colors flex items-center justify-center hover:bg-[#f2f2f2] dark:hover:bg-[#1a1a1a] hover:border-transparent text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5 sm:min-w-44"
44+
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
45+
target="_blank"
46+
rel="noopener noreferrer"
47+
>
48+
Read our docs
49+
</a>
50+
</div>
51+
</main>
52+
<footer className="row-start-3 flex gap-6 flex-wrap items-center justify-center">
53+
<a
54+
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
55+
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
56+
target="_blank"
57+
rel="noopener noreferrer"
58+
>
59+
<Image
60+
aria-hidden
61+
src="/file.svg"
62+
alt="File icon"
63+
width={16}
64+
height={16}
65+
/>
66+
Learn
67+
</a>
68+
<a
69+
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
70+
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
71+
target="_blank"
72+
rel="noopener noreferrer"
73+
>
74+
<Image
75+
aria-hidden
76+
src="/window.svg"
77+
alt="Window icon"
78+
width={16}
79+
height={16}
80+
/>
81+
Examples
82+
</a>
83+
<a
84+
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
85+
href="https://nextjs.org?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
86+
target="_blank"
87+
rel="noopener noreferrer"
88+
>
89+
<Image
90+
aria-hidden
91+
src="/globe.svg"
92+
alt="Globe icon"
93+
width={16}
94+
height={16}
95+
/>
96+
Go to nextjs.org →
97+
</a>
98+
</footer>
99+
</div>
100+
);
101+
}

bot.js

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
const express = require('express');
2+
const { Client, GatewayIntentBits, Events, Partials } = require('discord.js');
3+
4+
const app = express();
5+
const port = 3002;
6+
7+
const client = new Client({
8+
intents: [
9+
GatewayIntentBits.Guilds,
10+
GatewayIntentBits.GuildMembers,
11+
GatewayIntentBits.MessageContent,
12+
GatewayIntentBits.GuildPresences
13+
],
14+
partials: [Partials.User, Partials.GuildMember, Partials.Channel]
15+
});
16+
17+
client.on(Events.ClientReady, () => {
18+
console.log(`${client.user.tag} adıyla giriş yapıldı!`);
19+
});
20+
21+
app.get('/users/:userId', async (req, res) => {
22+
const userId = req.params.userId;
23+
24+
try {
25+
const guild = client.guilds.cache.get("1336412155137888266");
26+
27+
if (!guild) {
28+
return res.status(500).json({ error: 'Kullanıcı sunucuda bulunmamakta, lütfen discord.gg/setscript adresine giriş yapınız.' });
29+
}
30+
31+
const member = await guild.members.fetch(userId);
32+
33+
if (!member) {
34+
return res.status(404).json({ error: 'Kullanıcı sunucuda bulunmamakta, lütfen discord.gg/setscript adresine giriş yapınız.' });
35+
}
36+
37+
const user = member.user;
38+
const presence = member.presence;
39+
40+
const activities = presence?.activities || [];
41+
42+
const spotifyActivity = activities.find(activity => activity.name === 'Spotify' && activity.type === 2);
43+
44+
res.json({
45+
user: {
46+
id: user.id,
47+
username: user.username,
48+
tag: user.tag,
49+
avatarURL: user.displayAvatarURL(),
50+
},
51+
presence: {
52+
status: presence?.status || "Bilinmiyor",
53+
clientStatus: presence?.clientStatus || "Bilinmiyor",
54+
},
55+
spotify: spotifyActivity ? {
56+
title: spotifyActivity.details,
57+
artist: spotifyActivity.state,
58+
albumArtURL: spotifyActivity.assets?.large_image_url,
59+
} : "Spotify bilgisi bulunamadı",
60+
activities: activities.length > 0 ? activities.map(activity => ({
61+
name: activity.name,
62+
type: activity.type,
63+
details: activity.details,
64+
state: activity.state,
65+
})) : "Durum bilgisi bulunamadı",
66+
});
67+
68+
} catch (error) {
69+
console.error("Hata:", error);
70+
if (error.code === 10013) {
71+
res.status(404).json({ error: 'Kullanıcı sunucuda bulunmamakta, lütfen discord.gg/setscript adresine giriş yapınız.' });
72+
} else {
73+
res.status(500).json({ error: 'Kullanıcı sunucuda bulunmamakta, lütfen discord.gg/setscript adresine giriş yapınız.' });
74+
}
75+
}
76+
});
77+
78+
79+
client.login("");
80+
81+
app.listen(port, () => {
82+
console.log(`API sunucusu ${port} portunda çalışıyor`);
83+
});

eslint.config.mjs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { dirname } from "path";
2+
import { fileURLToPath } from "url";
3+
import { FlatCompat } from "@eslint/eslintrc";
4+
5+
const __filename = fileURLToPath(import.meta.url);
6+
const __dirname = dirname(__filename);
7+
8+
const compat = new FlatCompat({
9+
baseDirectory: __dirname,
10+
});
11+
12+
const eslintConfig = [...compat.extends("next/core-web-vitals")];
13+
14+
export default eslintConfig;

jsconfig.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"compilerOptions": {
3+
"paths": {
4+
"@/*": ["./*"]
5+
}
6+
}
7+
}

next.config.mjs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/** @type {import('next').NextConfig} */
2+
const nextConfig = {};
3+
4+
export default nextConfig;

package.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "discord-presence-api-website",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "concurrently \"node bot.js\" \"next dev --turbopack\"",
7+
"build": "next build",
8+
"start": "next start",
9+
"lint": "next lint"
10+
},
11+
"dependencies": {
12+
"concurrently": "^9.1.2",
13+
"discord.js": "^14.17.3",
14+
"dotenv": "^16.4.7",
15+
"express": "^4.21.2",
16+
"next": "15.1.6",
17+
"node-fetch": "^3.3.2",
18+
"react": "^19.0.0",
19+
"react-dom": "^19.0.0"
20+
},
21+
"devDependencies": {
22+
"@eslint/eslintrc": "^3",
23+
"eslint": "^9",
24+
"eslint-config-next": "15.1.6",
25+
"postcss": "^8",
26+
"tailwindcss": "^3.4.1"
27+
},
28+
"description": "This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).",
29+
"main": "bot.js",
30+
"keywords": [],
31+
"author": "",
32+
"license": "ISC"
33+
}

postcss.config.mjs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** @type {import('postcss-load-config').Config} */
2+
const config = {
3+
plugins: {
4+
tailwindcss: {},
5+
},
6+
};
7+
8+
export default config;

public/file.svg

+1
Loading

public/globe.svg

+1
Loading

public/next.svg

+1
Loading

public/vercel.svg

+1
Loading

public/window.svg

+1
Loading

0 commit comments

Comments
 (0)