我想将Discord.io添加到我的cordova(Windows 10移动版)应用中。
我在cordova项目目录中执行了npm install discord.io
。
它创建node_modules
目录,并将discord.io添加到NPM-Dependencies:
如果我尝试初始化discord.io lib,就像GitHub中的例子那样:
var DiscordClient = require('discord.io');
var bot = new DiscordClient({
autorun: true,
email: "my@email.com",
password: "secret_passw0rd"
});
bot.on('ready', function() {
console.log(bot.username + " - (" + bot.id + ")");
});
bot.on('message', function(user, userID, channelID, message, rawEvent) {
if (message === "ping") {
bot.sendMessage({
to: channelID,
message: "pong"
});
}
});
我收到错误消息:
0x800a1391 - JavaScript runtime error: 'require' is undefined
我还尝试使用cordova.require('discord.io');
,导致此错误:
0x800a139e - JavaScript runtime error: module discord.io not found
如何正确包含和初始化此库?