Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
feat: initial structure
Browse files Browse the repository at this point in the history
  • Loading branch information
twlite committed Aug 21, 2021
1 parent c5afcc1 commit 756ea15
Show file tree
Hide file tree
Showing 13 changed files with 358 additions and 240 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ dist/
.github/
docs/
coverage/
test/

*.d.ts
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ coverage/
dist/
.vscode/
yarn.lock
package-lock.json
package-lock.json
test/
62 changes: 47 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,47 @@
# TypeScript Template
Template for TypeScript projects

# Included
- eslint
- unit test
- prettier
- typescript declaration files bundler
- es modules generator
- husky pre-commit
- github actions:
- CodeQL
- ESLint
- Auto `npm publish` on release creation
- Stale action
# DartJS

DartJS is a Discord.js framework that aims to provide similar voice interface of Discord.js v12.

# Installation

```sh
$ npm i --save dartjs
```

> You may need to install encryption library and opus engine as well.
# Why?

This library was created just for learning purpose. There is no point of using this library unless you really have to :D

# Example

```js
const Discord = require("discord.js");
const client = new Discord.Client({
intents: [Discord.Intents.GUILDS, Discord.Intents.GUILD_VOICE_STATES, Discord.Intents.GUILD_MESSAGES]
});
const { DartVoiceManager } = require("dartjs");
const voiceManager = new DartVoiceManager(client);
const ytdl = require("ytdl-core");

client.on("ready", () => console.log("Bot is online!"));

client.on("messageCreate", message => {
if (message.author.bot) return;

if (message.content === "!play") {
voiceManager.join(message.member.voice.channel)
.then(connection => {
const dispatcher = connection.play(ytdl("https://www.youtube.com/watch?v=dQw4w9WgXcQ"));
dispatcher.on("start", () => message.channel.send("Music started!"));
dispatcher.on("finish", () => {
connection.disconnect();
message.channel.send("Music finished!");
});
});
}
});

client.login("XXX");
```
5 changes: 0 additions & 5 deletions __tests__/example.spec.ts

This file was deleted.

3 changes: 0 additions & 3 deletions babel.config.js

This file was deleted.

194 changes: 0 additions & 194 deletions jest.config.ts

This file was deleted.

42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@devsnowflake/typescript-template",
"name": "dartjs",
"version": "1.0.0",
"description": "Template for TypeScript projects",
"description": "Very simple framework that provides discord.js v12 voice interface",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
Expand All @@ -18,43 +18,43 @@
"build:esm": "gen-esm-wrapper ./dist/index.js ./dist/index.mjs",
"lint": "eslint src --ext .ts",
"lint:fix": "eslint src --ext .ts --fix",
"bumpdeps": "npm-check-updates -u",
"bump": "npx npm-check-updates -u",
"format": "prettier --write src/**/*.{ts,js,json,yaml,yml}",
"prepublishOnly": "rollup-type-bundler -e stream",
"test": "jest"
"prepublishOnly": "rollup-type-bundler -e stream"
},
"repository": {
"type": "git",
"url": "git+https://github.com/DevSnowflake/typescript-template.git"
"url": "git+https://github.com/DevSnowflake/dartjs.git"
},
"keywords": [
"typescript-template",
"template",
"project"
"dartjs",
"discord",
"voice",
"v12"
],
"author": "Snowflake Studio ❄️",
"author": "DevAndromeda",
"license": "MIT",
"bugs": {
"url": "https://github.com/DevSnowflake/typescript-template/issues"
"url": "https://github.com/DevSnowflake/dartjs/issues"
},
"homepage": "https://github.com/DevSnowflake/typescript-template#readme",
"devDependencies": {
"@babel/core": "^7.15.0",
"@babel/preset-env": "^7.15.0",
"@babel/preset-typescript": "^7.15.0",
"@favware/rollup-type-bundler": "^1.0.3",
"@types/jest": "^26.0.24",
"@types/node": "^16.4.13",
"@typescript-eslint/eslint-plugin": "^4.29.0",
"@typescript-eslint/parser": "^4.29.0",
"@types/node": "^16.7.1",
"@typescript-eslint/eslint-plugin": "^4.29.2",
"@typescript-eslint/parser": "^4.29.2",
"discord.js": "^13.1.0",
"eslint": "^7.32.0",
"gen-esm-wrapper": "^1.1.2",
"husky": "^7.0.1",
"jest": "^27.0.6",
"npm-check-updates": "^11.8.3",
"opusscript": "^0.0.8",
"prettier": "^2.3.2",
"rimraf": "^3.0.2",
"ts-node": "^10.1.0",
"ts-node": "^10.2.1",
"tweetnacl": "^1.0.3",
"typescript": "^4.3.5"
},
"dependencies": {
"@discordjs/voice": "^0.6.0"
}
}
16 changes: 16 additions & 0 deletions src/Utils/Util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export function catchError<T>(promiseLike: () => Promise<T>): Promise<[Error, T]> {
return new Promise((resolve) => {
promiseLike().then(
(d) => resolve([null, d]),
(e) => resolve([e, null])
);
});
}

export function noop() {} // eslint-disable-line @typescript-eslint/no-empty-function

export function wait(duration: number) {
return new Promise((resolve) => {
setTimeout(resolve, duration).unref();
});
}
Loading

0 comments on commit 756ea15

Please sign in to comment.