diff --git a/lib.js b/lib.js index ebc5ffa..279829f 100644 --- a/lib.js +++ b/lib.js @@ -1358,7 +1358,7 @@ exports.DiscordAPI = class DiscordAPI .then(result => result.json()) .then(response => { - + console.log(response, this.authorization) if(response.message) return response.message return response.filter(x=>x.owner==true); }) @@ -1466,11 +1466,11 @@ exports.DiscordAPI = class DiscordAPI } AuthStringMaker(cookieString) { - const splitCookie = cookieString.split('; '); - const tokenType = splitCookie[0].split('=')[1]; - const accessToken = splitCookie[1].split('=')[1]; + const accessToken = cookieParser(cookieString, 'accessToken'); + const tokenType = cookieParser(cookieString, 'tokenType'); return `${tokenType} ${accessToken}` } + /** * * @param {String} id GuildID @@ -1500,6 +1500,11 @@ exports.DiscordAPI = class DiscordAPI } } +exports.cookieParser = cookieParser = (cookie, name)=> +{ + if(!cookie.includes(name)) return null + return cookie.split(name+'=')[1].split(';')[0]; +} /** * * @param {String|String} id - Discord Guild Id (GuildId) | Mongo Record ID (ruleID)