let Discord; let Database; if (typeof window !== "undefined") { Discord = DiscordJS; Database = EasyDatabase; } else { Discord = require("discord.js"); Database = require("easy-json-database"); } const delay = (ms) => new Promise((resolve) => setTimeout(() => resolve(), ms)); const s4d = { Discord, client: null, tokenInvalid: false, reply: null, joiningMember: null, database: new Database("./db.json"), checkMessageExists() { if (!s4d.client) throw new Error('You cannot perform message operations without a Discord.js client') if (!s4d.client.readyTimestamp) throw new Error('You cannot perform message operations while the bot is not connected to the Discord API') } }; s4d.client = new s4d.Discord.Client({ fetchAllMembers: true }); s4d.client.on('raw', async (packet) => { if (['MESSAGE_REACTION_ADD', 'MESSAGE_REACTION_REMOVE'].includes(packet.t)) { const guild = s4d.client.guilds.cache.get(packet.d.guild_id); if (!guild) return; const member = guild.members.cache.get(packet.d.user_id) || guild.members.fetch(d.user_id).catch(() => {}); if (!member) return; const channel = s4d.client.channels.cache.get(packet.d.channel_id); if (!channel) return; const message = channel.messages.cache.get(packet.d.message_id) || await channel.messages.fetch(packet.d.message_id).catch(() => {}); if (!message) return; s4d.client.emit(packet.t, guild, channel, message, member, packet.d.emoji.name); } }); var Server_Name, Server_Owner_ID, Server_ID; s4d.client.login('ODQyMzY1OTMwNzI1OTY1ODU2.YJ0QaA.40jBIQD4IViH5Pr1eYUzbzfQDNs').catch((e) => { s4d.tokenInvalid = true; s4d.tokenError = e; }); s4d.client.on('guildMemberAdd', async (param1) => { s4d.joiningMember = param1; s4d.client.channels.cache.get('798412625397809182').send(String('A New Member Joined')); s4d.joiningMember = null }); s4d.client.on('ready', async () => { Server_Name = 'Scratch Community'; Server_Owner_ID = '767078695466696725'; Server_ID = '798412255393611816'; s4d.client.channels.cache.get('798412625397809182').send(String('ScratchBot Is Connected')); }); s4d.client.on('message', async (s4dmessage) => { if ((s4dmessage.content) == '!Meow') { s4dmessage.react('🐱'); } else if ((s4dmessage.content) == '!Credits') { s4d.client.channels.cache.find((channel) => channel.name === 'scratchbot').send(String('Created By PlanetSat0rn')); s4d.client.channels.cache.find((channel) => channel.name === 'scratchbot').send(String('Created Using Scratch For Discord')); } }); s4d;