Compare commits

...

3 Commits

Author SHA1 Message Date
d52431ffb5 Initialized discord bot version 2
Some checks failed
Build and Deploy / Deploy Web (push) Failing after 1s
Build and Deploy / Deploy Discord Bot (push) Failing after 1s
2023-06-27 19:38:28 +02:00
f5d9aefc0f removed modpack 2023-06-26 15:16:57 +02:00
7678a44945 feat: Added logout function 2023-06-26 15:16:24 +02:00
36 changed files with 4067 additions and 374 deletions

2
discordbot/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.env
node_modules

3833
discordbot/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

22
discordbot/package.json Normal file
View File

@ -0,0 +1,22 @@
{
"name": "discordbot",
"version": "1.0.0",
"description": "",
"main": "index.ts",
"scripts": {
"dev": "tsx watch src/index.ts",
"start": "node dist/index.js",
"build": "tsup src/index.ts --minify"
},
"author": "",
"license": "ISC",
"dependencies": {
"discord.js": "^14.11.0",
"dotenv": "^16.3.1"
},
"devDependencies": {
"tsup": "^7.1.0",
"tsx": "^3.12.7",
"typescript": "^5.1.3"
}
}

View File

@ -0,0 +1,10 @@
import { CommandInteraction, SlashCommandBuilder, Client } from "discord.js";
export const data = new SlashCommandBuilder()
.setName("ping")
.setDescription("Replies with Pong!");
export async function execute({ interaction, client, createEmbed }: { interaction: CommandInteraction, client: Client, createEmbed: Function }) {
const reply = await interaction.reply({ embeds: [createEmbed(`Websocket heartbeat: **${client.ws.ping}ms**\n Roundtrip latency: **Pinging...**`)], fetchReply: true, ephemeral: true });
interaction.editReply({ embeds: [createEmbed(`Websocket heartbeat: **${client.ws.ping}ms**\n Roundtrip latency: **${reply.createdTimestamp - interaction.createdTimestamp}ms**`)] });
}

20
discordbot/src/config.ts Normal file
View File

@ -0,0 +1,20 @@
import { ColorResolvable } from "discord.js";
import dotenv from "dotenv";
dotenv.config();
const { DISCORD_TOKEN, DISCORD_CLIENT_ID, DISCORD_GUILD_ID } = process.env;
if (!DISCORD_TOKEN || !DISCORD_CLIENT_ID) {
throw new Error("Missing environment variables");
}
const EMBED_COLOR: ColorResolvable = '#0080ff'
export const config = {
DISCORD_TOKEN,
DISCORD_CLIENT_ID,
DISCORD_GUILD_ID,
EMBED_COLOR
};

View File

