├── .prettierignore ├── lib └── discial-api │ ├── README.md │ ├── src │ ├── v10 │ │ ├── index.ts │ │ └── Channel.ts │ ├── index.ts │ ├── constants │ │ ├── index.ts │ │ ├── options.ts │ │ └── method.ts │ └── utils │ │ └── api.ts │ ├── test │ ├── config.json │ └── index.test.ts │ ├── package.json │ ├── .gitignore │ └── tsconfig.json ├── test ├── config.json ├── events │ ├── ready.ts │ └── message_create.ts └── index.ts ├── packages ├── intent │ └── index.ts ├── constants │ ├── index.ts │ ├── payload.ts │ ├── dataReq.ts │ └── eventsType.ts ├── typings │ ├── ClientOptions.ts │ ├── options.ts │ └── UserInput.ts ├── @api │ └── link │ │ └── index.ts ├── index.ts ├── interfaces │ └── dataReq.ts ├── modules │ └── status │ │ └── index.ts ├── handler │ ├── ready.ts │ └── message_create.ts ├── server │ └── WebSocket.ts ├── functions │ └── initEvent.ts ├── client │ ├── Events.ts │ └── index.ts ├── channel │ └── index.ts ├── user │ └── index.ts └── message │ └── index.ts ├── .github ├── ISSUE_TEMPLATE │ ├── custom.md │ ├── feature_request.md │ └── bug_report.md ├── dependabot.yml ├── FUNDING.yml └── workflows │ ├── dependency-review.yml │ └── codeql-analysis.yml ├── .vscode └── settings.json ├── SECURITY.md ├── .prettierrc.json ├── .eslintrc.json ├── package.json ├── LICENSE ├── README.md ├── .gitignore ├── CODE_OF_CONDUCT.md ├── Untitled Diagram.drawio └── tsconfig.json /.prettierignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/discial-api/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "botToken": "" 3 | } -------------------------------------------------------------------------------- /lib/discial-api/src/v10/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Channel' -------------------------------------------------------------------------------- /packages/intent/index.ts: -------------------------------------------------------------------------------- 1 | export const defaultIntents = 1 << 0 << 9 -------------------------------------------------------------------------------- /lib/discial-api/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './constants'; 2 | export * from './v10'; -------------------------------------------------------------------------------- /packages/constants/index.ts: -------------------------------------------------------------------------------- 1 | export * from './eventsType'; 2 | export * from './payload' -------------------------------------------------------------------------------- /lib/discial-api/src/constants/index.ts: -------------------------------------------------------------------------------- 1 | export * from './method'; 2 | export * from './options'; -------------------------------------------------------------------------------- /packages/typings/ClientOptions.ts: -------------------------------------------------------------------------------- 1 | export type ClientOptions = { 2 | token?: string; 3 | }; 4 | -------------------------------------------------------------------------------- /lib/discial-api/src/constants/options.ts: -------------------------------------------------------------------------------- 1 | export type options = { 2 | token: string; 3 | body?: string; 4 | } -------------------------------------------------------------------------------- /packages/constants/payload.ts: -------------------------------------------------------------------------------- 1 | export interface Payload { 2 | op: number; 3 | s: number; 4 | t: string; 5 | d: any; 6 | } -------------------------------------------------------------------------------- /lib/discial-api/test/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "botToken": "", 3 | "channelTest": { 4 | "channelID": 1234567890345 5 | } 6 | } -------------------------------------------------------------------------------- /packages/typings/options.ts: -------------------------------------------------------------------------------- 1 | import {statusIn} from '../modules/status'; 2 | 3 | export type options = { 4 | token: string; 5 | intents: string[] | number[]; 6 | }; 7 | -------------------------------------------------------------------------------- /packages/@api/link/index.ts: -------------------------------------------------------------------------------- 1 | export const DiscordGateway = { 2 | init: (version: string | number) => { 3 | return `wss://gateway.discord.gg/?v=${version}&encoding=json`; 4 | }, 5 | }; 6 | -------------------------------------------------------------------------------- /packages/index.ts: -------------------------------------------------------------------------------- 1 | export * from './client' 2 | export * from './client/Events' 3 | export * from './interfaces/dataReq' 4 | export * from './typings/UserInput' 5 | export * from './typings/options' 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Custom issue template 3 | about: Describe this issue template's purpose here. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /packages/interfaces/dataReq.ts: -------------------------------------------------------------------------------- 1 | export interface dataReq { 2 | op: number; 3 | d: { 4 | token: string; 5 | intents: string | number | number[]; 6 | properties: { 7 | os: string; 8 | browser: string; 9 | device: string; 10 | }; 11 | }; 12 | } 13 | -------------------------------------------------------------------------------- /packages/constants/dataReq.ts: -------------------------------------------------------------------------------- 1 | import { dataReq as d } from '../interfaces/dataReq'; 2 | 3 | export const dataReq: d = { 4 | op: 0, 5 | d: { 6 | token: '', 7 | intents: 0, 8 | properties: { 9 | os: '', 10 | browser: '', 11 | device: '', 12 | }, 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /lib/discial-api/test/index.test.ts: -------------------------------------------------------------------------------- 1 | import { Channel } from '../src/index'; 2 | import { botToken, channelTest } from "./config.json" ; 3 | 4 | const channel = Channel; 5 | channel.init(botToken); 6 | channel.getChannel(channelTest.channelID.toString()).then((data) => { 7 | console.log(data) 8 | }); -------------------------------------------------------------------------------- /test/events/ready.ts: -------------------------------------------------------------------------------- 1 | import {Events, Client, verifyEvent} from '../../packages' 2 | 3 | @verifyEvent 4 | export default class extends Events { 5 | constructor(client: Client) { 6 | super() 7 | this.render(client, 'READY', () => { 8 | console.log('hello') 9 | }) 10 | 11 | } 12 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "workbench.colorCustomizations": { 3 | "[One Dark Pro Mix]": { 4 | "activityBar.activeBackground": "#393E46", 5 | "activityBar.activeBorder": "#E7F6F2", 6 | "activityBar.background": "#222831" 7 | }, 8 | "minimap.background": "#00000000" 9 | } 10 | } -------------------------------------------------------------------------------- /lib/discial-api/src/constants/method.ts: -------------------------------------------------------------------------------- 1 | type method = { 2 | POST: string; 3 | GET: string; 4 | PUT: string; 5 | DELETE: string; 6 | PATCH: string; 7 | } 8 | 9 | export const method: method = { 10 | POST: 'POST', 11 | GET: 'GET', 12 | PUT: 'PUT', 13 | DELETE: 'DELETE', 14 | PATCH: 'PATCH', 15 | } -------------------------------------------------------------------------------- /test/index.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable max-len */ 2 | import { Client } from '../packages'; 3 | import { botToken } from "./config.json"; 4 | 5 | const client = new Client({ 6 | token: process.env.TOKEN 7 | }); 8 | 9 | 10 | client.setEvent('./test/events'); 11 | client.initEvent(); 12 | 13 | client.login(); 14 | 15 | -------------------------------------------------------------------------------- /packages/modules/status/index.ts: -------------------------------------------------------------------------------- 1 | type statusIn = { 2 | 'trực tuyến': string; 3 | 'chờ': string; 4 | 'không làm phiền': string; 5 | 'ngoại tuyến': string; 6 | }; 7 | 8 | export const statusIn: statusIn = { 9 | 'trực tuyến': 'online', 10 | 'chờ': 'idle', 11 | 'không làm phiền': 'dnd', 12 | 'ngoại tuyến': 'offline', 13 | }; 14 | -------------------------------------------------------------------------------- /packages/handler/ready.ts: -------------------------------------------------------------------------------- 1 | import { Client } from '../client'; 2 | import { Payload } from '../constants'; 3 | import { 4 | ReadyEventNameArray 5 | } from '../constants/eventsType'; 6 | import { User } from '../user'; 7 | 8 | 9 | export default async function (client: Client, payload: Payload) { 10 | const user = new User( 11 | client.token, 12 | JSON.parse(client.data).d.user 13 | ); 14 | ReadyEventNameArray.forEach((event) => { 15 | client.emit(event); 16 | }); 17 | } -------------------------------------------------------------------------------- /lib/discial-api/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "discial-api", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "dev": "ts-node ./test/index.test.ts" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "dependencies": { 14 | "discord-api-types": "^0.37.16", 15 | "ts-node": "^10.9.1" 16 | }, 17 | "homepage": "https://github.com/Folody-Team/Discial" 18 | } 19 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Use this section to tell people about which versions of your project are 6 | currently being supported with security updates. 7 | 8 | | Version | Supported | 9 | | ------- | ------------------ | 10 | | beta | :white_check_mark: | 11 | 12 | ## Reporting a Vulnerability 13 | 14 | Please create a ticket in Folody Community Discord server: https://discord.gg/BWm2znFebG 15 | 16 | You could also DM `Phat's Dev#7916` or `tobycm#7395` on Discord. 17 | -------------------------------------------------------------------------------- /test/events/message_create.ts: -------------------------------------------------------------------------------- 1 | import {Events, Client, verifyEvent} from '../../packages' 2 | 3 | @verifyEvent 4 | export default class extends Events { 5 | constructor(client: Client) { 6 | super() 7 | this.render(client, 'MESSAGE_CREATE', (message) => { 8 | console.log(`${message.author.username}: ${message.content}`) 9 | if(message.content == 'discial') { 10 | message.send('Bot này được tạo ra bởi Discial một thư viện phát triển bot discord của tương lai!') 11 | } 12 | }) 13 | } 14 | } -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "arrowParens": "always", 3 | "bracketSameLine": false, 4 | "bracketSpacing": true, 5 | "embeddedLanguageFormatting": "auto", 6 | "htmlWhitespaceSensitivity": "css", 7 | "insertPragma": false, 8 | "jsxSingleQuote": false, 9 | "printWidth": 80, 10 | "proseWrap": "preserve", 11 | "quoteProps": "as-needed", 12 | "requirePragma": false, 13 | "semi": true, 14 | "singleQuote": true, 15 | "tabWidth": 2, 16 | "trailingComma": "es5", 17 | "useTabs": true, 18 | "vueIndentScriptAndStyle": false 19 | } 20 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: 'npm' # See documentation for possible values 9 | directory: '/packages' # Location of package manifests 10 | schedule: 11 | interval: 'weekly' 12 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "es2021": true, 4 | "node": true 5 | }, 6 | "extends": [ 7 | "eslint:recommended", 8 | "plugin:@typescript-eslint/recommended" 9 | ], 10 | "parser": "@typescript-eslint/parser", 11 | "parserOptions": { 12 | "ecmaVersion": "latest", 13 | "sourceType": "module" 14 | }, 15 | "plugins": [ 16 | "@typescript-eslint" 17 | ], 18 | "rules": { 19 | "no-unused-vars": "off", 20 | "@typescript-eslint/no-unused-vars": [ 21 | "warn", 22 | { "argsIgnorePattern": "^_" } 23 | ] 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/handler/message_create.ts: -------------------------------------------------------------------------------- 1 | import {Client} from '../client' 2 | import { OnMessageCreateEventNameArray } from '../constants/eventsType'; 3 | import fetch from 'node-fetch'; 4 | import { Message } from '../message'; 5 | 6 | export type messageData = Message 7 | 8 | export default async function (client: Client) { 9 | const data = JSON.parse(client.data) 10 | const messageData: messageData = await Message.GetMessageByID( 11 | data.d.id, 12 | data.d.channel_id, 13 | client.token 14 | ); 15 | OnMessageCreateEventNameArray.forEach((event) => { 16 | client.emit(event, messageData); 17 | }); 18 | } -------------------------------------------------------------------------------- /packages/server/WebSocket.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-this-before-super */ 2 | /* eslint-disable no-trailing-spaces */ 3 | /* eslint-disable valid-jsdoc */ 4 | /* eslint-disable require-jsdoc */ 5 | import ws from 'ws'; 6 | 7 | // eslint-disable-next-line no-unused-vars 8 | export class WebSocket extends ws { 9 | // eslint-disable-next-line spaced-comment 10 | ////////////////////////// 11 | /** 12 | * @private {gateway, ws} 13 | * @param {string} gateway 14 | * @returns {WebSocket} 15 | */ 16 | // eslint-disable-next-line constructor-super 17 | /** 18 | * 19 | * @param gateway 20 | */ 21 | constructor(gateway: string) { 22 | super(gateway); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /packages/constants/eventsType.ts: -------------------------------------------------------------------------------- 1 | import {messageData} from '../handler/message_create'; 2 | 3 | type ReadyFunc = () => any; 4 | type OnMessageCreateFunc = (message: messageData) => any; 5 | 6 | type ReadyEventName = { 7 | READY: ReadyFunc; 8 | 'Đã kích hoạt': ReadyFunc; 9 | }; 10 | type OnMessageCreateEventName = { 11 | MESSAGE_CREATE: OnMessageCreateFunc; 12 | 'Tin nhắn được tạo': OnMessageCreateFunc; 13 | }; 14 | 15 | export const OnMessageCreateEventNameArray: Array< 16 | keyof OnMessageCreateEventName 17 | > = ['MESSAGE_CREATE', 'Tin nhắn được tạo']; 18 | export const ReadyEventNameArray: Array = [ 19 | 'READY', 20 | 'Đã kích hoạt', 21 | ]; 22 | 23 | export type IClientEvent = ReadyEventName & OnMessageCreateEventName; 24 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: 'folody' 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: 'folody-team' 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: ['https://www.folody.xyz'] 14 | -------------------------------------------------------------------------------- /packages/typings/UserInput.ts: -------------------------------------------------------------------------------- 1 | export interface UserInput { 2 | verified: boolean; 3 | username: string; 4 | mfa_enabled: boolean; 5 | id: string; 6 | flags: number; 7 | email: null; 8 | discriminator: string; 9 | bot: boolean; 10 | avatar?: string; 11 | } 12 | 13 | export interface MemberInput { 14 | roles: string[]; 15 | premium_since: any; 16 | pending: boolean; 17 | nick: string | null; 18 | mute: boolean; 19 | joined_at: string; 20 | flags: number; 21 | deaf: boolean; 22 | communication_disabled_until: null; 23 | avatar?: string; 24 | } 25 | 26 | export interface MessageAuthor { 27 | username: string; 28 | public_flags: number; 29 | id: string; 30 | discriminator: string; 31 | avatar_decoration?: any; 32 | avatar?: string; 33 | } 34 | -------------------------------------------------------------------------------- /packages/functions/initEvent.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-unused-vars */ 2 | import {Client} from '../client' 3 | import path from 'path' 4 | export function initEvent(dirname: string, client: Client) { 5 | import('node:fs').then(fs => { 6 | fs.readdir(`${dirname}`, (err, data) => { 7 | if(err) throw new Error(`${dirname} not found`) 8 | 9 | data.forEach(async file => { 10 | if(file.includes('jsx') || file.includes('js') || file.includes('tsx') || file.includes('ts')) { 11 | const {default: Init} = await import(path.resolve(`${dirname}/${file}`)) 12 | const event = new Init(client) 13 | if(event.event == true) { 14 | client.on(event.eventName, event.listener) 15 | } 16 | } 17 | }) 18 | }) 19 | }) 20 | } -------------------------------------------------------------------------------- /.github/workflows/dependency-review.yml: -------------------------------------------------------------------------------- 1 | # Dependency Review Action 2 | # 3 | # This Action will scan dependency manifest files that change as part of a Pull Request, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging. 4 | # 5 | # Source repository: https://github.com/actions/dependency-review-action 6 | # Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement 7 | name: 'Dependency Review' 8 | on: [pull_request] 9 | 10 | permissions: 11 | contents: read 12 | 13 | jobs: 14 | dependency-review: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: 'Checkout Repository' 18 | uses: actions/checkout@v3 19 | - name: 'Dependency Review' 20 | uses: actions/dependency-review-action@v2 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "discial", 3 | "version": "1.0.0", 4 | "description": "", 5 | "homepage": "https://github.com/Folody-Team/Discial", 6 | "main": "index.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1", 9 | "prepare": "husky install", 10 | "dev": "ts-node test/index.ts", 11 | "dev:nodemon": "nodemon test/index.ts" 12 | }, 13 | "keywords": [], 14 | "author": "", 15 | "license": "ISC", 16 | "dependencies": { 17 | "node-fetch": "^2.6.7", 18 | "websocket": "^1.0.34", 19 | "ws": "^8.8.1", 20 | "ws-heartbeat": "^1.2.0" 21 | }, 22 | "devDependencies": { 23 | "@types/node": "^18.7.5", 24 | "@types/node-fetch": "^2.6.2", 25 | "@types/websocket": "^1.0.5", 26 | "@types/ws": "^8.5.3", 27 | "@typescript-eslint/eslint-plugin": "^5.36.1", 28 | "@typescript-eslint/parser": "^5.36.1", 29 | "eslint": "^8.21.0", 30 | "eslint-config-google": "^0.14.0", 31 | "husky": "^8.0.1", 32 | "nodemon": "^2.0.19", 33 | "ts-node": "^10.9.1", 34 | "typescript": "^4.7.4" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Folody Studio 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /lib/discial-api/src/v10/Channel.ts: -------------------------------------------------------------------------------- 1 | import https, { RequestOptions } from 'https'; 2 | import zlib from 'zlib'; 3 | import {method, options} from '../.'; 4 | import {rest} from '../utils/api'; 5 | 6 | /** 7 | * @class Channel 8 | */ 9 | export class Channel { 10 | /** 11 | * @private {https, method} 12 | */ 13 | private static method: typeof method = method; 14 | 15 | /** 16 | * @protected {token, gzip} 17 | */ 18 | protected static token = ''; 19 | protected static gzip = { 20 | flush: zlib.Z_SYNC_FLUSH, 21 | finishFlush: zlib.Z_SYNC_FLUSH 22 | } 23 | 24 | /** 25 | * 26 | * @param url 27 | * @param method 28 | * @param body 29 | * @returns 30 | */ 31 | private static rest(url: string, method: string, body?: any) { 32 | 33 | /** 34 | * @return {Promise} 35 | */ 36 | return rest(url, method, body, this.token) 37 | 38 | } 39 | 40 | /** 41 | * 42 | * @param token 43 | */ 44 | public static init(token: string) { 45 | this.token = token; 46 | } 47 | 48 | /** 49 | * 50 | * @param id 51 | * @returns 52 | */ 53 | public static getChannel(id?: string) { 54 | return this.rest(`channels.${id}`, this.method.GET) 55 | 56 | } 57 | } -------------------------------------------------------------------------------- /packages/client/Events.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/ban-types */ 2 | /* eslint-disable no-empty-pattern */ 3 | /* eslint-disable @typescript-eslint/no-empty-function */ 4 | /* eslint-disable @typescript-eslint/no-unused-vars */ 5 | import {Client} from '.'; 6 | import {IClientEvent} from '../constants/eventsType'; 7 | 8 | /** 9 | * 10 | * @param target 11 | */ 12 | export function verifyEvent(target?: any): any { 13 | return class extends target { 14 | event = true 15 | } 16 | // target.prototype.event = true 17 | // target.constructor.prototype.event = true 18 | 19 | // // Object.assign(target?.prototype, {event: true}); 20 | 21 | // Object.seal(target); 22 | // Object.seal(target?.prototype); 23 | 24 | 25 | // console.log(target?.prototype) 26 | } 27 | 28 | export class Events{ 29 | public event!: boolean; 30 | public client!: Client 31 | /** 32 | * 33 | * @param client 34 | * @param event 35 | * @param listener 36 | */ 37 | render(client: Client, event: U, listener: IClientEvent[U]) { 38 | this.client = client 39 | /** 40 | * Add {eventName, listener} properties to this class 41 | */ 42 | Object.assign(this, {eventName: event, listener: listener}) 43 | } 44 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 |

3 | 4 | 5 | 6 | 7 | 8 |

Discial

9 | 10 | 11 |

12 |

13 |   14 |   15 | 16 | 17 |

18 | 19 | --- 20 | 21 | # Infomation 22 | A javascript and typescript package module for discord bot development, designed and developed with the simplest and most clean syntax. Maybe this is a promising package module. 23 | 24 | 25 | # Status 26 | 27 | This package is still in development, so it won't be available on the npm site yet. We are very grateful and ready to welcome anyone to contribute to this project, please join if you want. 28 | 29 | # Contributors 30 | 31 | 32 | 33 | 34 | 35 | --- 36 | 37 | ## This package is created by vietnamese with love 🇻🇳 38 | -------------------------------------------------------------------------------- /packages/channel/index.ts: -------------------------------------------------------------------------------- 1 | import fetch from "node-fetch"; 2 | 3 | export interface BaseChannelType { 4 | id: string; 5 | last_message_id: string; 6 | type: number; 7 | name: string; 8 | position: number; 9 | flags: number; 10 | parent_id: string; 11 | topic: null; 12 | guild_id: string; 13 | permission_overwrites: { 14 | id: string; 15 | type: number; 16 | allow: string; 17 | deny: string; 18 | }[]; 19 | rate_limit_per_user: number; 20 | nsfw: boolean; 21 | } 22 | 23 | export class BaseChannel implements BaseChannelType { 24 | id!: string; 25 | last_message_id!: string; 26 | type!: number; 27 | name!: string; 28 | position!: number; 29 | flags!: number; 30 | parent_id!: string; 31 | topic!: null; 32 | guild_id!: string; 33 | permission_overwrites!: { 34 | id: string; 35 | type: number; 36 | allow: string; 37 | deny: string; 38 | }[]; 39 | rate_limit_per_user!: number; 40 | nsfw!: boolean; 41 | token: string; 42 | constructor(data: BaseChannelType, token: string) { 43 | Object.assign(this, data); 44 | this.token = token; 45 | } 46 | 47 | public static async GetChannelById(id: string, token: string) { 48 | const ChannelData = await ( 49 | await fetch(`https://discord.com/api/v10/channels/${id}`, { 50 | method: 'GET', 51 | headers: { 52 | Authorization: `Bot ${token}`, 53 | 'Content-Type': 'application/json; charset=UTF-8', 54 | 'User-Agent': 55 | 'DiscordBot (https://github.com/Folody-Team/Discial, 1.0.0)', 56 | }, 57 | }) 58 | ).json(); 59 | return new BaseChannel(ChannelData, token); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /packages/user/index.ts: -------------------------------------------------------------------------------- 1 | import { MemberInput, UserInput, MessageAuthor } from '../typings/UserInput'; 2 | import fetch from 'node-fetch'; 3 | export class User implements UserInput { 4 | verified!: boolean; 5 | username!: string; 6 | mfa_enabled!: boolean; 7 | id!: string; 8 | flags!: number; 9 | email!: null; 10 | discriminator!: string; 11 | bot!: boolean; 12 | avatar?: string; 13 | token: string; 14 | constructor(token: string, UserData: UserInput) { 15 | Object.assign(this, { UserData }); 16 | this.token = token; 17 | } 18 | } 19 | 20 | export class Member implements MemberInput { 21 | token: string; 22 | roles!: string[]; 23 | premium_since: any; 24 | pending!: boolean; 25 | nick: string | null = null; 26 | mute!: boolean; 27 | joined_at!: string; 28 | flags!: number; 29 | deaf!: boolean; 30 | communication_disabled_until!: null; 31 | avatar?: string | undefined; 32 | constructor(token: string, MemberData: MemberInput) { 33 | Object.assign(this, MemberData); 34 | this.token = token; 35 | console.log(this) 36 | } 37 | public static async GetMemberByUserIDAndGuildID( 38 | id: string, 39 | guildId: string, 40 | token: string 41 | ) { 42 | const MemberData = await ( 43 | await fetch( 44 | `https://discord.com/api/v10/guilds/${guildId}/members/${id}`, 45 | { 46 | method: 'GET', 47 | headers: { 48 | Authorization: `Bot ${token}`, 49 | 'Content-Type': 'application/json; charset=UTF-8', 50 | 'User-Agent': 51 | 'DiscordBot (https://github.com/Folody-Team/Discial, 1.0.0)', 52 | }, 53 | } 54 | ) 55 | ).json(); 56 | return new Member(token, MemberData); 57 | } 58 | } 59 | 60 | export class Author implements MessageAuthor { 61 | token: string; 62 | username!: string; 63 | public_flags!: number; 64 | id!: string; 65 | discriminator!: string; 66 | avatar_decoration!: null; 67 | avatar?: string; 68 | constructor(author: MessageAuthor, token: string) { 69 | Object.assign(this, author); 70 | this.token = token; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript cache 45 | *.tsbuildinfo 46 | 47 | # Optional npm cache directory 48 | .npm 49 | 50 | # Optional eslint cache 51 | .eslintcache 52 | 53 | # Microbundle cache 54 | .rpt2_cache/ 55 | .rts2_cache_cjs/ 56 | .rts2_cache_es/ 57 | .rts2_cache_umd/ 58 | 59 | # Optional REPL history 60 | .node_repl_history 61 | 62 | # Output of 'npm pack' 63 | *.tgz 64 | 65 | # Yarn Integrity file 66 | .yarn-integrity 67 | 68 | # dotenv environment variables file 69 | .env 70 | .env.test 71 | 72 | # parcel-bundler cache (https://parceljs.org/) 73 | .cache 74 | 75 | # Next.js build output 76 | .next 77 | 78 | # Nuxt.js build / generate output 79 | .nuxt 80 | dist 81 | 82 | # Gatsby files 83 | .cache/ 84 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 85 | # https://nextjs.org/blog/next-9-1#public-directory-support 86 | # public 87 | 88 | # vuepress build output 89 | .vuepress/dist 90 | 91 | # Serverless directories 92 | .serverless/ 93 | 94 | # FuseBox cache 95 | .fusebox/ 96 | 97 | # DynamoDB Local files 98 | .dynamodb/ 99 | 100 | # TernJS port file 101 | .tern-port 102 | 103 | package-lock.json 104 | yarn.lock 105 | -------------------------------------------------------------------------------- /lib/discial-api/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript cache 45 | *.tsbuildinfo 46 | 47 | # Optional npm cache directory 48 | .npm 49 | 50 | # Optional eslint cache 51 | .eslintcache 52 | 53 | # Microbundle cache 54 | .rpt2_cache/ 55 | .rts2_cache_cjs/ 56 | .rts2_cache_es/ 57 | .rts2_cache_umd/ 58 | 59 | # Optional REPL history 60 | .node_repl_history 61 | 62 | # Output of 'npm pack' 63 | *.tgz 64 | 65 | # Yarn Integrity file 66 | .yarn-integrity 67 | 68 | # dotenv environment variables file 69 | .env 70 | .env.test 71 | 72 | # parcel-bundler cache (https://parceljs.org/) 73 | .cache 74 | 75 | # Next.js build output 76 | .next 77 | 78 | # Nuxt.js build / generate output 79 | .nuxt 80 | dist 81 | 82 | # Gatsby files 83 | .cache/ 84 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 85 | # https://nextjs.org/blog/next-9-1#public-directory-support 86 | # public 87 | 88 | # vuepress build output 89 | .vuepress/dist 90 | 91 | # Serverless directories 92 | .serverless/ 93 | 94 | # FuseBox cache 95 | .fusebox/ 96 | 97 | # DynamoDB Local files 98 | .dynamodb/ 99 | 100 | # TernJS port file 101 | .tern-port 102 | 103 | package-lock.json 104 | yarn.lock -------------------------------------------------------------------------------- /lib/discial-api/src/utils/api.ts: -------------------------------------------------------------------------------- 1 | import zlib from 'zlib'; 2 | import https from 'https'; 3 | import {homepage} from '../../package.json' 4 | 5 | const gzip = { 6 | flush: zlib.Z_SYNC_FLUSH, 7 | finishFlush: zlib.Z_SYNC_FLUSH 8 | } 9 | 10 | function makeid(length: number) { 11 | let result = ''; 12 | const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; 13 | const charactersLength = characters.length; 14 | for (let i = 0; i < length; i++ ) { 15 | result += characters.charAt(Math.floor(Math.random() * charactersLength)); 16 | } 17 | return result; 18 | } 19 | 20 | 21 | /** 22 | * 23 | * @param endpoint 24 | * @returns 25 | */ 26 | function createEndpoint(endpoint: string) { 27 | 28 | /** 29 | * Vietnamese comment: Ở đây nó sẽ trả về một object có kiểu là RequestOptions và sẽ hõ trợ cho request. 30 | */ 31 | return `https://discord.com/api/v10${endpoint}` 32 | } 33 | 34 | /** 35 | * 36 | * @param url 37 | * @param method 38 | * @param body 39 | * @param token 40 | * @returns 41 | */ 42 | export function rest(url: string, method: string, body?: any, token?: string) { 43 | return new Promise((resolve, reject) => { 44 | if(!token) reject(Error('Token not found')); 45 | let data = ''; 46 | const userAgent = `DiscordBot-${makeid(20)} (${homepage}, 1.0.0)` 47 | console.log(userAgent) 48 | const req = https.request(createEndpoint(url), { 49 | method: method, 50 | headers: { 51 | Authorization: `Bot ${token}`, 52 | 'Content-Type': 'application/json; charset=UTF-8', 53 | 'User-Agent': `${userAgent}`, 54 | 'Accept-Encoding': 'gzip' 55 | }, 56 | ...body 57 | }, res => { 58 | // Tạo một tác nhiệm unzip 59 | const unzip = zlib.createGunzip(gzip) 60 | 61 | /** 62 | * Vietnamese comment: SỰ kiện nếu có data trả về thì sẽ cộng dồn 63 | */ 64 | unzip.on('data', (chunk) => { 65 | data += chunk.toString() 66 | }) 67 | /** 68 | * Vietnamese comment: Sự kiện kết thúc thì nó sẽ trả về JSON data 69 | */ 70 | unzip.on('end', () => { 71 | data = JSON.parse(data); 72 | resolve(data) 73 | }) 74 | 75 | res.pipe(unzip); 76 | 77 | 78 | }) 79 | 80 | /** 81 | * Kết thúc request tránh hang out 82 | */ 83 | 84 | req.end() 85 | }) 86 | 87 | } -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: 'CodeQL' 13 | 14 | on: 15 | push: 16 | branches: ['main'] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: ['main'] 20 | schedule: 21 | - cron: '29 17 * * 0' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | permissions: 28 | actions: read 29 | contents: read 30 | security-events: write 31 | 32 | strategy: 33 | fail-fast: false 34 | matrix: 35 | language: ['javascript'] 36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] 37 | # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support 38 | 39 | steps: 40 | - name: Checkout repository 41 | uses: actions/checkout@v3 42 | 43 | # Initializes the CodeQL tools for scanning. 44 | - name: Initialize CodeQL 45 | uses: github/codeql-action/init@v2 46 | with: 47 | languages: ${{ matrix.language }} 48 | # If you wish to specify custom queries, you can do so here or in a config file. 49 | # By default, queries listed here will override any specified in a config file. 50 | # Prefix the list here with "+" to use these queries and those in the config file. 51 | 52 | # 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 53 | # queries: security-extended,security-and-quality 54 | 55 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 56 | # If this step fails, then you should remove it and run the build manually (see below) 57 | - name: Autobuild 58 | uses: github/codeql-action/autobuild@v2 59 | 60 | # ℹ️ Command-line programs to run using the OS shell. 61 | # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun 62 | 63 | # If the Autobuild fails above, remove it and uncomment the following three lines. 64 | # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. 65 | 66 | # - run: | 67 | # echo "Run, Build Application using script" 68 | # ./location_of_script_within_repo/buildscript.sh 69 | 70 | - name: Perform CodeQL Analysis 71 | uses: github/codeql-action/analyze@v2 72 | -------------------------------------------------------------------------------- /packages/message/index.ts: -------------------------------------------------------------------------------- 1 | import { Member } from '../user'; 2 | import fetch from 'node-fetch'; 3 | import { Author } from '../user/index'; 4 | import { BaseChannel } from '../channel'; 5 | 6 | export interface MessageRawData { 7 | type: number; 8 | tts: boolean; 9 | timestamp: string; 10 | referenced_message: null; 11 | pinned: boolean; 12 | nonce: string; 13 | mentions: never[]; 14 | mention_roles: never[]; 15 | mention_everyone: boolean; 16 | member: Member; 17 | id: string; 18 | flags: number; 19 | embeds: never[]; 20 | edited_timestamp: null; 21 | content: string; 22 | components: never[]; 23 | channel_id: string; 24 | author: Author; 25 | attachments: never[]; 26 | guild_id: string; 27 | } 28 | 29 | export class Message implements MessageRawData { 30 | type!: number; 31 | tts!: boolean; 32 | timestamp!: string; 33 | referenced_message!: null; 34 | pinned!: boolean; 35 | nonce!: string; 36 | mentions!: never[]; 37 | mention_roles!: never[]; 38 | mention_everyone!: boolean; 39 | member!: Member; 40 | id!: string; 41 | flags!: number; 42 | embeds!: never[]; 43 | edited_timestamp!: null; 44 | content!: string; 45 | components!: never[]; 46 | channel_id!: string; 47 | author!: Author; 48 | attachments!: never[]; 49 | guild_id!: string; 50 | channel!: BaseChannel; 51 | 52 | 53 | protected token: string; 54 | 55 | constructor( 56 | userData: MessageRawData & { channel: BaseChannel }, 57 | token: string 58 | ) { 59 | Object.assign(this, userData); 60 | this.token = token; 61 | } 62 | public static async GetMessageByID( 63 | id: string, 64 | channelID: string, 65 | token: string 66 | ) { 67 | const MessageData = await ( 68 | await fetch( 69 | `https://discord.com/api/v10/channels/${channelID}/messages/${id}`, 70 | { 71 | method: 'GET', 72 | headers: { 73 | Authorization: `Bot ${token}`, 74 | 'Content-Type': 'application/json; charset=UTF-8', 75 | 'User-Agent': 76 | 'DiscordBot (https://github.com/Folody-Team/Discial, 1.0.0)', 77 | }, 78 | } 79 | ) 80 | ).json(); 81 | 82 | const ChannelData = await BaseChannel.GetChannelById( 83 | MessageData.channel_id, 84 | token 85 | ); 86 | const MemberData = await Member.GetMemberByUserIDAndGuildID( 87 | MessageData.author.id, 88 | ChannelData.guild_id, 89 | token 90 | ); 91 | const MessageAuthor = new Author(MessageData.author, token); 92 | return new Message( 93 | { 94 | ...MessageData, 95 | channel: ChannelData, 96 | member: MemberData, 97 | author: MessageAuthor, 98 | }, 99 | token 100 | ); 101 | } 102 | public async send(content:string) { 103 | await fetch( 104 | `https://discord.com/api/v10/channels/${this.channel_id}/messages`, 105 | { 106 | method: 'POST', 107 | headers: { 108 | Authorization: `Bot ${this.token}`, 109 | 'Content-Type': 'application/json; charset=UTF-8', 110 | 'User-Agent': 111 | 'DiscordBot (https://github.com/Folody-Team/Discial, 1.0.0)', 112 | }, 113 | body: JSON.stringify({ 114 | content: content, 115 | }), 116 | } 117 | ); 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /packages/client/index.ts: -------------------------------------------------------------------------------- 1 | import ws from 'ws'; 2 | import { defaultIntents } from '../intent'; 3 | import { WebSocket } from '../server/WebSocket'; 4 | import { DiscordGateway } from '../@api/link'; 5 | import { EventEmitter } from 'events'; 6 | import { ClientOptions } from '../typings/ClientOptions'; 7 | import {initEvent} from '../functions/initEvent'; 8 | import { 9 | IClientEvent, 10 | } from '../constants/eventsType'; 11 | import { dataReq } from '../constants/dataReq'; 12 | import { User } from '../user'; 13 | 14 | declare interface Client extends EventEmitter { 15 | on(event: U, listener: IClientEvent[U]): this; 16 | 17 | emit( 18 | event: U, 19 | ...args: Parameters 20 | ): boolean; 21 | } 22 | 23 | class Client extends EventEmitter { 24 | private ws: WebSocket | undefined; 25 | private options: ClientOptions; 26 | private gateway: string = DiscordGateway.init(9); 27 | private defaultEvent!: string; 28 | 29 | public token: string; 30 | public data = '{}'; 31 | protected user: User | undefined; 32 | /** 33 | * 34 | * @param option 35 | */ 36 | constructor(option: ClientOptions) { 37 | super(); 38 | this.token = option.token || ''; 39 | this.options = option; 40 | } 41 | 42 | public setEvent(dirname: string): void { 43 | this.defaultEvent = dirname 44 | } 45 | 46 | public initEvent(): void { 47 | initEvent(this.defaultEvent, this) 48 | 49 | } 50 | // eslint-disablse-next-line require-jsdoc 51 | /** 52 | * @public listening 53 | */ 54 | public listening = this.on; 55 | /** 56 | * @public 'sự kiện' 57 | */ 58 | public 'sự kiện' = this.on; 59 | // eslint-disable-ext-line require-jsdoc 60 | /** 61 | * @public 'kích hoạt' 62 | */ 63 | public 'kích hoạt' = this.origin; 64 | /** 65 | * @public login 66 | */ 67 | public login = this.origin; 68 | 69 | private origin(): Promise { 70 | return new Promise((res, rej) => { 71 | const { token } = this.options; 72 | if (typeof token != 'string') { 73 | rej(new Error('token is not string')); 74 | return; 75 | } 76 | this.active(token); 77 | }); 78 | } 79 | /** 80 | * 81 | * @param ws 82 | * @param payload 83 | */ 84 | private async open(ws: WebSocket, payload: string) { 85 | ws.send(payload); 86 | } 87 | /** 88 | * 89 | * @param ws 90 | * @param data 91 | */ 92 | private async message(ws: WebSocket, data: ws.RawData, _payload: string) { 93 | const { op, d, t } = JSON.parse(data.toString()); 94 | switch (op) { 95 | case 0: 96 | break; 97 | case 10: { 98 | const { heartbeat_interval } = d; 99 | this.keepAlive(ws, heartbeat_interval); 100 | break; 101 | } 102 | default: 103 | break; 104 | } 105 | 106 | if (t) this.data = data.toString(); 107 | } 108 | /** 109 | * 110 | * @param ws 111 | * @param interval 112 | */ 113 | private async keepAlive(ws: WebSocket, interval: number) { 114 | /** 115 | * Delay to heartbeat 116 | */ 117 | setInterval(() => { 118 | /** 119 | * Send to ws again 120 | */ 121 | ws.send(JSON.stringify({ op: 1, d: null })); 122 | }, interval); 123 | } 124 | /** 125 | * 126 | * @param token 127 | * @param intents 128 | * @returns 129 | */ 130 | private dataReq = dataReq; 131 | 132 | /** 133 | * 134 | * @param dk 135 | * @param callback 136 | * @returns 137 | */ 138 | private 'nếu' = function (dk: any, callback: void | any) { 139 | if (dk) { 140 | /** 141 | * call acllback function 142 | */ 143 | callback(); 144 | } else return; 145 | }; 146 | 147 | /** 148 | * 149 | * @param token 150 | * @returns 151 | */ 152 | private async payload(token: string) { 153 | this.dataReq.op = 2; 154 | this.dataReq.d.token = token || ''; 155 | this.dataReq.d.intents = defaultIntents; 156 | this.dataReq.d.properties.os = 'linux'; 157 | this.dataReq.d.properties.browser = 'discial'; 158 | this.dataReq.d.properties.device = 'discial'; 159 | 160 | return JSON.stringify(this.dataReq); 161 | } 162 | /** 163 | * 164 | * @param token 165 | * @param intents 166 | */ 167 | private async active(token: string) { 168 | const ws = new WebSocket(this.gateway); 169 | 170 | const payload = await this.payload(token); 171 | this.ws = ws; 172 | 173 | /////////////////////////////////////// 174 | /** 175 | * open event in websocket 176 | */ 177 | ws.on('open', () => this.open(ws, payload)); 178 | /////////////////////////////////////// 179 | /** 180 | * message event in websocket 181 | */ 182 | ws.on('message', (data) => { 183 | this.message(ws, data, payload); 184 | /** 185 | * get t from data 186 | */ 187 | const { t } = JSON.parse(data.toString()); 188 | 189 | this['nếu'](t, async () => { 190 | // eslint-disable-next-line @typescript-eslint/no-var-requires 191 | try { 192 | const { default: init } = await import( 193 | `../handler/${(t as string).toLowerCase()}` 194 | ); 195 | /** 196 | * call init 197 | */ 198 | init(this, payload); 199 | } catch (err) { 200 | return; 201 | } 202 | }); 203 | }); 204 | 205 | /////////////////////////////////////// 206 | /** 207 | * close event in websocket 208 | */ 209 | 210 | ws.on('close', () => { 211 | setTimeout(() => { 212 | /** 213 | * Connect to gateway 214 | */ 215 | this.active(token); 216 | }, 1000); 217 | }); 218 | } 219 | } 220 | 221 | export { Client }; 222 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | https://discord.gg/MAFzCyY9v5. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /Untitled Diagram.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig to read more about this file */ 4 | 5 | /* Projects */ 6 | // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ 7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ 8 | // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ 9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ 10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ 11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ 12 | 13 | /* Language and Environment */ 14 | "target": "ESNext", 15 | "typeRoots": [ 16 | "packages/typing/globals.d.ts" 17 | ] /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, 18 | // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ 19 | // "jsx": "preserve", /* Specify what JSX code is generated. */ 20 | "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ 21 | "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ 22 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ 23 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ 24 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ 25 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ 26 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ 27 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ 28 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ 29 | 30 | /* Modules */ 31 | "module": "commonjs" /* Specify what module code is generated. */, 32 | // "rootDir": "./", /* Specify the root folder within your source files. */ 33 | // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ 34 | "baseUrl": "./packages/" /* Specify the base directory to resolve non-relative module names. */, 35 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ 36 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ 37 | // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ 38 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */ 39 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 40 | // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ 41 | "resolveJsonModule": true, /* Enable importing .json files. */ 42 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ 43 | 44 | /* JavaScript Support */ 45 | // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ 46 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ 47 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ 48 | 49 | /* Emit */ 50 | // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ 51 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */ 52 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ 53 | // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ 54 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ 55 | "outDir": "./lib" /* Specify an output folder for all emitted files. */, 56 | // "removeComments": true, /* Disable emitting comments. */ 57 | // "noEmit": true, /* Disable emitting files from a compilation. */ 58 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ 59 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ 60 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ 61 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ 62 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 63 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ 64 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ 65 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ 66 | // "newLine": "crlf", /* Set the newline character for emitting files. */ 67 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ 68 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ 69 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ 70 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ 71 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ 72 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ 73 | 74 | /* Interop Constraints */ 75 | // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ 76 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ 77 | "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */, 78 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 79 | "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, 80 | 81 | /* Type Checking */ 82 | "strict": true /* Enable all strict type-checking options. */, 83 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ 84 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ 85 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 86 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ 87 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ 88 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ 89 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ 90 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ 91 | // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ 92 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ 93 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ 94 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ 95 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ 96 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ 97 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ 98 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ 99 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ 100 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ 101 | 102 | /* Completeness */ 103 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ 104 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /lib/discial-api/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig to read more about this file */ 4 | "resolveJsonModule": true, 5 | "esModuleInterop": true, 6 | 7 | /* Projects */ 8 | // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ 9 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ 10 | // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ 11 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ 12 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ 13 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ 14 | 15 | /* Language and Environment */ 16 | "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ 17 | // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ 18 | // "jsx": "preserve", /* Specify what JSX code is generated. */ 19 | // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ 20 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ 21 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ 22 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ 23 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ 24 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ 25 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ 26 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ 27 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ 28 | 29 | /* Modules */ 30 | "module": "commonjs", /* Specify what module code is generated. */ 31 | // "rootDir": "./", /* Specify the root folder within your source files. */ 32 | // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ 33 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ 34 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ 35 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ 36 | // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ 37 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */ 38 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 39 | // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ 40 | // "resolveJsonModule": true, /* Enable importing .json files. */ 41 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ 42 | 43 | /* JavaScript Support */ 44 | // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ 45 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ 46 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ 47 | 48 | /* Emit */ 49 | // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ 50 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */ 51 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ 52 | // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ 53 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ 54 | // "outDir": "./", /* Specify an output folder for all emitted files. */ 55 | // "removeComments": true, /* Disable emitting comments. */ 56 | // "noEmit": true, /* Disable emitting files from a compilation. */ 57 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ 58 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ 59 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ 60 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ 61 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 62 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ 63 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ 64 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ 65 | // "newLine": "crlf", /* Set the newline character for emitting files. */ 66 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ 67 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ 68 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ 69 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ 70 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ 71 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ 72 | 73 | /* Interop Constraints */ 74 | // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ 75 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ 76 | "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ 77 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 78 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 79 | 80 | /* Type Checking */ 81 | "strict": true, /* Enable all strict type-checking options. */ 82 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ 83 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ 84 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 85 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ 86 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ 87 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ 88 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ 89 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ 90 | // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ 91 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ 92 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ 93 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ 94 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ 95 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ 96 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ 97 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ 98 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ 99 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ 100 | 101 | /* Completeness */ 102 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ 103 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 104 | } 105 | } 106 | --------------------------------------------------------------------------------