replchat.js
Advanced tools
Comparing version 1.1.1 to 1.1.2
39
index.js
@@ -6,2 +6,3 @@ const EventEmitter = require('events').EventEmitter | ||
constructor() { | ||
// Construct Client | ||
super() | ||
@@ -14,3 +15,5 @@ | ||
// Client Functions | ||
send(message) { | ||
// Send Message to replchat | ||
this.socket.emit('chat message', { message }) | ||
@@ -20,2 +23,3 @@ } | ||
login(auth) { | ||
// Authenticate with replchat | ||
this.socket = io(`https://replchat.vapwastaken.repl.co/`, { | ||
@@ -49,3 +53,3 @@ transports: ["websocket"], | ||
}) | ||
this.socket.on('banned', () => { | ||
@@ -64,15 +68,26 @@ this.emit('error', { | ||
this.socket.on('chat message', (data) => { | ||
this.emit('message', { | ||
author: { | ||
username: data.username, | ||
avatar: data.pfp | ||
}, | ||
content: data.message, | ||
reply: (content) => { | ||
var message = `Replying to @${data.username} (${data.message}): ${content}` | ||
this.send(message) | ||
} | ||
}) | ||
var message = new Message(this, data) | ||
this.emit('message', message) | ||
}) | ||
} | ||
} | ||
class Message { | ||
constructor(client, data) { | ||
// Construct Message | ||
this.author = { | ||
username: data.username, | ||
avatar: data.pfp | ||
} | ||
this.content = data.message | ||
this.client = client | ||
} | ||
// Message Functions | ||
reply(content) { | ||
var message = `Replying to @${this.author.username} (${this.content}): ${content}` | ||
this.client.send(message) | ||
} | ||
} |
{ | ||
"name": "replchat.js", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "A library for making bots with replchat (https://replchat.vapwastaken.repl.co/)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -65,3 +65,3 @@ # About | ||
## Events | ||
Currently there are 10 events, they are as follows: | ||
Currently there are 6 events, they are as follows: | ||
- 'connected': called when the bot has connected | ||
@@ -72,5 +72,5 @@ - 'ready': called when the bot is connected and ready | ||
- 'joined': called when a user joins | ||
- 'refreshed': called when `admin.refreshall` is called | ||
- 'announcement': called when an announcement is made | ||
- 'error': used when an error occurs (such as the bot was banned or kicked) | ||
- 'debug': not currently used by replchat | ||
## Docs | ||
Documentation is coming soon! Util then, hold on while we work on it! |
5350
72