Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

Commit

Permalink
Version 3.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Paultje52 committed Feb 21, 2019
1 parent 0ee90e3 commit a495b35
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bananenbase",
"version": "3.0.2",
"version": "3.0.3",
"description": "Thé discord.js AND express framework!",
"main": "src/index.js",
"dependencies": {
Expand Down
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,10 @@ exports = module.exports = class BananenBase {
res.sendDiscordLogin = (options) => {
if (!options) return error("No options for the send discord login!");
if (!options.clientID || !options.redirect) return error("Invalid options object!");
options.scope = ["identify", "email", "guilds"];
if (!options.scope) options.scope = [];
["identify", "email", "guilds"].forEach(thing => {
if (!options.scope.includes(thing)) options.scope.push(thing);
});
return res.redirect(`https://discordapp.com/api/oauth2/authorize?client_id=${options.clientID}&redirect_uri=${encodeURIComponent(options.redirect)}&response_type=code&scope=${options.scope.join("%20")}`);
}
res.handleDiscordLogin = (options) => {
Expand All @@ -278,6 +281,7 @@ exports = module.exports = class BananenBase {
packages.request({url: "http://discordapp.com/api/users/@me", json: true, auth: {bearer: json.access_token}}, (err, response, body) => {
if (err) return reject(err);
packages.tmp = body;
packages.tmp.accesToken = json.access_token;
packages.request({url: "http://discordapp.com/api/users/@me/guilds", json: true, auth: {bearer: json.access_token}}, (err, response, b) => {
if (err) return reject(err);
packages.tmp.guilds = b;
Expand Down

0 comments on commit a495b35

Please sign in to comment.