ScionSpy / G-C-A_V2

MIT License
1 stars 0 forks source link

BUG - Database.DiscordPlayer.load() #7

Closed ScionSpy closed 1 month ago

ScionSpy commented 1 month ago

Describe the bug

When attempted to load a player, we check if the entry includes a discord_id. If it does this indicates the player is on discord, so we attempt to boot a DiscordPlayer class which calls the Discord.GuildMember class. If the member is not on the server, as is true with this member due to their leaving the server, the bot errors.

Event.ready() Failed loading player [ 1002536069 ] to cache! Error: Database.DiscordPlayer.load(); Error! DiscordAPIError: Unknown Member
    at DiscordPlayer.loadDiscord (C:\Users\scion\OneDrive\Desktop\bots_\bot_src\G-C-A_V2\src\Database\Schemas\Player\DiscordPlayer.js:34:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async loadMembers (C:\Users\scion\OneDrive\Desktop\bots_\bot_src\G-C-A_V2\src\Discord\Events\Discord\ready.js:184:26)
    at async module.exports (C:\Users\scion\OneDrive\Desktop\bots_\bot_src\G-C-A_V2\src\Discord\Events\Discord\ready.js:32:5)

To Reproduce

Steps to reproduce the behavior:

  1. Have a member join the clan and server.
  2. Verify the member.
  3. Have the member leave the server.
  4. Re-attempt to load the player via new DiscordPlayer(), or restart the bot.

Expected behavior

The bot loading the player to cache regardless of them being on the server or not. A Discord verified member should default to the Database.Player class if they are not on discord.

Screenshots

image image

Additional context

When executing https://github.com/ScionSpy/G-C-A_V2/blob/916989471a0c2a37d4b2675448ab45dd66a9cd70/Src/Database/Schemas/Player/DiscordPlayer.js#L29 If the value comes back null (Member not on server) then redirect the process to the parent, extended Class, Database.Player