cura-app.js
v1.0.3
Published
The official api wrapper for cura-app.tk
Downloads
9
Readme
Cura-app.js, API Wrapper for cura-app.tk
The official api wrapper for cura-app.tk
Functionality
- [X] Events
- [X] Login
- [X] Invite Generator
- [X] Internal Command Handler
- [X] Send, reply to messages
- [X] Emulate Typing
Modify for use with your copy of CuraApp
Before logging in do client.socketUrl = "wss://example.com"
In the case of use with the official cura-app.tk this is not required!
Syntax
client.login(token)
This is required to login to the client
let Cura = require("cura-app.js");
let client = new Cura();
client.login("xb:------------");
client.command(options)
This is used for the internal command handler, easy for beginners.
client.command({ //!ping returns Pong!
name: "ping",
message: "Pong!"
})
client.command({
name: "echo",
run: (message, args) => { //Run functions using run you can get message object and args
message.startTyping(); //Start typing
message.reply(args.join(" ")); //Reply with all arguments
}
})
client.send(content, guildId, channelId)
Send a message to a channel
client.send("Hello there", "e8ef0db5-bdf6-4624-b22b-7b85928bfcec", "fee5fceb-f7fd-42bf-96e8-dc8daefa6fa2")
client.typeStart(channelId, guildId)
Start typing.
client.typeStart("e8ef0db5-bdf6-4624-b22b-7b85928bfcec", "fee5fceb-f7fd-42bf-96e8-dc8daefa6fa2");
client.typeStop(channelId, guildId)
Start typing.
client.typeStop("e8ef0db5-bdf6-4624-b22b-7b85928bfcec", "fee5fceb-f7fd-42bf-96e8-dc8daefa6fa2");
Events
ready
When the bot is ready and connected to ws.
client.on("ready", (raw)=>{})
(returns raw data)
message
When you recieve a message in a guild
client.on("message", (MessageObject)=>{})
(returns MessageObject)
typingStart
When someone starts typing
client.on("typingStart", (data)=>{data.username})
(returns username)
Do note that you will have to handle if no typing event for 5 seconds stop typing, this event also gets sent every keystroke
typingStop
When someone stops typing
client.on("typingStop", (data)=>{data.username})
(returns username)
Objects
MessageObject
{
id: 'messageId',
guild: boolean,
guildObject: guildObject,
channel: channelObject,
author: userObject,
content: 'messageContent',
str: null,
html: 'messageHtml',
member: userObject,
bot: boolean,
startTyping: MessageObject.stopTyping(),
stopTyping: MessageObject.startTyping(),
reply: MessageObject.reply(content)
}
GuildObject
{
id: 'guildId',
name: 'guildName'
}
UserObject
{
id: 'userId',
username: 'userName',
badges: { mod: boolean, bot: { is: boolean, verified: boolean } },
bot: boolean
}
ChannelObject
{
name: 'channelName',
id: 'channelId'
}
Internal Variables
client.rooms
A variable with all dm's/guilds
[GuildID, GuildID]
client.token
The client's token
xb:-------
client.socketUrl
URL of socket to connect to
wss://cura-app.tk
client.prefix
Prefix for internal command handler
!
client.ready
Is the client ready
boolean
Examples
Echo Command
let Cura = require("cura-app.js");
let client = new Cura();
client.on("ready", (data) => {
console.log("Your bot is now online!");
})
client.command({
name: "echo",
run: (message, args) => {
message.startTyping();
message.reply(args.join(" "));
}
})
client.login(``);