1.0.4-2 • Published 2 years ago

faceit-bot v1.0.4-2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

PacketName

Implement the functionality of the Faceit Chat Websocket, Main Websocket and Api into one library

Installation

npm install <packetName>

Chat:

Methods:

chat.mute(chatId,userId,length) //-> Mutes the specified user in the chat (Needs to be a Hub/tournament chat)
chat.message(chatId,type,message,DM?) // => Sends a message in the specified chat
chat.delete(chatId,messageId) // => Deletes a message in the specified chat, 
                                  //ID only retreivable through events (implemented) / Chat API (Not implemented)

Events

chat.on("chatMessage", (data: MessageReceivedModel) => {
    //Do something
})

Example

import {createChatSocket,ChatSocket} from "<packetName>";

//Create socket and log in automatically
const chat = await createChatSocket("faceit name | faceit id", "Faceit Bearer");

//or

//Create socket and login manually
const chat = new ChatSocket();
await chat.connect("Faceit id", "Faceit Bearer");

//Subscribe to a chat
await chat.presence("hub | match","chat id")

//Handle events
chat.on("chatMessage", (messageData) => {
    if(messageData.self) return
    chat.message(
        messageData.from.id,
        messageData.from.type,
        "Hey! I received your message!"
    );
}

FACEIT Edge:

Methods:

edge.presence("hub_admin | hub_public | room | queue | public", id); // -> Subscribe to an entity

Events

edge.on("ticketUpdate", (ticketData: TicketUpdatedModel) => void)
edge.on("matchUpdate", (matchData: MatchUpdateModel) => void)
edge.on("playerQueueingUpdate", (playerData: QueueingPlayersModel) => void)
edge.on("matchCountUpdate", (matchCountData: HubLiveMatchesModel) => void)

Example

import {createEdgeSocket,EdgeSocket} from "packetName";

//Create socket and log in automatically
const edge = await createEdgeSocket("faceitName | faceitId", "Faceit Bearer");

//or

//Create socket and login manually
const edge = new EdgeSocket();
await socket.connect("FaceitId", "Faceit Bearer");

//Subscribe to an entity
await edge.presence("queue",queueId);
await edge.presence("hub_admin",hubId)
//Handle events
edge.on("playerQueueingUpdate", (playerData) => {
    console.log(`Hey cool, someone just joined/left the queue, we now have ${playerData.entity.count} players queueing`)
});
edge.on("ticketUpdate",(ticket) => {
    if(ticket.entity.status === "open") {
        console.log("Watch out admins! There is a new ticket which needs attention!")
    }
})

API

Methods:

import {Api} from "./Api";

API.getUserData(userName) // -> Get userdata
API.getMatchData(matchId) // -> Get matchdata
API.getMatches(competitionId, competitionType, [states], limit, offset) //Get all matches matching the state from the competition

API.getMatchHistory(playerId, limit, offset, filter) //Get a players matchhistory matching the filter
API.getVoteHistory(matchId) //Get details about the voting in the match

API.getTickets(competitionId,competitionType,ticketStatus) //Get all tickets matching the status
API.getTicket(ticketId) //Get more information about a certain ticket

API.getCompetitions(userId,competitionType,status) //Get all hubs or tournaments of a player
API.getChatUsers(competitionId,type) //Get all users who are connected to a hub or tournament chat -> Close to all Hub/Tournament members

API.getOngoingMatchCount(competitionId, competitionType) //Get the amount of ongoing games
API.getPlayersQueueing(queueId,limit) //Get amount and info of players queueing in a hub

API.getLeaderboard(hubId,leaderboardType,leaderboardId,limit,offset) //Get leaderboard settings and rankings 

Example

import {API} from "packetName"

const user = await API.getUserData("faceitName")
//Do something with the users data


const match = await API.getMatchData("matchId")
//Do something with the matchId

//And many more methods

License

MIT