Skip to content

Commit 6c8591e

Browse files
committed
docs: fix stale pre-v4 examples (on('message')→'text', msg.text()→ctx.text, on('connection')→'connect')
1 parent 37826a7 commit 6c8591e

6 files changed

Lines changed: 12 additions & 12 deletions

File tree

docs/content/api-reference.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ const client = new Client({
3131
qrTerminal: true,
3232
})
3333

34-
client.on('connection', (s) => console.log(s.status))
35-
client.on('message', (msg) => {
36-
if (msg.text() === 'ping') client.send(msg.chatId()).text('pong')
34+
client.on('connect', ({ me }) => console.log('connected as', me.id))
35+
client.on('text', (ctx) => {
36+
if (ctx.text === 'ping') ctx.reply('pong')
3737
})
3838
```
3939

@@ -185,8 +185,8 @@ client
185185
Inbound event payloads and helpers. See [Events](/events).
186186

187187
```typescript
188-
client.on('message', (msg) => console.log(msg.text(), msg.chatId()))
189-
client.on('call', (call) => console.log(call))
188+
client.on('text', (ctx) => console.log(ctx.text, ctx.senderId))
189+
client.on('call-incoming', (call) => console.log(call))
190190
```
191191

192192
| Export | Kind | Description |

docs/content/client.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ const client = new Client() // connects automatically
172172

173173
// These run on the same tick, before the queued connect() fires
174174
client.on('qr', ({ qrString }) => console.log(qrString))
175-
client.on('message', (ctx) => console.log(ctx.text))
175+
client.on('text', (ctx) => console.log(ctx.text))
176176
```
177177

178178
If auto-connect fails, the client logs the error and emits an `'error'` event **only if** you have

docs/content/rich-responses.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ await client.send(jid).text(
172172
'',
173173
'const client = new Client()',
174174
'',
175-
"client.on('message', async (msg) => {",
175+
"client.on('text', async (msg) => {",
176176
" await client.send(msg.senderId).text('hi')",
177177
'})',
178178
'```',

docs/content/runtimes.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ That means both styles are first-class — pick whichever matches your project:
6262
phoneNumber: 628000000000,
6363
})
6464

65-
client.on('connection', ({ status }) => console.log(status))
65+
client.on('connect', ({ me }) => console.log('connected as', me.id))
6666
await client.connect()
6767
```
6868
</Tabs.Tab>
@@ -75,7 +75,7 @@ That means both styles are first-class — pick whichever matches your project:
7575
phoneNumber: 628000000000,
7676
})
7777

78-
client.on('connection', ({ status }) => console.log(status))
78+
client.on('connect', ({ me }) => console.log('connected as', me.id))
7979
client.connect()
8080
```
8181
</Tabs.Tab>

docs/content/sending-messages.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,8 @@ const key = await client.send(to).text('Original')
314314
await client.send(to).text('A reply').reply(key)
315315

316316
// inside a handler, you typically already have the full message:
317-
client.on('message', async (msg) => {
318-
await client.send(msg.chat.id).text('got it').reply(msg)
317+
client.on('text', async (ctx) => {
318+
await client.send(ctx.senderId).text('got it').reply(ctx.message())
319319
})
320320
```
321321

examples/airich-bot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const showcase = async (target: string): Promise<void> => {
5050
'',
5151
'const client = new Client()',
5252
'',
53-
"client.on('message', async (msg) => {",
53+
"client.on('text', async (msg) => {",
5454
' await client.send(msg.senderId).buttons(',
5555
" [{ id: 'yes', text: 'Ya' }, { id: 'no', text: 'Tidak' }],",
5656
" { text: 'Lanjut order?' },",

0 commit comments

Comments
 (0)