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

24 lines
842 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.eyJ1c2VybmFtZSI6InVzZXIiLCJpYXQiOjE2MDcxOTE5NjAsImV4cCI6MTYwNzIwMjc2MH0.dfI6CMeDNck-ubqwEmiMFdHbRR4iiuooeTuzgVc_8rY');
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, {
nickAuthor: {username: e.author.username},
//destUser: {_id: e.author._id}
});
});
});
};
main();