SceduleJob not doing the command

Viewed 23

I have a discord bot project v13 and training to make a scheduled job that hide an array of channels using node-schedule ,

So far i have done the mongodb schema and everything is ok Put it doesn't hide the channels

If i change the command to console.log everything is ok i tired to put the code in index and not working In messageCreate and not working Tried module.exports to the code and nothing happened

Please help.

const schedule = require('node-schedule');
const timejop = require('../models/Jobschema')

let everyone = message.guild.
          roles.cache.find(m => m.name === '@everyone');
        const job = await timejop.findOne({ GuildID: message.guild.id })
  
const ho = job.openHo
const men = job.openM
const ho2 = job.closeHo
const men2 = job.closeM
const ch = job.Channels
let timezone = job.timezone
  
 let show = new schedule.RecurrenceRule(); // your
    show.tz = timezone;
    show.second = 0;
    show.minute = men;
    show.hour = ho;
    schedule.scheduleJob(show, function () {
    
ch.permissionOverwrites.Edit(ch.guild.roles.everyone, { ViewChannel: true });
    
        });

  let hide = new schedule.RecurrenceRule(); // your
    hide.tz = timezone;
    hide.second = 0;
    hide.minute = men2;
    hide.hour = ho2;
    schedule.scheduleJob(hide, function () {
    
ch.permissionOverwrites.edit(ch.guild.roles.everyone, { ViewChannel: false });
    
        })  

this is the code i made

const mongoose = require('mongoose')
const jobs = mongoose.Schema({
  guildId: { type: String, require: true, unique: true },
  Channels: [String],
  openM: { type: String},
  openHo: { type: String},
  closeM: { type: String},
  closeHo: { type: String},
  timezone: { type: String},
});

const model = mongoose.model("guildjob", jobs, 'jobs');

this is the scheme

0 Answers
Related