trexton
v1.1.0
Published
A free and powerful library to connect and interact with the Trexton API
Downloads
3
Readme
About
The Trexton API is a Node.js library that provides access to connect to the Trexton API.
Simple Quick Start
const Trexton = require(`trexton`);
const client = new Trexton.Client({ token: "xxx-xxx-xxx-xxx" });
client.init({
activity: "ONLINE",
status: "Hello world!"
});
client.once('login', (SCT) => {
console.log(`The bot has connected to Trexton in ${SCT}ms!`);
});
client.on("message", (message) => {
console.log(`New message from ${message.user.username}: ${message.data.content}`);
});
Installation
$ npm i trexton
Getting your API key
Currently there is no way available to get your API key. Your best bet is to ask for one in our Trexton Discord server.
Usage
const Trexton = require('trexton');
const client = new Trexton.Client({ token: "YOUR_API_KEY"});
Trexton API is highly inspired by Discord.js, so if your fimiliar with Discord.js, this should be a breeze for you.
Start your bot!
This step is important, as without the initiation, your bot will not start.
const myActivities = ["ONLINE", "DND", "STREAMING", "OFFLINE", "IDLE", "GAMING"]
const myStatus = "Hello world!";
client.init({
activity: myActivities[0], // Optional, defaults to ONLINE.
status: myStatus // Optional.
})
Have I logged in?
client.once('login', (serverConnectionTime) => {
console.log(`The bot has connected to Trexton in ${serverConnectionTime}ms!`);
});
Or have I logged out?
client.once('logout', () => {
console.log(`The bot is now offline.`);
});
Messages!
client.on("message", (message) => {
console.log(`New message from ${message.user.username} in ${message.channel.name} at ${message.data.sendTime}: ${message.data.content}`);
});