generated from Baipyrus/DiscordJS-Template
isolate DiscordJS
This commit is contained in:
parent
7d1b869b86
commit
d3cd5f6945
0
discord-bot/.gitignore
vendored
0
discord-bot/.gitignore
vendored
@ -1,3 +0,0 @@
|
||||
# Private
|
||||
TEMP_FOLDER_LOCATION=
|
||||
CONFIG_FOLDER_LOCATION=
|
@ -1,13 +0,0 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
/build
|
||||
/.svelte-kit
|
||||
/package
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
|
||||
# Ignore files for PNPM, NPM and YARN
|
||||
pnpm-lock.yaml
|
||||
package-lock.json
|
||||
yarn.lock
|
@ -1,15 +0,0 @@
|
||||
/** @type { import("eslint").Linter.FlatConfig } */
|
||||
module.exports = {
|
||||
root: true,
|
||||
extends: ['eslint:recommended', 'plugin:svelte/recommended', 'prettier'],
|
||||
parserOptions: {
|
||||
sourceType: 'module',
|
||||
ecmaVersion: 2020,
|
||||
extraFileExtensions: ['.svelte']
|
||||
},
|
||||
env: {
|
||||
browser: true,
|
||||
es2017: true,
|
||||
node: true
|
||||
}
|
||||
};
|
9
website/.gitignore
vendored
9
website/.gitignore
vendored
@ -1,9 +0,0 @@
|
||||
/build
|
||||
/.svelte-kit
|
||||
/package
|
||||
vite.config.js.timestamp-*
|
||||
vite.config.ts.timestamp-*
|
||||
|
||||
temp
|
||||
config
|
||||
backend_files
|
@ -1 +0,0 @@
|
||||
engine-strict=true
|
@ -1,13 +0,0 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
/build
|
||||
/.svelte-kit
|
||||
/package
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
|
||||
# Ignore files for PNPM, NPM and YARN
|
||||
pnpm-lock.yaml
|
||||
package-lock.json
|
||||
yarn.lock
|
@ -1,8 +0,0 @@
|
||||
{
|
||||
"useTabs": true,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"printWidth": 100,
|
||||
"plugins": ["prettier-plugin-svelte"],
|
||||
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
|
||||
}
|
@ -1 +0,0 @@
|
||||
# L Pa So
|
3019
website/package-lock.json
generated
3019
website/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,27 +0,0 @@
|
||||
{
|
||||
"name": "website",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"lint": "prettier --check . && eslint .",
|
||||
"format": "prettier --write ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/adapter-auto": "^2.0.0",
|
||||
"@sveltejs/kit": "^1.27.4",
|
||||
"eslint": "^8.28.0",
|
||||
"eslint-config-prettier": "^9.0.0",
|
||||
"eslint-plugin-svelte": "^2.30.0",
|
||||
"prettier": "^3.0.0",
|
||||
"prettier-plugin-svelte": "^3.0.0",
|
||||
"svelte": "^4.2.7",
|
||||
"vite": "^4.4.2"
|
||||
},
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"gamedig": "^4.3.0"
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
<div style="display: contents">%sveltekit.body%</div>
|
||||
</body>
|
||||
</html>
|
@ -1,7 +0,0 @@
|
||||
import { getAllServer } from '$lib/server/scripts/refreshGameservers.js';
|
||||
|
||||
getAllServer();
|
||||
|
||||
setInterval(() => {
|
||||
getAllServer();
|
||||
}, 3000);
|
@ -1,16 +0,0 @@
|
||||
<script>
|
||||
import {onMount} from "svelte";
|
||||
|
||||
let data = {};
|
||||
onMount(async () => {
|
||||
const response = await fetch('/api/read-tournament');
|
||||
data = await response.json();
|
||||
});
|
||||
</script>
|
||||
|
||||
<h2>Aktuelles Tunier</h2>
|
||||
<h3>Diese Spiele werden Gespielt:</h3>
|
||||
<p>{data.games}</p>
|
||||
|
||||
<h3>Die Teilnehmer lauten: </h3>
|
||||
<p>{data.player}</p>
|
@ -1,28 +0,0 @@
|
||||
<script>
|
||||
import { browser } from '$app/environment';
|
||||
|
||||
import ServerlistItem from './ServerlistItem.svelte';
|
||||
|
||||
const allServers = async () => {
|
||||
if (browser) {
|
||||
const response = await fetch('/api/serverlist');
|
||||
const data = await response.json();
|
||||
return data;
|
||||
}
|
||||
return [];
|
||||
};
|
||||
let promise = allServers();
|
||||
</script>
|
||||
|
||||
<h1>Lokale Serverliste</h1>
|
||||
<div>
|
||||
{#await promise}
|
||||
<p>Lade Daten...</p>
|
||||
{:then servers}
|
||||
{#each servers as serverdata}
|
||||
<ServerlistItem server={serverdata} />
|
||||
{/each}
|
||||
{:catch error}
|
||||
<p>Laden der Daten war nicht möglich!</p>
|
||||
{/await}
|
||||
</div>
|
@ -1,22 +0,0 @@
|
||||
<script>
|
||||
export let server;
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{server.game}</td>
|
||||
<td>{server.name}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{server.playerCount.current}/{server.playerCount.max}</td>
|
||||
<td>{server.status}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{server.ip}</td>
|
||||
<td>{server.link}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
@ -1,68 +0,0 @@
|
||||
import Gamedig from 'gamedig';
|
||||
import fs from 'fs';
|
||||
|
||||
import { TEMP_FOLDER_LOCATION, CONFIG_FOLDER_LOCATION } from '$env/static/private';
|
||||
|
||||
export const getAllServer = async () => {
|
||||
if (!fs.existsSync(TEMP_FOLDER_LOCATION)) fs.mkdirSync(TEMP_FOLDER_LOCATION, { recursive: true });
|
||||
|
||||
if (!fs.existsSync(CONFIG_FOLDER_LOCATION))
|
||||
fs.mkdirSync(CONFIG_FOLDER_LOCATION, { recursive: true });
|
||||
|
||||
if (!fs.existsSync(CONFIG_FOLDER_LOCATION + 'gameserverlist.json')) return [];
|
||||
|
||||
const serverList = JSON.parse(fs.readFileSync(CONFIG_FOLDER_LOCATION + 'gameserverlist.json'));
|
||||
|
||||
let parsedResults = [];
|
||||
|
||||
for (const server of serverList) {
|
||||
let status = true;
|
||||
let serverResponse;
|
||||
try {
|
||||
serverResponse = await Gamedig.query({
|
||||
type: server.type,
|
||||
host: server.ip,
|
||||
port: server.port
|
||||
});
|
||||
} catch (error) {
|
||||
status = false;
|
||||
}
|
||||
|
||||
let parsedResult;
|
||||
if (status) {
|
||||
parsedResult = {
|
||||
game: server.type,
|
||||
name: serverResponse.name,
|
||||
playerCount: {
|
||||
current: serverResponse.players.length,
|
||||
max: serverResponse.maxplayers
|
||||
},
|
||||
status: status,
|
||||
ip: server.ip,
|
||||
link: ''
|
||||
};
|
||||
} else {
|
||||
parsedResult = {
|
||||
game: server.type,
|
||||
name: server.name,
|
||||
playerCount: {
|
||||
current: 0,
|
||||
max: 0
|
||||
},
|
||||
status: status,
|
||||
ip: serverResponse.connect,
|
||||
link: server.link
|
||||
};
|
||||
}
|
||||
|
||||
parsedResults.push(parsedResult);
|
||||
}
|
||||
|
||||
fs.writeFile(
|
||||
TEMP_FOLDER_LOCATION + 'gameserverstatus.json',
|
||||
JSON.stringify(parsedResults),
|
||||
(err) => {
|
||||
if (err) throw err;
|
||||
}
|
||||
);
|
||||
};
|
@ -1,22 +0,0 @@
|
||||
<script>
|
||||
import Serverlist from '$lib/client/components/Serverlist.svelte'
|
||||
import CurrentTunier from "$lib/client/components/CurrentTunier.svelte";
|
||||
let year = new Date().getFullYear();
|
||||
</script>
|
||||
|
||||
<h1>Willkommen zur Weihnachtslan {year}</h1>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<h2>aktive Server</h2>
|
||||
<Serverlist />
|
||||
</td>
|
||||
<td>|</td>
|
||||
<td>-----</td>
|
||||
<td>|</td>
|
||||
<td>
|
||||
<h2>LAN Tunier</h2>
|
||||
<CurrentTunier />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
@ -1,9 +0,0 @@
|
||||
import { promises as fs } from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
export async function GET() {
|
||||
const filePath = path.resolve('static/tournament.json');
|
||||
const data = await fs.readFile(filePath, 'utf8');
|
||||
const json = JSON.parse(data);
|
||||
return Response.json(json)
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
import fs from 'fs';
|
||||
|
||||
import { TEMP_FOLDER_LOCATION } from '$env/static/private';
|
||||
|
||||
export async function GET() {
|
||||
if (!fs.existsSync(TEMP_FOLDER_LOCATION)) fs.mkdirSync(TEMP_FOLDER_LOCATION, { recursive: true });
|
||||
|
||||
if (!fs.existsSync(TEMP_FOLDER_LOCATION + 'gameserverstatus.json'))
|
||||
return new Response({ status: 404 });
|
||||
|
||||
const serverList = fs.readFileSync(TEMP_FOLDER_LOCATION + 'gameserverstatus.json');
|
||||
|
||||
return new Response(serverList, { status: 200 });
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
import { promises as fs } from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
export async function POST({ request }) {
|
||||
const data = await request.text();
|
||||
try {
|
||||
await fs.writeFile(path.resolve('static/tournament.json'), data);
|
||||
return new Response('Array wurde gespeichert.');
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
<script>
|
||||
import CurrentTunier from '$lib/client/components/CurrentTunier.svelte';
|
||||
</script>
|
||||
|
||||
<h1>Tunier</h1>
|
||||
|
||||
<CurrentTunier />
|
||||
|
||||
<button
|
||||
on:click={() => {
|
||||
location.replace('/tunier/neu');
|
||||
}}>Tunier erstellen</button
|
||||
>
|
@ -1,80 +0,0 @@
|
||||
<script>
|
||||
let gameCount = 1;
|
||||
let playerCount = 1;
|
||||
let games = [];
|
||||
let player = [];
|
||||
|
||||
function getGames() {
|
||||
games = [];
|
||||
const inputs = document.querySelectorAll('.Spiel');
|
||||
inputs.forEach((input) => {
|
||||
games.push(input.value);
|
||||
});
|
||||
return games;
|
||||
}
|
||||
function getPlayer() {
|
||||
player = [];
|
||||
const inputs = document.querySelectorAll('.Teilnehmer');
|
||||
inputs.forEach((input) => {
|
||||
player.push(input.value);
|
||||
});
|
||||
return player;
|
||||
}
|
||||
|
||||
function addGame() {
|
||||
gameCount++;
|
||||
}
|
||||
|
||||
function removeGame() {
|
||||
gameCount = gameCount > 1 ? gameCount - 1 : gameCount;
|
||||
}
|
||||
|
||||
function addPlayer() {
|
||||
playerCount++;
|
||||
}
|
||||
|
||||
function removePlayer() {
|
||||
playerCount = playerCount > 1 ? playerCount - 1 : playerCount;
|
||||
}
|
||||
|
||||
async function addTournament() {
|
||||
let gamelist = getGames();
|
||||
let playerlist = getPlayer();
|
||||
|
||||
const tournament = {
|
||||
games: gamelist,
|
||||
player: playerlist
|
||||
};
|
||||
const res = await fetch('/api/update-json/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(tournament)
|
||||
});
|
||||
if (res.ok) {
|
||||
console.log('JSON gespeichert');
|
||||
} else {
|
||||
console.error('JSON nicht gespeichert');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<h1>Ein neues Tunier erstellen</h1>
|
||||
<h2>Spiele hinzufügen</h2>
|
||||
<ul>
|
||||
{#each { length: gameCount } as _, i}
|
||||
<li>{i + 1}. <input class="Spiel" type="text" /></li>
|
||||
{/each}
|
||||
</ul>
|
||||
<button on:click={addGame}>noch ein Spiel hinzufügen</button>
|
||||
<button on:click={removeGame}>letztes Spiel entfernen</button>
|
||||
<h2>Teilnehmer hinzufügen</h2>
|
||||
<ul>
|
||||
{#each { length: playerCount } as _, i}
|
||||
<li>{i + 1}.<input required class="Teilnehmer" type="text" /></li>{/each}
|
||||
</ul>
|
||||
<button on:click={addPlayer}>noch ein Teilnehmer hinzufügen</button>
|
||||
<button on:click={removePlayer}>letzten Teilnehmer entfernen</button>
|
||||
<h2>Tunier anlegen</h2>
|
||||
<button on:click={addTournament}>Tunier anlegen</button>
|
Binary file not shown.
Before Width: | Height: | Size: 1.5 KiB |
@ -1,13 +0,0 @@
|
||||
import adapter from '@sveltejs/adapter-auto';
|
||||
|
||||
/** @type {import('@sveltejs/kit').Config} */
|
||||
const config = {
|
||||
kit: {
|
||||
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
|
||||
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
|
||||
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
|
||||
adapter: adapter()
|
||||
}
|
||||
};
|
||||
|
||||
export default config;
|
@ -1,6 +0,0 @@
|
||||
import { sveltekit } from '@sveltejs/kit/vite';
|
||||
import { defineConfig } from 'vite';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [sveltekit()]
|
||||
});
|
Loading…
Reference in New Issue
Block a user