# @disploy/ws

Latest version **0.0.1-dev.1670115616-7204cc8.0** (published 2022-12-04) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @disploy/ws
pnpm add @disploy/ws
yarn add @disploy/ws
bun add @disploy/ws
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1-dev.1670115616-7204cc8.0 |
| Published | 2022-12-04 |
| First published | 2022-12-04 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 21.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 30 |
| Maintainers | tristancamejo |

## Links

- npm: https://www.npmjs.com/package/@disploy/ws
- Repository: https://github.com/Disploy/disploy
- Homepage: https://disploy.dev
- Issues: https://github.com/Disploy/disploy/issues
- npm.io page: https://npm.io/package/@disploy/ws

## Dependencies (3)

- [@discordjs/ws](https://npm.io/package/@discordjs/ws.md) ^0.5.0
- [eventemitter3](https://npm.io/package/eventemitter3.md) ^5.0.0
- [discord-api-types](https://npm.io/package/discord-api-types.md) ^0.37.20

## Recent versions

- 0.0.1-dev.1670115616-7204cc8.0 (latest) — 2022-12-04
- 0.0.1-dev.1704413957-78c9477.0 (dev) — 2024-01-05
- 0.0.1-dev.1704370053-78c9477.0 — 2024-01-04
- 0.0.1-dev.1704327580-78c9477.0 — 2024-01-04
- 0.0.1-dev.1704283655-78c9477.0 — 2024-01-03
- 0.0.1-dev.1704241149-78c9477.0 — 2024-01-03
- 0.0.1-dev.1704197239-78c9477.0 — 2024-01-02
- 0.0.1-dev.1704154753-78c9477.0 — 2024-01-02
- 0.0.1-dev.1704110851-78c9477.0 — 2024-01-01
- 0.0.1-dev.1704068522-78c9477.0 — 2024-01-01
- 0.0.1-dev.1704024405-78c9477.0 — 2023-12-31
- 0.0.1-dev.1703982063-78c9477.0 — 2023-12-31
- 0.0.1-dev.1703938000-78c9477.0 — 2023-12-30
- 0.0.1-dev.1703895496-78c9477.0 — 2023-12-30
- 0.0.1-dev.1703851599-78c9477.0 — 2023-12-29
- … 795 more at https://npm.io/package/@disploy/ws/versions

## README

<div align="center">
	<br />
	<p>
		<a href="https://disploy.dev"><img src="https://disploy.dev/img/logo.svg" alt="disploy" width="200" /></a>
	</p>
    <p>
		<a href="https://vercel.com/?utm_source=disploy&utm_campaign=oss"><img src="https://www.datocms-assets.com/31049/1618983297-powered-by-vercel.svg" alt="Vercel" /></a>
	</p>
    <h3>
        @disploy/ws
    </h3>
	<br />
	<p>
		<a href="https://discord.gg/E3z8MDnTWn"><img src="https://img.shields.io/discord/901426442242498650?color=5865F2&logo=discord&logoColor=white" alt="Disploy's Discord server" /></a>
	</p>

</div>

## Overview

`@disploy/ws` is a WebSocket extension for Disploy. It is used to communicate with the Discord gateway.
This allows you to receive events from Discord and utilize `@discordjs/voice`.

## Workflow

```ts
import { Gateway } from '@disploy/ws';
import { GatewayIntentBits } from 'discord-api-types/v10';
import { App, expressAdapter } from 'disploy';
import express from 'express';

// Handle environment variables
const clientId = process.env.DISCORD_CLIENT_ID;
const token = process.env.DISCORD_TOKEN;
const publicKey = process.env.DISCORD_PUBLIC_KEY;

if (!clientId || !token || !publicKey) {
	throw new Error('Missing environment variables');
}

// Setup Discord application
const app = new App();

app.start({
	clientId,
	token,
	publicKey,
});

// Setup gateway connection
app.ws = new Gateway(app, {
	intents: GatewayIntentBits.MessageContent | GatewayIntentBits.GuildMessages,
});

// Example event listener
app.ws.on('messageCreate', (message) => {
	if (message.content === 'ping') {
		message.reply({
			content: 'pong',
		});
	}
});

// Setup interaction server
const interactionServer = express();

interactionServer.use(express.json());
expressAdapter(app, interactionServer);

interactionServer.listen(3000, () => {
	console.log('[interaction server] Listening on port 3000');
});

// Connect to gateway
app.ws.connect();

// Types
declare module 'disploy' {
	interface App {
		ws: Gateway;
	}
}
```

You can find more examples in the [example bot](https://github.com/Disploy/disploy/tree/main/apps/example) including the usage of `@discordjs/voice`.

## Need Help?

https://discord.gg/E3z8MDnTWn - Join our Discord server for support and updates!

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