Бот Discord нельзя развернуть на Heroku - PullRequest
0 голосов
/ 12 июля 2020

Итак, мой бот отлично работал на Heroku и был развернут, пока я не добавил код в свой js файл. Я установил node-cron и node-schedule, потому что я работал над запланированным событием сообщения.

const Discord = require("discord.js")
const cron = require("node-cron");
const bot = new Discord.Client({disableEveryone: false});

module.exports = bot => { 
    console.log(`${bot.user.username} is online`)
    bot.user.setActivity("SINoALICE", {type: "PLAYING"});

    let reminderChannel = client.channel.find(channel => channel.id === '731870214526074910');
    let colloseumChannel = client.channel.find(channel => channel.id ==='730423361783726111');

    const cronJobs = [
        { "type": "Guerrilla", "param": "* 25 20 * * *" },
        { "type": "Guerrilla", "param": "* 25 22 * * *" },
        { "type": "Guerrilla", "param": "* 25 00 * * *" },
        { "type": "Guerrilla", "param": "* 25 02 * * *" },
        { "type": "Guerrilla", "param": "* 25 04 * * *" },
        { "type": "Guerrilla", "param": "* 25 13 * * *" },
        { "type": "Conquest", "param": "* 25 21 * * *" },
        { "type": "Conquest", "param": "* 25 23 * * *" },
        { "type": "Conquest", "param": "* 25 01 * * *" },
        { "type": "Conquest", "param": "* 25 03 * * *" },
        { "type": "Conquest", "param": "* 25 05 * * *" },
        { "type": "Conquest", "param": "* 50 14 * * *" },
        { "type": "Colloseum", "param": "* 50 22 * * *" }
    ];
 
for(let i = 0; i < cronJobs.length; i++){
  cron.schedule(cronJobs[i].param, () => {
    let message;
    if(cronJobs[i].type === 'Colloseum'){
        colloseumChannel.send(`@everyone The Colloseum Battle is about to being in 10 minutes. Please ready yourself!`);
     } else {
        reminderChannel.send(`@everyone The next ${croneJobs.type} Event begins in 5 minutes.`);
     }
    console.log("Scheduler running...")
  })
}
}

после этого, когда я пытаюсь развернуть ветку, я получаю это

    -----> Node.js app detected
       
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       NODE_VERBOSE=false
       
-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)
       
       Resolving node version 12.x...
       Downloading and installing node 12.18.2...
       Using default npm version: 6.14.5
       
-----> Restoring cache
       - node_modules is checked into source control and cannot be cached
       
-----> Installing dependencies
       Prebuild detected (node_modules already exists)
       Rebuilding any native modules
       
       > node-cron@2.0.3 postinstall /tmp/build_60d67a8f4743298ef5ee95c5ea225a00/node_modules/node-cron
       > opencollective-postinstall
       
       sh: 1: opencollective-postinstall: Permission denied
       npm ERR! code ELIFECYCLE
       npm ERR! errno 126
       npm ERR! node-cron@2.0.3 postinstall: `opencollective-postinstall`
       npm ERR! Exit status 126
       npm ERR! 
       npm ERR! Failed at the node-cron@2.0.3 postinstall script.
       npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
       
       npm ERR! A complete log of this run can be found in:
       npm ERR!     /tmp/npmcache.rKNE5/_logs/2020-07-12T20_38_10_922Z-debug.log
-----> Build failed
       
       We're sorry this build is failing! You can troubleshoot common issues here:
       https://devcenter.heroku.com/articles/troubleshooting-node-deploys
       
       Some possible problems:
       
       - node_modules checked into source control
         https://blog.heroku.com/node-habits-2016#9-only-git-the-important-bits
       
       - Node version not specified in package.json
         https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
       
       Love,
       Heroku
       
 !     Push rejected, failed to compile Node.js app.
 !     Push failed

Честно говоря, не уверен, что мне нужно делать. Я никогда не трогал свой json файл после его создания.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...