LucasB25 / Eagle-Bot-List

Discord Bot List v1
https://discord.gg/5cyQ378ffG
Apache License 2.0
7 stars 4 forks source link

List of known bugs #5

Open LucasB25 opened 1 year ago

LucasB25 commented 1 year ago

Bug description

Bot commands no longer work. but the panel can return them

C:\Users\batti\OneDrive\Documents\GitHub\Eagle-Bot-List\src\routes\bots\index.js:85
  let c = botUser.presence.status;
                           ^

TypeError: Cannot read properties of undefined (reading 'status')
    at C:\Users\batti\OneDrive\Documents\GitHub\Eagle-Bot-List\src\routes\bots\index.js:85:28
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
C:\Users\batti\OneDrive\Documents\GitHub\Eagle-Bot-List\src\routes\api\auth\index.js:16
  if (![bot.owners.primary].concat(bot.owners.additional).includes(req.user.id) && !admin_user_ids.includes(req.user.id)) return res.json({ "success": false, "error": "Bot owner is not user." });
                                                                                    ^

ReferenceError: admin_user_ids is not defined
    at C:\Users\batti\OneDrive\Documents\GitHub\Eagle-Bot-List\src\routes\api\auth\index.js:16:85
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
TypeError: C:\Users\batti\OneDrive\Documents\GitHub\Eagle-Bot-List\src\dynamic\includes\nav.pug:24
    22|           li.nav-item
    23|             span.hover-grey.nav-link Join Discord
  > 24|         if (req.user && req.user.staff)
    25|           a(style='text-decoration:none!important;', href='/admin')
    26|             li.nav-item
    27|               span.hover-grey.nav-link Review Panel

Cannot read properties of undefined (reading 'user')
Iinksafe commented 11 months ago

Well, I am unable to reproduce the first and the third error(s), but the second one says that the variable admin_user_ids is not defined, so you should check for its definition in other parts of the code.

As for the first one, you should add a check whether the bot has a presence set or not, example:

// Assuming that `.status` is a `string` object,
// we return an empty string if no presence
// was received or fetched from gateway.
let c = botUser.presence?.status ?? '';

Last but not least, in the third one, you should do the same thing for the first one, example:

if (req?.user?.staff) { ... }

Here, ?. checks whether the variable that is currently being accessed checks whether the variable req (or req.user, if it is accessible) is null or undefined.

Hope this helps! :heart: