【问题标题】:Object.values is not a function errorObject.values 不是函数错误
【发布时间】:2019-01-06 19:30:59
【问题描述】:

我正在创建一个不和谐机器人只是为了弄乱它,我正在使用 express 创建一个网站来控制它。但是当从按钮单击转移到另一个页面时,我不断收到“Object.values is not a function”,并使用它作为哈巴狗的“代码”

input(type="button", value="Turn bot off", onclick='window.location.href = "website";' ,id='offButton')

Index.js:

var express = require('express');
var router = express.Router();
const DISCORD = require('discord.js');

const CLIENT = new DISCORD.Client();

const TOKEN = 'discord token';

//GET home page. 
router.get('/', function(req, res) {
  res.render('index', {
    title: 'Express'
  });
});

router.get('/off', function(req, res) {
  CLIENT.destroy();
  res.redirect('go back to home'); << where error is
});

CLIENT.on('ready', () => {
  console.log('Ready')
});

CLIENT.on('message', message => {
  if (message.content === 'ping') {
    message.channel.send('pong');
  } else if (message.content === 'off' && message.member.permissions.has('ADMINISTRATOR')) {
    CLIENT.destroy();
  } else if (message.content.charAt(0) === '!') {
    message.channel.send('what?')
  }
});

CLIENT.login(TOKEN);

module.exports = router;

【问题讨论】:

    标签: node.js express discord.js


    【解决方案1】:

    您可能应该升级您的 node.js。您至少需要 7.0.0 版才能支持 Object.values()。见https://node.green/#ES2017-features-Object-static-methods-Object-values

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-15
      • 1970-01-01
      • 2017-10-23
      • 2013-01-04
      • 1970-01-01
      • 2017-05-09
      • 2021-09-14
      • 2021-05-10
      相关资源
      最近更新 更多