• If you need help or want to discuss things, you now can also join us on our Discord Server!
  • Happy New Year everyone! A new version (1.0.0-beta.16) is out for Linux, fixing an issue that could lock the bot up when using it with TS3. Please visit the resources section or the main page (https://www.sinusbot.com) for the new package.
Discord Voice State

Discord Discord Voice State 2.0.0

No permission to download
Required SinusBot Version
1.0
Compatible Backends
  1. Discord
Voice State

This plugin caches the voicestate of a webuser and checks if the bot is in the same channel as the webuser.


API Call: POST {URL}/api/v1/bot/i/{instance_id}/event/voicestate (You must be logged in)

NotLoggedIn: "You are not logged in"
NotBound: "This account is not bound to a discord user"
UserNotConnected: "You are not connected"
NotConnected: "The bot is not connected" (Unused atm)
NotSameChannel: "You are not in the same channel with the bot"

JavaScript:
function isConnectedToVoice(instance, response) {
    $.ajax({
        url: 'http://127.0.0.1:8087/api/v1/bot/i/' + instance + '/event/voicestate',
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
            'Authorization': 'bearer ' + window.localStorage.token
        }
    }).done(function (data) {
        if (data.length == 0) {
            console.log("Voice API Error: We did not received data!");
            response(false);
            return;
        }
        if (data[0].success) {
            response(data[0].success);
        } else {
            console.log("Voice Error: " + data[0].data);
            response(data[0].success);
        }
    });
}

isConnectedToVoice("instance-uid", function(result) {
    if(result) {
        alert("Everything okay");
        // Do stuff
    } else {
        alert("Something went wrong. See console log.");
    }
});

JavaScript:
var store = require('store');
var event = require('event');

event.on('chat', ev => {
    let channel_id = store.getGlobal('voicestate-' + ev.user().uid().split("/").pop());
    if (channel_id != null) {
        // Do stuff with channel_id
    }
});

Error JSON:

JSON:
[
    {
        "data": "Error",
        "success": false
    }
]

Success JSON:
JSON:
[
    {
        "data": {
            "channel": "809889361767956551",
            "connected": true,
            "user": "199858858166976513"
        },
        "success": true
    }
]


1623708297457.png
1623708303454.png
Author
Lala Sabathil
Downloads
38
Views
1,520
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from Lala Sabathil

Top