Skip to content

Commit

Permalink
Merge pull request #15 from EvarinDev/dev
Browse files Browse the repository at this point in the history
Refactor command file structure and fix author name in LICENSE
  • Loading branch information
EvarinDev authored Sep 8, 2024
2 parents 78c3d6e + 14008ff commit eb13a7d
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 44 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work.
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2024 | FAYStarNext [https://faystarnext.studio/]
Copyright 2024 | EvarinDev

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This is a bot for a community Discord server using the Discord.js library.

## Installation

1. Clone this repository `git clone https://github.com/EwarinDev/Discord.JS-Community-Bot && cd Discord.JS-Community-Bot`
1. Clone this repository `git clone https://github.com/EvarinDev/Discord.JS-Community-Bot && cd Discord.JS-Community-Bot`
2. Run `bun install` to install the dependencies.

## Usage
Expand Down
35 changes: 35 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const pluginJs = require("@eslint/js");
const globals = require("globals");
const tseslint = require("typescript-eslint");

module.exports = [
pluginJs.configs.recommended,
// ...tseslint.configs.recommendedTypeChecked,
{
files: ["**/*.{js,mjs,cjs,ts,tsx}"],
ignores: ["**/node_modules/**", "**/dist/**", "**/build/**"],
languageOptions: {
globals: {
...globals.browser,
...globals.node
},
},
plugins: {
"@typescript-eslint": tseslint.plugin
},
rules: {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "warn",
"no-undef": "off",
},
},
{
files: ["**/*.ts", "**/*.tsx"],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: "./tsconfig.json"
},
},
}
];
16 changes: 10 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@
"scripts": {
"dev:debug": "NODE_ENV=development bun src/index.ts",
"dev": "NODE_ENV=development bun --watch src/index.ts",
"start": "NODE_ENV=production bun src/index.ts"
"start": "NODE_ENV=production bun src/index.ts",
"lint": "bun x eslint src/**/*.ts"
},
"author": "FAYStarNext",
"author": "Evarin",
"license": "Apache-2.0",
"devDependencies": {
"@types/bun": "^1.1.6",
"globals": "^15.7.0",
"typescript": "^5.4.4"
"@eslint/js": "^9.10.0",
"@types/bun": "^1.1.8",
"eslint": "^9.10.0",
"globals": "^15.9.0",
"typescript": "^5.5.4",
"typescript-eslint": "^8.4.0"
},
"dependencies": {
"@discordjs/rest": "^2.3.0",
"@discordjs/rest": "^2.4.0",
"ansi-colors": "^4.1.3",
"cross-env": "^7.0.3",
"discord.js": "14.16.1",
Expand Down
12 changes: 6 additions & 6 deletions src/Client/Discord.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ActivityType, ApplicationCommandType, Client, Routes } from "discord.js";
import { ActivityType, ApplicationCommandType, Client, Collection, Routes } from "discord.js";
import { REST } from "@discordjs/rest";
import fs from "fs";
import path from "path";
import Config from "../Config";
import { Logger } from "../Logger";
import { CommandBuilder } from "../util/CommandBuilder";
import { CommandBuilder } from "../Util/CommandBuilder";

export class Discord extends Client {
public command = new Map<string, CommandBuilder>();
public command = new Collection<string, CommandBuilder>();
constructor() {
super({
intents: 3149317,
Expand Down Expand Up @@ -58,11 +58,11 @@ export class Discord extends Client {
public async _registerCommand() {
try {
const [slashFiles] = await Promise.all([
fs.readdirSync(path.join("src/Commands")),
fs.readdirSync(path.join(__dirname ,"../Commands")),
]);
const commands = [];
for (const folder of slashFiles) {
const commandsInFolder = fs.readdirSync(path.join(`src/Commands/${folder}`));
const commandsInFolder = fs.readdirSync(path.join(__dirname, `../Commands/${folder}`));
for (const commandFile of commandsInFolder) {
const command = await import(`../Commands/${folder}/${commandFile}`).then((c) => c.default);
commands.push(command.data);
Expand All @@ -72,7 +72,7 @@ export class Discord extends Client {
}
const rest = new REST({ version: '10' }).setToken(Config.TOKEN);

await Promise.all([
return await Promise.all([
Logger.info(`Started refreshing application (/) commands.`),
rest.put(Routes.applicationGuildCommands(Config.CLIENT_ID, Config.GUILD_ID), { body: commands }).then(() => Logger.info(`Successfully reloaded application (/) commands.`))
]);
Expand Down
5 changes: 2 additions & 3 deletions src/Commands/admin/ban.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ApplicationCommandOptionType, ChatInputCommandInteraction, CacheType, GuildMember } from "discord.js";
import { CommandBuilder } from "../../util/CommandBuilder";
import { Discord } from "../../Client/Discord";
import { ApplicationCommandOptionType, ChatInputCommandInteraction, GuildMember } from "discord.js";
import { CommandBuilder } from "../../Util/CommandBuilder";

export default new CommandBuilder({
data: {
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/admin/kick.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApplicationCommandOptionType, GuildMember } from "discord.js";
import { CommandBuilder } from "../../util/CommandBuilder";
import { CommandBuilder } from "../../Util/CommandBuilder";

export default new CommandBuilder({
data: {
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/info/ping.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EmbedBuilder } from "discord.js";
import { CommandBuilder } from "../../util/CommandBuilder";
import { CommandBuilder } from "../../Util/CommandBuilder";

export default new CommandBuilder({
data: {
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/info/serverinfo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EmbedBuilder } from "discord.js";
import { CommandBuilder } from "../../util/CommandBuilder";
import { CommandBuilder } from "../../Util/CommandBuilder";

export default new CommandBuilder({
data: {
Expand Down
File renamed without changes.
49 changes: 25 additions & 24 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
{
"$schema": "https://json.schemastore.org/tsconfig.json",
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"outDir": "./dist",
"rootDir": "./src",
"lib": [
"ES2020"
],
"types": [
"bun"
],
"strict": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"forceConsistentCasingInFileNames": true,
"checkJs": true,
"skipLibCheck": true
"lib": [
"ESNext"
],
"target": "ESNext",
"module": "CommonJS",
"allowJs": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"noFallthroughCasesInSwitch": true,
"types": [
"bun"
],
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"esModuleInterop": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"rootDir": "./src",
"outDir": "./dist",
"paths": {
"@/*": ["./src/*"],
}
},
"include": [
"src/**/**/**/**/**/**/*.ts"
],
"exclude": [
"node_modules"
]
}
"include": ["src"],
"exclude": ["node_modules"]
}

0 comments on commit eb13a7d

Please sign in to comment.