@ -0,0 +1,23 @@
import { Events, Client, BaseInteraction } from 'discord.js'
export const name = Events.InteractionCreate
export const execute = async ({ client, createEmbed }: { client: Client, createEmbed: Function }, interaction: BaseInteraction) => {
if (interaction.isChatInputCommand()) {
const command = interaction.client.commands.get(interaction.commandName);
if (!command) {
return console.error(`No command matching ${interaction.commandName} was found`);
} else {
console.info(`${interaction.user.username} executed command ${interaction.commandName}`);
}
try {
await command.execute({ interaction, client, createEmbed });
} catch (error) {
console.error(error);
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
}
}

View File

@ -0,0 +1,12 @@
import { Events, Client } from 'discord.js'
import registerCommands from '../registerCommands'
export const name = Events.ClientReady
export const once = true
export const execute = async ({ client }: { client: Client }) => {
console.log(`Ready! Logged in as ${client.user.tag}`)
registerCommands()
}

45
discordbot/src/index.ts Normal file
View File

@ -0,0 +1,45 @@
import { Client, GatewayIntentBits, Collection, EmbedBuilder } from 'discord.js'
import fs from 'node:fs'
import path from 'node:path'
import { config } from './config'
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]
})
const createEmbed = (description: string) => {
return new EmbedBuilder()
.setColor(config.EMBED_COLOR)
.setDescription(description);
};
client.commands = new Collection()
const commandsPath = path.join(__dirname, 'commands');
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.ts'));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
} else {
console.error(`The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
const eventsPath = path.join(__dirname, 'events');
const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.ts'));
for (const file of eventFiles) {
const filePath = path.join(eventsPath, file);
const event = require(filePath);
if (event.once) {
client.once(event.name, (...args) => event.execute({ client, createEmbed }, ...args));
} else {
client.on(event.name, (...args) => event.execute({ client, createEmbed }, ...args));
}
}
client.login(config.DISCORD_TOKEN);

View File

@ -0,0 +1,54 @@
import fs from 'node:fs'
import path from 'node:path'
import { REST, Routes } from 'discord.js'
import { config } from './config'
type Command = {
data: any
}
export default async () => {
const commands = []
const commandsPath = path.join(__dirname, 'commands')
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('ts'))
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file)
const command = await import(filePath) as Command
if ('data' in command && 'execute' in command) {
commands.push(command.data.toJSON())
} else {
console.error(`The command at ${filePath} is missing a required "data" or "execute" property`)
}
}
const rest = new REST().setToken(config.DISCORD_TOKEN)
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);
// The put method is used to fully refresh all commands in the guild with the current set
if (config.DISCORD_GUILD_ID) {
const data: any = await rest.put(
Routes.applicationGuildCommands(config.DISCORD_CLIENT_ID, config.DISCORD_GUILD_ID),
{ body: commands },
);
console.log(`Successfully reloaded ${data.length} guild (/) commands.`);
} else {
const data: any = await rest.put(
Routes.applicationCommands(config.DISCORD_CLIENT_ID),
{ body: commands },
);
console.log(`Successfully reloaded ${data.length} global (/) commands.`);
}
} catch (error) {
// And of course, make sure you catch and log any errors!
console.error(error);
}
}

15
discordbot/tsconfig.json Normal file
View File

@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"rootDir": "./src",
"outDir": "./dist",
"removeComments": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"strictNullChecks": true,
"skipLibCheck": true
}
}

7
discordbot/types.d.ts vendored Normal file
View File

@ -0,0 +1,7 @@
import { Collection } from 'discord.js'
declare module 'discord.js' {
export interface Client {
commands: Collection<unknown, any>
}
}

View File

@ -1,101 +0,0 @@
hash-format = "sha256"
[[files]]
file = "mods/alternate-current.pw.toml"
hash = "fda319290cfe268fdc7c6c6ca8dcad24e51c1de98442f23f2a41d657b26fc8d0"
metafile = true
[[files]]
file = "mods/anti-xray.pw.toml"
hash = "d8833b2961beb076df826ac3a34634260fa9828923a9a327da882065fa3b2f84"
metafile = true
[[files]]
file = "mods/banhammer.pw.toml"
hash = "40a4d80590660eadaa6002f006f0738136fa35583686ea1fb163f98c63d72bac"
metafile = true
[[files]]
file = "mods/debugify.pw.toml"
hash = "d02024521821336e40652c36c675ee520b4137ed73953e98f21bcf8a55f6a583"
metafile = true
[[files]]
file = "mods/fabric-api.pw.toml"
hash = "e87a52fb14288a8c503c76a40a18fb901de532b2805e84799c63d6202b3ce037"
metafile = true
[[files]]
file = "mods/fabric-language-kotlin.pw.toml"
hash = "0fe83c99b29c952f464c7bfba9cc86cc4f834bef7834821433fe23ce3dd230e6"
metafile = true
[[files]]
file = "mods/fastload.pw.toml"
hash = "9ab7092cb7e27bec8bb02d195e8f0c6a207b3f1383da7179a57ebd3328778a24"
metafile = true
[[files]]
file = "mods/ferrite-core.pw.toml"
hash = "4c1b893d87c51588985c483fe33193ca03cf3673de998eef6eeb850d8928e7ab"
metafile = true
[[files]]
file = "mods/headindex.pw.toml"
hash = "48e4d5004d63bf599c62daf73c36f7bfaccd770c7cc8645c2d03e5cddede167d"
metafile = true
[[files]]
file = "mods/invview.pw.toml"
hash = "fc6c71feb98476fa7cc0c683a52993bc751772171372fde95b0d823da0c6a2b7"
metafile = true
[[files]]
file = "mods/ledger.pw.toml"
hash = "badf7e1fb371f1cdac13ce547794339a58c64d87793ce4d5bf4151f99d5e2e00"
metafile = true
[[files]]
file = "mods/lithium.pw.toml"
hash = "feaedf6b6d73530c0289d9c7aa4149823343d2a7f9893f7b81e8c7c003763f31"
metafile = true
[[files]]
file = "mods/memoryleakfix.pw.toml"
hash = "5b43c0fc6904ad4480c8ed596411c6e24172f8320ccd63de97b4ce2e7e0f90a5"
metafile = true
[[files]]
file = "mods/no-chat-reports.pw.toml"
hash = "df11b66e152011f96cc5a4dbf35d2dec99c4373cb19a8c1c761368170d425cf4"
metafile = true
[[files]]
file = "mods/smoothboot-fabric.pw.toml"
hash = "971e8b0bef16bd6ce88c7f940b30fdc1debff7b715058f4d331d54beb58a4314"
metafile = true
[[files]]
file = "mods/spark.pw.toml"
hash = "9f7ce104c709103550148f4ff79acd17f9f93901224166445de1052b681c09da"
metafile = true
[[files]]
file = "mods/styled-chat.pw.toml"
hash = "1555d923f1277dfd8c1c55bf1ad8fa109718b717ee2f528fdaa80978e25e74e3"
metafile = true
[[files]]
file = "mods/styledplayerlist.pw.toml"
hash = "77b0faa9fdcbaf2d0b11358b34a659fd99e00dd5a7f150e0ad69a38259df81a7"
metafile = true
[[files]]
file = "mods/thorium.pw.toml"
hash = "61e2a941621007c901c96fe1474b3c07f208712fa6130151771d5235b6cc8adb"
metafile = true
[[files]]
file = "mods/yacl.pw.toml"
hash = "c66028d555a347562589645179fe8834bd04d48b78c9a667f20b4178211dfbb3"
metafile = true

View File

@ -1,13 +0,0 @@
name = "Alternate Current"
filename = "alternate-current-mc1.19-1.4.0.jar"
side = "server"
[download]
url = "https://cdn.modrinth.com/data/r0v8vy1s/versions/mc1.19-1.4.0/alternate-current-mc1.19-1.4.0.jar"
hash-format = "sha1"
hash = "108344ed05830948e6ab1414efa4f7ab34e6dba9"
[update]
[update.modrinth]
mod-id = "r0v8vy1s"
version = "4QElEqe4"

View File

@ -1,13 +0,0 @@
name = "AntiXray"
filename = "anti-xray-1.3.0-Fabric-1.19.3.jar"
side = "server"
[download]
url = "https://cdn.modrinth.com/data/sml2FMaA/versions/WPaK6kfx/anti-xray-1.3.0-Fabric-1.19.3.jar"
hash-format = "sha1"
hash = "a7cdba2fd9a2801cba56e74bedf6c6ee63a461a1"
[update]
[update.modrinth]
mod-id = "sml2FMaA"
version = "WPaK6kfx"

View File

@ -1,13 +0,0 @@
name = "BanHammer"
filename = "banhammer-0.6.3+1.19.3.jar"
side = "server"
[download]
url = "https://cdn.modrinth.com/data/Wpqg0ciI/versions/LFwC8Fix/banhammer-0.6.3%2B1.19.3.jar"
hash-format = "sha1"
hash = "8c2bcb4aa5b8aeec6066d96f5675225cb625820a"
[update]
[update.modrinth]
mod-id = "Wpqg0ciI"
version = "LFwC8Fix"

View File

@ -1,13 +0,0 @@
name = "Debugify"
filename = "Debugify-1.19.3+1.1.jar"
side = "both"
[download]
url = "https://cdn.modrinth.com/data/QwxR6Gcd/versions/fgjgGIfI/Debugify-1.19.3%2B1.1.jar"
hash-format = "sha1"
hash = "d7f9cbf11bb36ef360de2b898a5a5e224eaef9e3"
[update]
[update.modrinth]
mod-id = "QwxR6Gcd"
version = "fgjgGIfI"

View File

@ -1,13 +0,0 @@
name = "Fabric API"
filename = "fabric-api-0.74.0+1.19.3.jar"
side = "both"
[download]
url = "https://cdn.modrinth.com/data/P7dR8mSH/versions/1ld37x4U/fabric-api-0.74.0%2B1.19.3.jar"
hash-format = "sha1"
hash = "119d1710004834d83f34d2b8519aebedba981979"
[update]
[update.modrinth]
mod-id = "P7dR8mSH"
version = "1ld37x4U"

View File

@ -1,13 +0,0 @@
name = "Fabric Language Kotlin"
filename = "fabric-language-kotlin-1.9.1+kotlin.1.8.10.jar"
side = "both"
[download]
url = "https://cdn.modrinth.com/data/Ha28R6CL/versions/lgFl3olb/fabric-language-kotlin-1.9.1%2Bkotlin.1.8.10.jar"
hash-format = "sha1"
hash = "12f265ea91e73ac2c74c6f66d446671122bbb1c8"
[update]
[update.modrinth]
mod-id = "Ha28R6CL"
version = "lgFl3olb"

View File

@ -1,13 +0,0 @@
name = "Fastload"
filename = "Fastload+1.19.3-2.6.11.jar"
side = "both"
[download]
url = "https://cdn.modrinth.com/data/kCpssoSb/versions/GCH0zDV1/Fastload%2B1.19.3-2.6.11.jar"
hash-format = "sha1"
hash = "a796a3d17378e943a45caf576e9749aaa157d174"
[update]
[update.modrinth]
mod-id = "kCpssoSb"
version = "GCH0zDV1"

View File

@ -1,13 +0,0 @@
name = "FerriteCore"
filename = "ferritecore-5.1.0-fabric.jar"
side = "both"
[download]
url = "https://cdn.modrinth.com/data/uXXizFIs/versions/GHcKib6J/ferritecore-5.1.0-fabric.jar"
hash-format = "sha1"
hash = "4c45e0e8981374d6c98304c3de90e813eb930673"
[update]
[update.modrinth]
mod-id = "uXXizFIs"
version = "GHcKib6J"

View File

@ -1,13 +0,0 @@
name = "Head Index"
filename = "headindex-1.1.1.jar"
side = "both"
[download]
url = "https://cdn.modrinth.com/data/mEPmyd7J/versions/smDwseAG/headindex-1.1.1.jar"
hash-format = "sha1"
hash = "0f6ed3d568acd55fcdb4814bdfb4256031254fac"
[update]
[update.modrinth]
mod-id = "mEPmyd7J"
version = "smDwseAG"

View File

@ -1,13 +0,0 @@
name = "Inv View"
filename = "InvView-1.4.10-1.19.3+.jar"
side = "both"
[download]
url = "https://cdn.modrinth.com/data/jrDKjZP7/versions/rv8bhw5X/InvView-1.4.10-1.19.3%2B.jar"
hash-format = "sha1"
hash = "99dd21d6aab9c65d9b1135bce9c912e6bfd48feb"
[update]
[update.modrinth]
mod-id = "jrDKjZP7"
version = "rv8bhw5X"

View File

@ -1,13 +0,0 @@
name = "Ledger"
filename = "ledger-1.2.6.jar"
side = "server"
[download]
url = "https://cdn.modrinth.com/data/LVN9ygNV/versions/ykSbFGkA/ledger-1.2.6.jar"
hash-format = "sha1"
hash = "636857df039d3cec623843844abb72c670590d61"
[update]
[update.modrinth]
mod-id = "LVN9ygNV"
version = "ykSbFGkA"

View File

@ -1,13 +0,0 @@
name = "Lithium"
filename = "lithium-fabric-mc1.19.3-0.10.4.jar"
side = "both"
[download]
url = "https://cdn.modrinth.com/data/gvQqBUqZ/versions/XS6vJwop/lithium-fabric-mc1.19.3-0.10.4.jar"
hash-format = "sha1"
hash = "a1b521e18f7857a2fd327c7bebeed3128418e3c9"
[update]
[update.modrinth]
mod-id = "gvQqBUqZ"
version = "XS6vJwop"

View File

@ -1,13 +0,0 @@
name = "Memory Leak Fix"
filename = "memoryleakfix-1.19.3-0.7.0.jar"
side = "both"
[download]
url = "https://cdn.modrinth.com/data/NRjRiSSD/versions/YtNQP5gX/memoryleakfix-1.19.3-0.7.0.jar"
hash-format = "sha1"
hash = "9fae1093c64b47d6b97ee825ed3d9b725490700c"
[update]
[update.modrinth]
mod-id = "NRjRiSSD"
version = "YtNQP5gX"

View File

@ -1,13 +0,0 @@
name = "No Chat Reports"
filename = "NoChatReports-FABRIC-1.19.3-v2.0.0.jar"
side = "both"
[download]
url = "https://cdn.modrinth.com/data/qQyHxfxd/versions/uVt4LKvF/NoChatReports-FABRIC-1.19.3-v2.0.0.jar"
hash-format = "sha1"
hash = "2eaa80b4480ca6c0d8b1180fdb742ebcb43ac300"
[update]
[update.modrinth]
mod-id = "qQyHxfxd"
version = "uVt4LKvF"

View File

@ -1,13 +0,0 @@
name = "Smooth Boot (Fabric)"
filename = "smoothboot-fabric-1.19-1.7.1.jar"
side = "both"
[download]
url = "https://cdn.modrinth.com/data/FWumhS4T/versions/1.19-1.7.1/smoothboot-fabric-1.19-1.7.1.jar"
hash-format = "sha1"
hash = "8414cbce145a5f48102e6cc811dfd1459afe44f3"
[update]
[update.modrinth]
mod-id = "FWumhS4T"
version = "r8xRVPEI"

View File

@ -1,13 +0,0 @@
name = "spark"
filename = "spark-1.10.29-fabric.jar"
side = "both"
[download]
url = "https://cdn.modrinth.com/data/l6YH9Als/versions/1K3xO8TS/spark-1.10.29-fabric.jar"
hash-format = "sha1"
hash = "680b8ed890e05ed0811065a381a7924d536e0508"
[update]
[update.modrinth]
mod-id = "l6YH9Als"
version = "1K3xO8TS"

View File

@ -1,13 +0,0 @@
name = "Styled Chat"
filename = "styled-chat-2.1.2+1.19.3.jar"
side = "both"
[download]
url = "https://cdn.modrinth.com/data/doqSKB0e/versions/BriPIjGV/styled-chat-2.1.2%2B1.19.3.jar"
hash-format = "sha1"
hash = "f54c649adb0b4cfccdfca71ddd0a2f4afe761947"
[update]
[update.modrinth]
mod-id = "doqSKB0e"
version = "BriPIjGV"

View File

@ -1,13 +0,0 @@
name = "Styled Player List"
filename = "styledplayerlist-2.3.0+1.19.3.jar"
side = "server"
[download]
url = "https://cdn.modrinth.com/data/DQIfKUHf/versions/cEi0Qx95/styledplayerlist-2.3.0%2B1.19.3.jar"
hash-format = "sha1"
hash = "1edd1c021991f26ab42ea3eb49153d719153a582"
[update]
[update.modrinth]
mod-id = "DQIfKUHf"
version = "cEi0Qx95"

View File

@ -1,13 +0,0 @@
name = "thorium"
filename = "thorium-1.4.0.jar"
side = "both"
[download]
url = "https://cdn.modrinth.com/data/ImUQFWcy/versions/ChzyZR8C/thorium-1.4.0.jar"
hash-format = "sha1"
hash = "dc5d3176cf60ee669ef0f5ca0fc151cd403aa64a"
[update]
[update.modrinth]
mod-id = "ImUQFWcy"
version = "ChzyZR8C"

View File

@ -1,13 +0,0 @@
name = "YetAnotherConfigLib"
filename = "YetAnotherConfigLib-2.2.0.jar"
side = "both"
[download]
url = "https://cdn.modrinth.com/data/1eAoo2KR/versions/3EWbdCzX/YetAnotherConfigLib-2.2.0.jar"
hash-format = "sha1"
hash = "62158cf974075dfd896540191e4ae108e6ec67b3"
[update]
[update.modrinth]
mod-id = "1eAoo2KR"
version = "3EWbdCzX"

View File

@ -1,13 +0,0 @@
name = "Polarcraft Modpack Server"
author = "Xeovalyte"
version = "1.0.0"
pack-format = "packwiz:1.1.0"
[index]
file = "index.toml"
hash-format = "sha256"
hash = "6128b2e4b2f814751c53a71f47da47aac28c41f25c5da220c55f673d2350ec98"
[versions]
minecraft = "1.19.3"
quilt = "0.18.2"

View File

@ -15,5 +15,25 @@
<Icon size="1.5em" name="heroicons:map" class="mr-2" />
Map
</NuxtLink>
<div class="mb-5 mt-auto flex w-full items-center rounded bg-black/0 p-2 text-lg hover:cursor-pointer hover:bg-black/20" @click="logout">
<Icon size="1.5em" name="heroicons:arrow-right-on-rectangle" class="mr-2" />
Logout
</div>
</div>
</template>
<script setup>
const logout = async () => {
try {
await useFetch('/api/auth', {
method: 'DELETE'
})
navigateTo('/login')
} catch (e) {
console.error(e)
useToast().add({ title: e.statusMessage, color: 'red' })
}
}
</script>

View File

@ -0,0 +1,4 @@
export default defineEventHandler((event) => {
setCookie(event, 'jwt', '', { httpOnly: true, maxAge: 1 })
sendRedirect(event, '/', 302)
})