From bbabc0c6303a4b03f7e5dc7d697fd2de84a1c380 Mon Sep 17 00:00:00 2001 From: FoxStorm1 <69159547+Yeetov@users.noreply.github.com> Date: Mon, 20 Nov 2023 20:05:52 +0000 Subject: [PATCH] Create script.js --- script.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 script.js diff --git a/script.js b/script.js new file mode 100644 index 0000000..3ddf5c1 --- /dev/null +++ b/script.js @@ -0,0 +1,19 @@ +// script.js + +// Function to set Discord avatar if the image URL is not available +function setDiscordAvatar(element, discordId, defaultAvatar) { + element.src = `https://cdn.discordapp.com/avatars/${discordId}/${defaultAvatar}`; +} + +document.addEventListener("DOMContentLoaded", function() { + // Check and set Discord avatars for each staff member + const avatars = document.querySelectorAll('.avatar'); + avatars.forEach(avatar => { + avatar.onerror = function() { + // If the avatar URL fails, load the specified Discord avatar + const discordId = this.getAttribute('data-discord-id'); + const defaultAvatar = this.getAttribute('data-default-avatar'); + setDiscordAvatar(this, discordId, defaultAvatar); + }; + }); +});