all repos — kitten @ 7069b00b3a14cefdd48236a2ad08cb3377011751

pkgs/gateway/README.md (view raw)

 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
# @purrkit/gateway

```ts
import { Gateway } from "@purrkit/gateway";

const Intents = {
	GUILDS: 1 << 0,
	GUILD_MESSAGES: 1 << 9,
	MESSAGE_CONTENT: 1 << 15,
};
const intents = Intents.GUILDS | Intents.GUILD_MESSAGES | Intents.MESSAGE_CONTENT;
const gateway = Gateway({
	token: "...",
	intents: intents,
});

gateway.on("READY", (data) => {
	console.log(`logged in: ${data.user.username}`); // data: GatewayReadyDispatchData
});

gateway.once("MESSAGE_CREATE", (message) => {
	console.log(`first message caught: ${message.content}`); // message: MessageResponse
});

gateway.connect();
```