Deprecated: Use of "parent" in callables is deprecated in /var/www/html/forum/src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php on line 431
  • If you need help or want to discuss things, you now can also join us on our Discord Server!
  • A first preview of the unlimited version of SinusBot can be found in the Upcoming Changes thread. A version for Windows will follow, but we don't have a release date, yet.

Requesting implementation of the javascript URL-API to the scripting engine.

syscaller

Active Member
Hi, im currently working on API implementations for different platforms like spotify, youtube and google. Ive tried something like this:
JavaScript:
function getOAuthURL(state = "", scope = [], show_diag = false) {
        var redirect = store.get('redirect_uri');
        if (!redirect) throw Error('There is no host saved. Please click on the script-link in the settings.');
        var redirect_uri = new URL(redirect)

        var client_id = config.client_id;
        if (!client_id) throw Error('Please specify a the client_id in the settings');
      
        redirect_uri.searchParams.append('bot',engine.getBotID())
        redirect_uri.searchParams.append('instance',engine.getInstanceID())

        var spotifyURL = new URL('https://accounts.spotify.com/authorize');
        spotifyURL.searchParams.append('client_id',client_id);
        spotifyURL.searchParams.append('response_type','code');
        spotifyURL.searchParams.append('redirect_uri',redirect_uri.href)
        if(state) spotifyURL.searchParams.append('state',state);
        if(scope.length) spotifyURL.searchParams.append('scope',scope.join(' '))
        if(show_diag) spotifyURL.searchParams.append("show_diag", show_diag.toString());

        return  spotifyURL.href;
    }

Which doesn't work right now, because the URL-API is currently not implemented, i guess. Or is there some secret way to import it? Would be nice if this (or some other tool for uri manipulation) could be avaiable in the engine :)
Maybe you can take the implementation from Chromium.
 
Last edited:
Top