# ts-discord-wrapper

> A wrapper for the Discord API written in TypeScript

Latest version **0.0.6** (published 2023-10-11) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install ts-discord-wrapper
pnpm add ts-discord-wrapper
yarn add ts-discord-wrapper
bun add ts-discord-wrapper
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2023-10-11 |
| First published | 2023-10-08 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 137.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Yusuf Ismail |
| Maintainers | realyusufismail |
| Keywords | discord, wrapper, typescript, api, discord-api, discord-wrapper, ts-discord-wrapper |

## Links

- npm: https://www.npmjs.com/package/ts-discord-wrapper
- Repository: https://github.com/RealYusufIsmail/TS-Discord-Wrapper
- Homepage: https://github.com/RealYusufIsmail/TS-Discord-Wrapper#readme
- Issues: https://github.com/RealYusufIsmail/TS-Discord-Wrapper/issues
- npm.io page: https://npm.io/package/ts-discord-wrapper

## Dependencies (5)

- [winston](https://npm.io/package/winston.md) ^3.10.0
- [websocket](https://npm.io/package/websocket.md) ^1.0.34
- [ts-color-class](https://npm.io/package/ts-color-class.md) ^0.10.1
- [@types/websocket](https://npm.io/package/@types/websocket.md) ^1.0.7
- [rest-api-handler](https://npm.io/package/rest-api-handler.md) ^2.22.18

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.0.6 (latest) — 2023-10-11
- 0.0.5 — 2023-10-10
- 0.0.4 — 2023-10-10
- 0.0.3-alpha.3 — 2023-10-09
- 0.0.3-alpha.2 — 2023-10-09
- 0.0.3-alpha.1 — 2023-10-09
- 0.0.3 — 2023-10-08
- 0.0.2 — 2023-10-08
- 0.0.1 — 2023-10-08

## README

# TSDiscordWrapper

A simple wrapper for the Discord API written in TypeScript.

## Installation

```bash
npm i ts-discord-wrapper    
```

## Usage

```typescript
import {EventNames} from "ts-discord-wrapper/src/ts/main/ws/util/EventNames.ts";
import {ReadEvent} from "ts-discord-wrapper/src/ts/main/events/core/ReadEvent.ts";
import {TSDiscordWrapper} from "ts-discord-wrapper/src/ts/main/TSDiscordWrapper.ts";
import GateWayIntent from "ts-discord-wrapper/src/ts/main/GateWayIntent.ts";
import {SlashBuilder} from "ts-discord-wrapper/src/ts/main/interactions/slash/SlashBuilder.ts";
import {SlashEvent} from "ts-discord-wrapper/src/ts/main/events/core/interaction/SlashEvent.ts";

const tsDiscordWrapper = new TSDiscordWrapper("TOKEN");

tsDiscordWrapper.login(GateWayIntent.getDefaultIntents()).then(() => {
    tsDiscordWrapper.logger.info("Logged in");
});

tsDiscordWrapper.eventEmitter.on(EventNames.READY, (readEvent: ReadEvent) => {
    tsDiscordWrapper.logger.info("Ready as " + readEvent.getBot().getUsername());
});

tsDiscordWrapper.onReady(() => {
    tsDiscordWrapper.logger.info("Ready");
    new SlashBuilder(tsDiscordWrapper)
        .addSlashCommand("ping", "pong")
        .addSlashCommand("embed", "embed test")
        .build();
});

tsDiscordWrapper.eventEmitter.on(EventNames.INTERACTION_CREATE, (slashCommand : SlashEvent) => {
    if (slashCommand.getInteraction().data.name == "ping") {
        slashCommand.getInteraction().sendReply("pong", false, false);
    } else if (slashCommand.getInteraction().data.name == "embed") {
        let embed = slashCommand.getTSDiscordWrapper()
            .embedBuilder
            .setTitle("Test")
            .setDescription("This is a test")
            .setColor(new Color(0, 255, 0))
            .build()
        slashCommand.getInteraction().sendReplyEmbed(embed, true);
    }
});
```

## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Link to GitHub repo: https://github.com/RealYusufIsmail/TS-Discord-Wrapper

## License
[Apache 2.0](https://choosealicense.com/licenses/apache-2.0/)

---
_Source: https://npm.io/package/ts-discord-wrapper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
