From 6669b3fb8f027c348466088fc82b66a17323e0c1 Mon Sep 17 00:00:00 2001 From: itzdrli Date: Fri, 25 Apr 2025 22:30:02 +0200 Subject: [PATCH] init --- .gitignore | 34 ++++++++++++++++++++++++++++++++++ README.md | 15 +++++++++++++++ bun.lock | 30 ++++++++++++++++++++++++++++++ commands.json | 1 + package.json | 18 ++++++++++++++++++ seyfert.config.ts | 14 ++++++++++++++ src/commands/mcs.ts | 30 ++++++++++++++++++++++++++++++ src/commands/ping.ts | 16 ++++++++++++++++ src/index.ts | 13 +++++++++++++ tsconfig.json | 28 ++++++++++++++++++++++++++++ 10 files changed, 199 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 bun.lock create mode 100644 commands.json create mode 100644 package.json create mode 100644 seyfert.config.ts create mode 100644 src/commands/mcs.ts create mode 100644 src/commands/ping.ts create mode 100644 src/index.ts create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a14702c --- /dev/null +++ b/.gitignore @@ -0,0 +1,34 @@ +# dependencies (bun install) +node_modules + +# output +out +dist +*.tgz + +# code coverage +coverage +*.lcov + +# logs +logs +_.log +report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# caches +.eslintcache +.cache +*.tsbuildinfo + +# IntelliJ based IDEs +.idea + +# Finder (MacOS) folder config +.DS_Store diff --git a/README.md b/README.md new file mode 100644 index 0000000..ec3534a --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# fantastic_spoon_dc + +To install dependencies: + +```bash +bun install +``` + +To run: + +```bash +bun run index.ts +``` + +This project was created using `bun init` in bun v1.2.10. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. diff --git a/bun.lock b/bun.lock new file mode 100644 index 0000000..9c9f5c2 --- /dev/null +++ b/bun.lock @@ -0,0 +1,30 @@ +{ + "lockfileVersion": 1, + "workspaces": { + "": { + "name": "fantastic_spoon_dc", + "dependencies": { + "seyfert": "^3.0.0", + }, + "devDependencies": { + "@types/bun": "latest", + }, + "peerDependencies": { + "typescript": "^5", + }, + }, + }, + "packages": { + "@types/bun": ["@types/bun@1.2.10", "", { "dependencies": { "bun-types": "1.2.10" } }, "sha512-eilv6WFM3M0c9ztJt7/g80BDusK98z/FrFwseZgT4bXCq2vPhXD4z8R3oddmAn+R/Nmz9vBn4kweJKmGTZj+lg=="], + + "@types/node": ["@types/node@22.15.2", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-uKXqKN9beGoMdBfcaTY1ecwz6ctxuJAcUlwE55938g0ZJ8lRxwAZqRz2AJ4pzpt5dHdTPMB863UZ0ESiFUcP7A=="], + + "bun-types": ["bun-types@1.2.10", "", { "dependencies": { "@types/node": "*" } }, "sha512-b5ITZMnVdf3m1gMvJHG+gIfeJHiQPJak0f7925Hxu6ZN5VKA8AGy4GZ4lM+Xkn6jtWxg5S3ldWvfmXdvnkp3GQ=="], + + "seyfert": ["seyfert@3.0.0", "", {}, "sha512-Gs8e3gBqNgo6KCsCHND1k6I+rtKIeI/aUfA+AC4YQrgV9oiPwrWSCr9F4+Vu6S9IaTEyW9Tl7pkWfTXsukjbwA=="], + + "typescript": ["typescript@5.8.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ=="], + + "undici-types": ["undici-types@6.21.0", "", {}, "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="], + } +} diff --git a/commands.json b/commands.json new file mode 100644 index 0000000..3f328ff --- /dev/null +++ b/commands.json @@ -0,0 +1 @@ +[{"name":"mcs","type":1,"nsfw":false,"description":"Qeury a Minecraft server","contexts":[0,1,2],"integration_types":[0],"options":[{"name":"ip","description":"Server IP","type":3,"name_localizations":{},"description_localizations":{},"autocomplete":false}]},{"name":"ping","type":1,"nsfw":false,"description":"Show latency with Discord","contexts":[0,1,2],"integration_types":[0],"options":[]}] \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..63f9ca0 --- /dev/null +++ b/package.json @@ -0,0 +1,18 @@ +{ + "name": "fantastic_spoon_dc", + "module": "index.ts", + "type": "module", + "private": true, + "devDependencies": { + "@types/bun": "latest" + }, + "scripts": { + "dev": "bun --env-file=.env --watch src/index.ts" + }, + "peerDependencies": { + "typescript": "^5" + }, + "dependencies": { + "seyfert": "^3.0.0" + } +} diff --git a/seyfert.config.ts b/seyfert.config.ts new file mode 100644 index 0000000..47b72c1 --- /dev/null +++ b/seyfert.config.ts @@ -0,0 +1,14 @@ +import { config } from "seyfert"; + +export default config.bot({ + token: process.env.DC_TOKEN ?? "", + locations: { + base: "src", // replace with "src" if using bun + commands: "commands" + }, + intents: ["Guilds"], + // This configuration is optional, in case you want to receive interactions via HTTP + // This allows you to use both the gateway and the HTTP webhook + publicKey: process.env.PUBLIC_KEY ?? "", // replace with your public key + port: 3275, // replace with your application's port +}); \ No newline at end of file diff --git a/src/commands/mcs.ts b/src/commands/mcs.ts new file mode 100644 index 0000000..2414449 --- /dev/null +++ b/src/commands/mcs.ts @@ -0,0 +1,30 @@ +import { + Command, + Declare, + Options, + createStringOption, + type CommandContext +} from 'seyfert'; + +const options = { + ip: createStringOption({ + description: "Server IP", + }), +}; + +@Declare({ + name: 'mcs', + description: 'Qeury a Minecraft server', +}) +@Options(options) +export default class McsCommand extends Command { + + async run(ctx: CommandContext) { + const ip = ctx.options.ip || 'hypixel.net'; + const port = 25565; + + await ctx.write({ + content: `${ip}:${port}`, + }); + } +} \ No newline at end of file diff --git a/src/commands/ping.ts b/src/commands/ping.ts new file mode 100644 index 0000000..acb2919 --- /dev/null +++ b/src/commands/ping.ts @@ -0,0 +1,16 @@ +import { Declare, Command, type CommandContext } from 'seyfert'; + +@Declare({ + name: 'ping', + description: 'Show latency with Discord' +}) +export default class PingCommand extends Command { + async run(ctx: CommandContext) { + // Average latency between existing connections + const ping = ctx.client.gateway.latency; + + await ctx.write({ + content: `The latency is \`${ping}\`` + }); + } +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..d74af8f --- /dev/null +++ b/src/index.ts @@ -0,0 +1,13 @@ +import { Client } from "seyfert"; + +import type { ParseClient } from "seyfert"; + +declare module 'seyfert' { + interface UsingClient extends ParseClient> { } +} + +const client = new Client(); + +// This will start the connection with the Discord gateway and load commands, events, components, and language (i18n) +client.start() + .then(() => client.uploadCommands({ cachePath: './commands.json' })); \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..9c62f74 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + // Environment setup & latest features + "lib": ["ESNext"], + "target": "ESNext", + "module": "ESNext", + "moduleDetection": "force", + "jsx": "react-jsx", + "allowJs": true, + + // Bundler mode + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + + // Best practices + "strict": true, + "skipLibCheck": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedIndexedAccess": true, + + // Some stricter flags (disabled by default) + "noUnusedLocals": false, + "noUnusedParameters": false, + "noPropertyAccessFromIndexSignature": false + } +}