How to use hiven - 4 common examples

To help you get started, we’ve selected a few hiven examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hivenapp / hiven.js / examples / basic / bot.js View on Github external
// Modules
const Hiven = require('hiven.js');

const Client = new Hiven.Client();

Client.on('INIT_STATE', () => {
    console.log(`Ready, connected as ${Client.user.username} (${Client.user.id})`);
});

Client.on('MESSAGE_CREATE', msg => {
    console.log(`MSG : [${msg.room.name}@${msg.house.name}] ${msg.author.username}: ${msg.content}`);
});

Client.connect('noTokenForU');
github hivenapp / hiven.js / docs / examples / greeting.js View on Github external
/**
 * A bot that will post in a room when a user joins
 */

// Modules
const Hiven = require('hiven.js');

// Remember to put { clientType: 'user' } in this function call to enable user accounts
const Client = new Hiven.Client();

// This event is emitted when the client successfully authenticates
Client.on('INIT_STATE', () => {
    console.log(`Ready, connected as ${Client.user.username} (${Client.user.id})`);
});

// This event is emitted when a user joins a house
Client.on('HOUSE_MEMBER_JOIN', async member => {
    let room = await Client.rooms.resolve('55494222333080793');

    if (member.house.id !== room.house.id) return;

    console.log(`New member in house ${member.house.name}`);

    room.send(`New member joined: @\`${member.username}\`\nName: \`${member.name}\`\nID: \`${member.id}\``);
});
github hivenapp / hiven.js / docs / examples / ping.js View on Github external
/**
 * A bot that responds Pong when you send ping.
 */

// Modules
const Hiven = require('hiven.js');

// Remember to put { clientType: 'user' } in this function call to enable user accounts
const Client = new Hiven.Client();

// This event is emitted when the client successfully authenticates
Client.on('INIT_STATE', () => {
    console.log(`Ready, connected as ${Client.user.username} (${Client.user.id})`);
});

// This event is emitted when the client receives a message
Client.on('MESSAGE_CREATE', msg => {
    if (msg.content.toLowerCase() == '!ping') {
        msg.room.send('Pong!');
    }
});

// Connect to hiven using a token
Client.connect('token_here');
github hivenapp / hiven.js / docs / examples / messaging.js View on Github external
/**
 * A bot that will show you how to send, update and delete messages
 */

// Modules
const Hiven = require('hiven.js');

// Remember to put { clientType: 'user' } in this function call to enable user accounts
const Client = new Hiven.Client();

// This event is emitted when the client successfully authenticates
Client.on('INIT_STATE', () => {
    console.log(`Ready, connected as ${Client.user.username} (${Client.user.id})`);
});

// This event is emitted when the client receives a message
Client.on('MESSAGE_CREATE', async msg => {
    if (msg.content.toLowerCase() == '!delete') {
        let message = await msg.room.send(`Deleting this message in like 5 seconds`);

        setTimeout(async () => {
            await message.delete();
        }, 5000);
    }

hiven

Hiven.js - TS/JS bot library for Hiven

Apache-2.0
Latest version published 3 years ago

Package Health Score

42 / 100
Full package analysis

Popular hiven functions