From 2448c4488bccc8bde257d64bbac30874209e7c16 Mon Sep 17 00:00:00 2001 From: Cristiano Pires Date: Sun, 16 Apr 2023 16:29:04 +0100 Subject: [PATCH] routes fix --- controller/api.js | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/controller/api.js b/controller/api.js index 0629a2d..4f2a658 100644 --- a/controller/api.js +++ b/controller/api.js @@ -215,7 +215,10 @@ exports.updateRule = (bot)=> var roleEmoji = args.emojiid; var gID = args.gid; var roleName; - if(!(mID && roleID && roleEmoji && gID)) return mID?(roleID?(roleEmoji? false: {error:'Emoji ID'}):{error:'Role ID'}):{error:'Message ID'}; + if(!mID) return {error:'Message ID'} + if(!roleID) return {error:'Role ID'} + if(!roleEmoji) return {error:'Emoji ID'} + if(!gID) return {error:'Guild ID'} var m = await (async ()=> { for(const [id, channel] of bot.channels.cache) @@ -230,7 +233,12 @@ exports.updateRule = (bot)=> } })(); const r = bot.guilds.cache.get(gID).roles.cache.get(roleID); - const e = bot.guilds.cache.get(gID).emojis.cache.get(roleEmoji); + const e = bot.guilds.cache.get(gID).emojis.cache.get(roleEmoji); + bot.guilds.cache.get(gID).emojis.cache.forEach(emoji=> + { + if(emoji.name == 'tuturu') console.log(emoji) + }) + console.log('Emoji', roleEmoji, e) if(!m || !r || !e) return m?(r?(e?false:{error:'Emoji ID'}):{error:'Role ID'}):{error:'Message ID'} roleName = r.name; return {mID, roleID, roleEmoji, roleName, gID} @@ -450,9 +458,13 @@ exports.registerGame = async (req, res)=> return false }) if(!updated) return res.json({Error:'The game failed to register.'}) + var _PA = update.PA; + _PA.extraData= update.PA.Name == GameData.info.PlayerA.summonerName? GameData.info.PlayerA: GameData.info.PlayerB; + var _PB = update.PB; + _PB.extraData = update.PA.Name == GameData.info.PlayerA.summonerName? GameData.info.PlayerA: GameData.info.PlayerB; Game[0] = { - PA:update.PA, - PB:update.PB, + PA:_PA, + PB:_PB, Winner:update.Winner, WinCondition:update.WinCondition, Played:true, @@ -671,7 +683,15 @@ exports.createLeaguePage = (req, res)=> } exports.createLeaguePage = (req, res)=> { - //TODO: Render page; res.render('createLeague'); } +exports.getGame = (req, res)=> +{ + return res.render('game') +} +exports.getGameData = (req, res)=> +{ + //TODO: getGameData + //TODO: send as json +} \ No newline at end of file