const { Client, GatewayIntentBits, Partials } = require('discord.js'); const cron = require('node-cron'); const client = new Client({ intents: [GatewayIntentBits.Guilds], partials: [Partials.Channel] }); const channelId = 'YOUR_CHANNEL_ID_HERE'; // Replace with your channel ID client.once('ready', () => { console.log('Bot is online!'); // Start the cron job to lock and unlock the channel startCronJob(); }); client.login('YOUR_BOT_TOKEN_HERE'); // Replace with your bot token function startCronJob() { // Define the cron job to run at 3 am every day in Algeria timezone (GMT/UTC+1) cron.schedule('0 3 * * *', () => { const now = new Date(); const hour = now.getUTCHours(); // Get current hour in UTC if (hour >= 3 && hour < 10) { // Lock the channel lockChannel(); } else { // Unlock the channel unlockChannel(); } }, { timezone: 'Africa/Algiers' // Algeria timezone }); } async function lockChannel() { const channel = await client.channels.fetch(channelId); if (!channel) return console.error('Channel not found.'); // Lock the channel await channel.permissionOverwrites.edit(channel.guild.roles.everyone, { SEND_MESSAGES: false }); // Send embed message indicating channel is locked const embed = new MessageEmbed() .setColor('#ff0000') .setTitle('Channel Locked') .setDescription('Curfew hours are on.') .setTimestamp(); await channel.send({ embeds: [embed] }); } async function unlockChannel() { const channel = await client.channels.fetch(channelId); if (!channel) return console.error('Channel not found.'); // Unlock the channel await channel.permissionOverwrites.edit(channel.guild.roles.everyone, { SEND_MESSAGES: true }); // Send embed message indicating channel is unlocked const embed = new MessageEmbed() .setColor('#00ff00') .setTitle('Channel Unlocked') .setDescription('Curfew hours are off.') .setTimestamp(); await channel.send({ embeds: [embed] }); }