const fs = require('fs'); const path = require('path'); const client = require("./Constants/Client.js"); const { Collection, EmbedBuilder } = require('discord.js'); const { token } = require('./config.json'); const { ActivityTypes, Events } = require('discord.js') client.commands = new Collection(); const commandsPath = path.join(__dirname, 'commands'); const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js')); const Sequelize = require('sequelize'); const Restricted = require('./database.js'); for (const file of commandFiles) { const filePath = path.join(commandsPath, file); const command = require(filePath); client.commands.set(command.data.name, command); } client.once(Events.ClientReady, () => { console.log(`Online.`); console.log(`I am in ${client.guilds.cache.size} servers`); await Restricted.sync(); console.log('synced blocked users') setInterval(() => { const servers = (client.guilds.cache.size) const channels = (client.channels.cache.size) const members = client.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0); const activities = [ { type: 0, name: "ROBLOX" }, { type: 0, name: "Grand Theft Auto 5" }, { type: 0, name: "Fortnite" }, { type: 0, name: "Farming Simulator 19" }, { type: 2, name: `Spotify` }, { type: 2, name: `AmNobCop` }, { type: 2, name: `NotCaesahr` }, { type: 3, name: `out for commands` }, { type: 3, name: `YouTube` }, { type: 3, name: `${servers} servers` }, { type: 3, name: `${channels} channels` }, { type: 3, name: `${members} members` } ]; const status = activities[Math.floor(Math.random() * activities.length)]; client.user.setActivity({ type: status.type, name: status.name }); }, 15000); }); const errorEmbed = new EmbedBuilder() .setColor(0xFF0000) .setTitle('Unexpected Error') .setDescription(` An unexpected error occurred while running this command. `) .setTimestamp() .setFooter({ text: 'Bot made by AmNobCop' }); client.on(Events.InteractionCreate, async (interaction) => { try { const RestrictedUsers = await Restricted.findOne({ where: { user: interaction.user.id } }) console.log(RestrictedUsers.user) if (RestrictedUsers.user == interaction.user.id) return interaction.reply('no'); } catch {}; if (interaction.isChatInputCommand()) { const command = client.commands.get(interaction.commandName); if (!command) return; try { await command.execute(interaction); } catch (error) { console.error(error); await interaction.reply({ embeds: [errorEmbed], ephemeral: true }); } } if (interaction.isModalSubmit()) { if (interaction.customId === 'PatrolLog') { const StartTimeInput = interaction.fields.fields.getTextInputValue(StartTime); const EndTimeInput = interaction.fields.fields.getTextInputValue(EndTime); const StartProofInput = interaction.fields.fields.getTextInputValue(StartProof); const EndProofInput = interaction.fields.fields.getTextInputValue(EndProof); const TotalTimeInput = interaction.fields.fields.getTextInputValue(TotalTime); const PendingEmbed = new EmbedBuilder() .setColor(0x0099FF) .setTitle('Patrol Log Submission') .setDescription(`${StartTimeInput}`) .setThumbnail('https://cdn.discordapp.com/attachments/925850735697068042/1039891607568273428/USAF.png') .setTimestamp() .setFooter({ text: 'Bot made by AmNobCop' }); interaction.followUp(`${interaction.user.tag}, your patrol log has been submitted. You will get a notice in your Direct Messages on the status of your log.`) ApproveChl.send({ embeds: [PendingEmbed] }) }} }); client.login(token);