From 3a933ef7b01ffdcfd8412facd6505a3e64f711c5 Mon Sep 17 00:00:00 2001 From: masterhc Date: Thu, 15 Feb 2024 15:24:57 +0000 Subject: [PATCH] Error handling --- controller/api.js | 2 +- views/guilds.ejs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/controller/api.js b/controller/api.js index b1c6cef..aab9420 100644 --- a/controller/api.js +++ b/controller/api.js @@ -25,7 +25,7 @@ exports.dashboard = (bot)=> username:'placeholder', avatar:'', } - if(!req.headers.cookie) return res.render('dashboard.ejs', {user:userPlaceholder, guilds:{}}); + if(!req.headers.cookie) return res.render('dashboard.ejs', {user:userPlaceholder, guilds:[{}]}); const connector = new DiscordAPI(req.headers.cookie, bot); const user = await connector.getUser(); const guilds = await connector.getGuildsFull(); diff --git a/views/guilds.ejs b/views/guilds.ejs index b44d8c0..2e8239d 100644 --- a/views/guilds.ejs +++ b/views/guilds.ejs @@ -1,5 +1,7 @@
- <% guilds.forEach(guild => {%> - <%- include('guildCard.ejs', {guild}) %> - <% }); %> + <% if(guilds.length>0){%> + <% guilds.forEach(guild => {%> + <%- include('guildCard.ejs', {guild}) %> + <% }); %> + <% } %>
\ No newline at end of file