diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..4b21a2a --- /dev/null +++ b/.eslintignore @@ -0,0 +1,7 @@ +# Folders +/.cache +/.git +/dist +/node_modules +.eslintcache +yarn.lock \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..f49619b --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,94 @@ +{ + "root": true, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "project": "./tsconfig.json" + }, + "plugins": ["@typescript-eslint", "import", "unicorn"], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking", + "plugin:import/recommended", + "plugin:import/typescript" + ], + "rules": { + "@typescript-eslint/explicit-function-return-type": [ + "error", + { + "allowExpressions": true + } + ], + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-floating-promises": "off", + "@typescript-eslint/no-inferrable-types": [ + "error", + { + "ignoreParameters": true + } + ], + "@typescript-eslint/no-misused-promises": "off", + "@typescript-eslint/no-unsafe-argument": "off", + "@typescript-eslint/no-unsafe-assignment": "off", + "@typescript-eslint/no-unsafe-call": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + "@typescript-eslint/no-unsafe-return": "off", + "@typescript-eslint/no-unused-vars": [ + "error", + { + "argsIgnorePattern": "^_", + "varsIgnorePattern": "^_" + } + ], + "@typescript-eslint/no-var-requires": "off", + "@typescript-eslint/require-await": "off", + "@typescript-eslint/restrict-template-expressions": "off", + "@typescript-eslint/return-await": ["error", "always"], + "@typescript-eslint/typedef": [ + "error", + { + "parameter": true, + "propertyDeclaration": true + } + ], + "import/extensions": ["error", "ignorePackages"], + "import/no-extraneous-dependencies": "error", + "import/no-unresolved": "off", + "import/no-useless-path-segments": "error", + "import/order": [ + "error", + { + "alphabetize": { + "caseInsensitive": true, + "order": "asc" + }, + "groups": [ + ["builtin", "external", "object", "type"], + ["internal", "parent", "sibling", "index"] + ], + "newlines-between": "always" + } + ], + "no-return-await": "off", + "no-unused-vars": "off", + "prefer-const": "off", + "quotes": [ + "error", + "single", + { + "allowTemplateLiterals": true + } + ], + "sort-imports": [ + "error", + { + "allowSeparatedGroups": true, + "ignoreCase": true, + "ignoreDeclarationSort": true, + "ignoreMemberSort": false, + "memberSyntaxSortOrder": ["none", "all", "multiple", "single"] + } + ], + "unicorn/prefer-node-protocol": "error" + } +} diff --git a/.github/workflows/FUNDING.yml b/.github/workflows/FUNDING.yml new file mode 100644 index 0000000..538c7cc --- /dev/null +++ b/.github/workflows/FUNDING.yml @@ -0,0 +1,4 @@ +# These are supported funding model platforms + +github: LucasB25 +custom: ['https://www.paypal.me/battistoloL'] diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..04dd677 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,75 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: 'CodeQL' + +on: + push: + branches: ['main'] + pull_request: + # The branches below must be a subset of the branches above + branches: ['main'] + schedule: + - cron: '18 20 * * 3' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: ['javascript'] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Use only 'java' to analyze code written in Java, Kotlin or both + # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v3 + + # โ„น๏ธ Command-line programs to run using the OS shell. + # ๐Ÿ“š See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: '/language:${{matrix.language}}' diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b950435 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +# Folders +/.cache +/.git +/dist +/node_modules +.eslintcache +.env +package-lock.json +yarn.lock \ No newline at end of file diff --git a/.hintrc b/.hintrc new file mode 100644 index 0000000..12c4655 --- /dev/null +++ b/.hintrc @@ -0,0 +1,8 @@ +{ + "extends": [ + "development" + ], + "hints": { + "typescript-config/strict": "off" + } +} \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..4b21a2a --- /dev/null +++ b/.prettierignore @@ -0,0 +1,7 @@ +# Folders +/.cache +/.git +/dist +/node_modules +.eslintcache +yarn.lock \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..ad2cf87 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,12 @@ +{ + "printWidth": 100, + "tabWidth": 4, + "useTabs": false, + "semi": true, + "singleQuote": true, + "quoteProps": "as-needed", + "trailingComma": "es5", + "bracketSpacing": true, + "arrowParens": "avoid", + "endOfLine": "auto" +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..6fcfc9a --- /dev/null +++ b/README.md @@ -0,0 +1,108 @@ +
+ +[![Version][version-shield]](version-url) +[![Contributors][contributors-shield]][contributors-url] +[![Forks][forks-shield]][forks-url] +[![Stargazers][stars-shield]][stars-url] +[![Issues][issues-shield]][issues-url] +[![Support Server][support-shield]][support-server] +[![MIT License][license-shield]][license-url] +[![Run on Repl.it](https://repl.it/badge/github/LucasB25/AikouTicket)](https://repl.it/github/LucasB25/AikouTicket) +[![Remix on Glitch](https://cdn.glitch.com/2703baf2-b643-4da7-ab91-7ee2a2d00b5b%2Fremix-button.svg)](https://glitch.com/edit/#!/import/github/LucasB25/AikouTicket) + + +
+ +

AikouTicket

+ +

AikouTicket and TypeScript. +
+
+ Serveur Support + ยท + Report Bug & Request Feature +

+

+ +# AikouTicket + +AikouTicket is a versatile Discord bot that now also offers text-to-text capabilities through its integration with Google Gemini, an advanced text generation model platform. It automatically responds to specific commands on Discord, generating text or images based on the nature of users' requests. + +## ๐Ÿ”ง Requirements + +- Create Discord Bot and get token and client id from [Discord Developer Portal](https://discord.com/developers/applications) + +- Download [Node.js](https://nodejs.org/en/download/) + +## ๐Ÿš€ Installation from source + +1. Clone the AikouTicket repository: + +```bash +git clone https://github.com/LucasB25/AikouTicket.git +``` + +2. change the directory to AikouTicket + +```bash +cd AikouTicket +``` + +3. Install the required packages: + +```bash +npm i +or +yarn i +``` + +4. Set up your environment variables: + +Create a `.env` file in the root directory of your project with the following variables: +or you can use the [.env.example](https://raw.githubusercontent.com/LucasB25/AikouTicket/main/.env.example) file + +```bash +TOKEN= #Discord Bot Token +CLIENT_ID= #Discord Bot Client ID +Activity=/help +``` + +5. Run the bot: + +```bash +npm start +``` + +## ๐Ÿ“œ Contributing + +Thank you for your interest in contributing to AikouTicket! Here are some guidelines to follow when contributing: + +1. Fork the repository and create a new branch for your feature or bug fix. +2. Write clean and concise code that follows the established coding style. +3. Create detailed and thorough documentation for any new features or changes. +4. Write and run tests for your code. +5. Submit a pull request with your changes. + +Your contribution will be reviewed by the project maintainers, and any necessary feedback or changes will be discussed with you. We appreciate your help in making AikouTicket better! + +## ๐Ÿ‘ฅ Contributors + +Thanks goes to these wonderful people : + + + contributors + + +[version-shield]: https://img.shields.io/github/package-json/v/LucasB25/AikouTicket?style=for-the-badge +[contributors-shield]: https://img.shields.io/github/contributors/LucasB25/AikouTicket.svg?style=for-the-badge +[contributors-url]: https://github.com/LucasB25/AikouTicket/graphs/contributors +[forks-shield]: https://img.shields.io/github/forks/LucasB25/AikouTicket.svg?style=for-the-badge +[forks-url]: https://github.com/LucasB25/AikouTicket/network/members +[stars-shield]: https://img.shields.io/github/stars/LucasB25/AikouTicket.svg?style=for-the-badge +[stars-url]: https://github.com/LucasB25/AikouTicket/stargazers +[issues-shield]: https://img.shields.io/github/issues/LucasB25/AikouTicket.svg?style=for-the-badge +[issues-url]: https://github.com/LucasB25/AikouTicket/issues +[license-shield]: https://img.shields.io/github/license/LucasB25/AikouTicket.svg?style=for-the-badge +[license-url]: https://github.com/LucasB25/AikouTicket/blob/mains/LICENSE +[support-server]: https://discord.gg/AhUJa2kdAr +[support-shield]: https://img.shields.io/discord/942117923001098260.svg?style=for-the-badge&logo=discord&colorB=7289DA diff --git a/package.json b/package.json new file mode 100644 index 0000000..9e99922 --- /dev/null +++ b/package.json @@ -0,0 +1,59 @@ +{ + "name": "AikouTicket", + "version": "0.5.0", + "description": "A simple AikouTicket bot for discord", + "type": "module", + "main": "dist/index.js", + "scripts": { + "start": "npm run build && node dist/index.js", + "clean:windows": "rmdir /s /q dist", + "clean:linux": "rm -rf dist", + "build": "tsc --project tsconfig.json", + "lint": "eslint . --cache --ext .js,.jsx,.ts,.tsx", + "lint:fix": "eslint . --fix --cache --ext .js,.jsx,.ts,.tsx", + "format": "prettier --check .", + "format:fix": "prettier --write ." + }, + "repository": { + "type": "git", + "url": "git+https://github.com/LucasB25/AikouTicket.git" + }, + "bugs": { + "url": "https://github.com/LucasB25/AikouTicket/issues" + }, + "homepage": "https://github.com/LucasB25/AikouTicket#readme", + "devDependencies": { + "@types/node": "^20.12.12", + "@types/signale": "^1.4.7", + "@typescript-eslint/eslint-plugin": "^7.9.0", + "@typescript-eslint/parser": "^7.9.0", + "eslint": "^8.57.0", + "eslint-plugin-import": "^2.29.1", + "eslint-plugin-unicorn": "^53.0.0", + "prettier": "^3.2.5", + "ts-node": "^10.9.2" + }, + "keywords": [ + "discord", + "bot", + "support", + "tickets", + "typescript" + ], + "author": "LucasB25", + "license": "GPL-3.0", + "signale": { + "displayScope": true, + "displayBadge": true, + "displayDate": true, + "displayFilename": true, + "displayLabel": true, + "displayTimestamp": true, + "underlineLabel": true + }, + "dependencies": { + "discord.js": "^14.15.2", + "dotenv": "^16.4.5", + "signale": "^1.4.0" + } +} diff --git a/src/events/client/ClientReady.ts b/src/events/client/ClientReady.ts new file mode 100644 index 0000000..69e86fa --- /dev/null +++ b/src/events/client/ClientReady.ts @@ -0,0 +1,18 @@ +import { Bot, Event, EventsTypes } from '../../structures/index.js'; + +export default class ClientReady extends Event { + constructor(client: Bot, file: string) { + super(client, file, { + name: EventsTypes.ClientReady, + }); + } + + public async run(): Promise { + this.client.logger.info(`Connected to Discord as ${this.client.user?.tag}!`); + + this.client.user?.setActivity({ + name: `${this.client.config.activity}` + ' - by LucasB25', + type: 1, + }); + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..eb02467 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "target": "es2021", + "module": "es2022", + "lib": ["es2021"], + "declaration": true, + "sourceMap": true, + "outDir": "./dist", + "rootDir": "./src", + "strict": false, + "moduleResolution": "node", + "esModuleInterop": true, + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "skipLibCheck": true, + "importHelpers": true, + "forceConsistentCasingInFileNames": true + }, + "include": ["src/**/*"], + "exclude": ["dist", "node_modules"] +}