docs: Update example usage (#9461)

This commit is contained in:
Jiralite
2023-04-27 19:28:44 +01:00
committed by GitHub
parent b2e1bb92d0
commit 6212bffa30

View File

@@ -39,14 +39,15 @@ import { GatewayDispatchEvents, GatewayIntentBits, InteractionType, MessageFlags
// Create REST and WebSocket managers directly
const rest = new REST({ version: '10' }).setToken(token);
const ws = new WebSocketManager({
const gateway = new WebSocketManager({
token,
intents: GatewayIntentBits.GuildMessages | GatewayIntentBits.MessageContent,
rest,
});
// Create a client to emit relevant events.
const client = new Client({ rest, ws });
const client = new Client({ rest, gateway });
// Listen for interactions
// Each event contains an `api` prop along with the event data that allows you to interface with the Discord REST API
@@ -62,7 +63,7 @@ client.on(GatewayDispatchEvents.InteractionCreate, async ({ data: interaction, a
client.once(GatewayDispatchEvents.Ready, () => console.log('Ready!'));
// Start the WebSocket connection.
ws.connect();
gateway.connect();
```
## Independent REST API Usage