Changed to deno suport

This commit is contained in:
Lukian 2024-12-23 20:15:22 +01:00
parent ac0672f13a
commit 13df5eb10d
14 changed files with 35 additions and 60 deletions

View file

@ -1,2 +1,2 @@
DISCORD_TOKEN=""
BOT_ID=""
DISCORD_TOKEN="MTE0MTA2NjU3MTUwMzEyNDU0MA.GJATwt.Q4bVmnbv5pw8s5jTXfnJBOYlDlMsxW0gEn2k24"
BOT_ID="1141066571503124540"

5
.gitignore vendored
View file

@ -1,4 +1,3 @@
node_modules
package-lock.json
dist
.env
.env
deno.lock

View file

@ -1,4 +0,0 @@
FROM node:latest
WORKDIR /app
COPY . /app
CMD ["npm", "run", "start"]

4
Dockerfile Normal file
View file

@ -0,0 +1,4 @@
FROM denoland/deno:alpine
WORKDIR /app
COPY . .
CMD ["deno", "run", "start"]

11
deno.json Normal file
View file

@ -0,0 +1,11 @@
{
"tasks": {
"dev": "deno run --allow-env --allow-read --allow-net --watch src/main.ts",
"start": "deno run --allow-env --allow-read --allow-net src/main.ts"
},
"imports": {
"@std/assert": "jsr:@std/assert@1",
"discord.js": "npm:discord.js@^14.16.3",
"dotenv": "npm:dotenv@^16.4.7"
}
}

View file

@ -1,10 +1,8 @@
version: '3.1'
services:
service_name:
discord_bot:
build:
context: .
dockerfile: DOCKERFILE
dockerfile: Dockerfile
container_name: discord_bot
restart: always
volumes:
- /full/path/to/bot:/app

View file

@ -1,20 +0,0 @@
{
"name": "bot-template-ts",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"dev": "tsx watch src",
"build": "tsc",
"start": "node dist"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"discord.js": "^14.14.1",
"dotenv": "^16.4.5",
"mysql": "^2.18.1"
}
}

View file

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

View file

@ -1,4 +1,4 @@
import { SlashCommandBuilder, ChatInputCommandInteraction } from "discord.js";
import { SlashCommandBuilder, ChatInputCommandInteraction } from "npm:discord.js";
export default {
data: new SlashCommandBuilder()

View file

@ -1,4 +1,4 @@
import { Events, Interaction } from "discord.js";
import { Events, Interaction } from "npm:discord.js";
export default {
name: Events.InteractionCreate,

View file

@ -1,4 +1,4 @@
import { Events, Message } from "discord.js";
import { Events, Message } from "npm:discord.js";
export default {
name: Events.MessageCreate,

View file

@ -1,4 +1,4 @@
import { Events, Client } from "discord.js";
import { Events, Client } from "npm:discord.js";
export default {
name: Events.ClientReady,

View file

@ -1,7 +1,7 @@
import * as fs from 'fs';
import * as path from 'path';
import "dotenv/config";
import { Client, Collection, REST, Routes, RESTPutAPIApplicationCommandsResult } from 'discord.js';
import * as fs from 'node:fs';
import * as path from 'node:path';
import "npm:dotenv/config";
import { Client, Collection, REST, Routes, RESTPutAPIApplicationCommandsResult } from 'npm:discord.js';
const client: Client = new Client({
intents: [],
@ -23,7 +23,7 @@ async function loadCommands() {
for (const file of commandFiles) {
const filePath = `./commands/${folder}/${file}`;
const command = await import(filePath.replace(".ts", ".js"));
const command = await import(filePath);
if ("data" in command.default && "execute" in command.default) {
client.commands.set(command.default.data.name, command.default);
commands.push(command.default.data.toJSON());
@ -43,7 +43,7 @@ async function loadEvents() {
for (const file of eventFiles) {
const filePath = `./events/${file}`;
const event = await import(filePath.replace(".ts", ".js"));
const event = await import(filePath);
if (event.default.once) {
client.once(event.default.name, (...args) => event.default.execute(...args));

View file

@ -1,13 +0,0 @@
{
"compilerOptions": {
"target": "ES5",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"resolveJsonModule": true,
"strict": true,
"outDir": "./dist",
"skipLibCheck": true,
"noImplicitAny": true,
},
"include": ["src"],
}