1.1.7 • Published 3 years ago

voltra.api v1.1.7

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Voltra.api

Refrences

const voltraApi = require('voltra.api'); // import the package
const api = new voltraApi.client('SID TOKEN'); // Initiate the bot
api.socket.onMessage('CHANNEL ID', async (msg) => { // Open a websocket to receive messages from a channel
    // ...
});
const userObj = await api.socket.getUser('USERID'); // Get the user object
api.joinGuild('guildid'); // Join a guild
api.socket.sendMessage('messagecontent', false); // set to true to send a message type of 100
api.changeSettings('newusername', 'avatarurl')
api.socket.me // EXPERIMENTAL: Gives the bot's user object.

Examples

Simple bot connected to multiple channels:

const voltra = require('voltra.api');
const api = new voltra.client('BOT_TOKEN');
const prefix = '!';

(async () => {
    async function joinGuild(id){ // join guild function (Callable)
        return await api.joinGuild(id); 
    }
    api.socket.onMessage('channel1', async (message) => { // Provide a channel id here to connect and receive messages
        console.log(`${message.author.username}:`, message.string)

        if(!message.string.startsWith(prefix) || message.author.bot) return;
        const args = message.string.slice(prefix.length).trim().split(' ');
        const command = args.shift().toLowerCase();

        if(command == 'commandname'){
           // ...
        }
    });

    api.socket.onMessage('channel2', async (message) => { // Provide a channel id here to connect and receive messages
        console.log(`${message.author.username}:`, message.string)

        if(!message.string.startsWith(prefix) || message.author.bot) return;
        const args = message.string.slice(prefix.length).trim().split(' ');
        const command = args.shift().toLowerCase();

        if(command == 'commandname'){
           // ...
        }
    });
})()

OAuth

const oauth = new voltra.oauth(); // new client
const user = await oauth.authorize(); // authorize user by token
console.log('OAuth >', user) // log user
1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago