Connect to Glimesh's chat servers with ease!
Using this package is very simple:
import { GlimeshChat } from "glimesh-chat"
const chat = new GlimeshChat({ token: "<MY TOKEN HERE>" })
chat.connect("<MY CHANNEL HERE>").then((meta) => {
chat.on("message", msg => {
console.log(msg)
chat.sendMessage("Wow! I got your message!")
})
})
const Glimesh = require("glimesh-chat")
const chat = new Glimesh.GlimeshChat({ token: "<MY TOKEN HERE>" })
chat.connect("<MY CHANNEL HERE>").then(meta => {
chat.on("message", msg => {
console.log(msg)
chat.sendMessage("Wow! I got your message!")
})
})
And that's it! This will automatically start the heartbeat loop to keep the connection alive. It is your application's responsibility to handle authentication token refreshing.
You can then later disconnect with await chat.close()
For these examples, assume that you're already connected to the chat servers, like the previous examples, with the chat
variable.
// Ban
await chat.banUser(userId)
// Unban
await chat.unbanUser(userId)
Short timeout on Glimesh is defined as a 5 minute timeout and a long timeout is 15 minutes.
await chat.shortTimeout(userId)
await chat.longTimeout(userId)
Got a custom payload to send? Use this!
await chat.send([ packet: "data", here: true ])
const id = await chat.getUserId("usernameHere")
const id = await chat.getChannelId("usernameHere")
const mods = await chat.getModerators("usernameHere")
mods.forEach(mod => {
console.log(`user: ${mod.id} can ban ${mod.canBan} can long timeout ${mod.canLongTimeout} can short timeout ${mod.canShortTimeout} can untimeout ${mod.canUnTimeout}`)
})