我正在创建一个不和谐的bot,只是为了弄乱它,而我正在使用express创建一个网站来对其进行控制。但是当我从按钮单击将其用作哈巴狗的“代码”转移到另一页时,我一直得到“ Object.values不是函数”
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;
答案 0 :(得分:3)
您可能应该升级node.js。您至少需要版本7.0.0才能支持Object.values()。参见https://node.green/#ES2017-features-Object-static-methods-Object-values