This repository has been archived on 2022-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
brainlet/libbrainlet/test.js

23 lines
779 B
JavaScript
Raw Normal View History

const Client = require('./index');
const main = async () => {
const client = new Client('http://localhost:3000', {
throwErrors: true
});
await client.setToken('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InVzZXIiLCJpYXQiOjE2MDcxNzkyMzAsImV4cCI6MTYwNzE5MDAzMH0.X7KJA-8KmcdwTORXXVZcQTId3iz4_c7H7FYgF2X6nq8');
await client.gatewayConnect();
client.gateway.on('connect', () => {
client.gateway.subscribeToCategoryChat('5fc829314e96e00725c17fd8');
client.gateway.on('message', (e) => {
if (e.author._id === client.user._id) return;
client.gateway.sendMessage('5fc829314e96e00725c17fd8', e.content, {
username: e.author.username
});
});
});
};
main();