Skip to content

Commit

Permalink
docs: Translated example code (#2226)
Browse files Browse the repository at this point in the history
  • Loading branch information
gekkedev authored Jul 18, 2024
1 parent 5a2239d commit 91b2c40
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion docs/getting-started/configuring-logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const files = new winston.transports.File({ filename: 'combined.log' });
wppconnect.defaultLogger.add(files); // Add file transport

//Optional: create a custom console with error level
const console = new winston.transports.Console({ level: 'erro' });
const console = new winston.transports.Console({ level: 'error' });
wppconnect.defaultLogger.add(console); // Add console transport

//Optional: Remove the custom transport
Expand Down
4 changes: 4 additions & 0 deletions docs/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The first thing that you had to do is install the `npm package`:
```bash
npm i --save @wppconnect-team/wppconnect
```
or with Yarn:
```bash
yarn add @wppconnect-team/wppconnect
```

or for [Nightly releases](https://github.com/wppconnect-team/wppconnect/releases/tag/nightly):

Expand Down
6 changes: 3 additions & 3 deletions docs/getting-started/receiving-messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ function start(client) {
client
.sendText(message.from, 'Hello, how I may help you?')
.then((result) => {
console.log('Result: ', result); //return object success
console.log('Result: ', result); //return success object
})
.catch((erro) => {
console.error('Error when sending: ', erro); //return object error
.catch((error) => {
console.error('Error when sending: ', error); //return error object
});
}
});
Expand Down
10 changes: 5 additions & 5 deletions examples/basic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ const wppconnect = require('../../dist');
wppconnect
.create()
.then((client) => start(client))
.catch((erro) => {
console.log(erro);
.catch((error) => {
console.log(error);
});

function start(client) {
client.onMessage((message) => {
if (message.body === 'Hi' && message.isGroupMsg === false) {
client
.sendText(message.from, 'Welcome Wppconnect')
.sendText(message.from, 'Welcome to Wppconnect')
.then((result) => {})
.catch((erro) => {
console.error('Error when sending: ', erro); //return object error
.catch((error) => {
console.error('Error when sending: ', error); //return error object
});
}
});
Expand Down
20 changes: 10 additions & 10 deletions examples/bot-functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const wppconnect = require('../../dist');

wppconnect
.create({
session: 'teste',
session: 'test',
onLoadingScreen: (percent, message) => {
console.log('LOADING_SCREEN', percent, message);
},
Expand Down Expand Up @@ -84,30 +84,30 @@ function start(client) {
await client.setChatState(msg.from, '2');
}
} else if (msg.body.startsWith('!btn')) {
await client.sendMessageOptions(msg.from, 'teste', {
title: 'CALÇA JEN FEMININA',
footer: 'Escolha uma opção abaixo',
await client.sendMessageOptions(msg.from, 'test', {
title: "WOMEN'S JEANS PANTS",
footer: 'Choose an option below',
isDynamicReplyButtonsMsg: true,
dynamicReplyButtons: [
{
buttonId: 'idSim',
buttonId: 'idYes',
buttonText: {
displayText: 'SIM',
displayText: 'YES',
},
type: 1,
},
{
buttonId: 'idNao',
buttonId: 'idNo',
buttonText: {
displayText: 'NÃO',
displayText: 'NO',
},
type: 1,
},
],
});
}
} catch (e) {
console.log(e);
} catch (error) {
console.log(error);
}
});
}
6 changes: 3 additions & 3 deletions examples/newsletter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ const wppconnect = require('../../dist');

wppconnect
.create({
session: 'teste',
session: 'test',
})
.then((client) => start(client))
.catch((erro) => {
console.log(erro);
.catch((error) => {
console.log(error);
});

function start(client) {
Expand Down
6 changes: 3 additions & 3 deletions examples/orders/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const froms = [];
wppconnect
.create()
.then((client) => start(client))
.catch((erro) => {
console.log(erro);
.catch((error) => {
console.log(error);
});

function start(client) {
Expand All @@ -33,7 +33,7 @@ function start(client) {
froms.push(message.from);
client.sendText(
message.from,
`Please, save your order id, and get order for test porpouse`
`Please save your order ID, and get your order for testing purposes`
);
client.sendText(message.from, `${order.id}`);
}
Expand Down

0 comments on commit 91b2c40

Please sign in to comment.