node.js - 将 discord.js bot 转换为 exe
问题描述
我有一个工作不和谐的机器人,但我想把它编译成一个.exe
文件。怎么做?我尝试使用pkg
and nexe
,但两者都没有正确使用。Nexe 甚至没有开始给我一些奇怪的错误,我在阅读文档和互联网上的一些讨论后无法修复这些错误。
Error: https://github.com/nexe/nexe/releases/download/v3.3.3/windows-x64-14.8.0 is not available, create it using the --build flag
和Error: vcbuild.bat nosign release x64 exited with code: 1
。效果更好,pkg
我得到并exe
归档,但它似乎不起作用:我有这段代码,其中 bot 是我的不和谐客户端。
bot.on('ready', () =>
{
console.log(bot.guilds.cache.toJSON());
bot.guilds.cache.forEach((gui) =>
{
console.log(gui.id + ' ' + gui.name + ' ' + gui.memberCount);
});
console.log('Bot started!');
});
当我使用 启动它时,它会提供一台服务器,但如果我执行创建的文件,node index.js
它不会提供任何服务器,尽管机器人会联机。exe
我的package.json
样子是这样的:
{
"name": "sth",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"pkg": {
"assets": [ "jsons/**/*", "config.json" ]
},
"bin": "index.js",
"author": "",
"license": "ISC",
"dependencies": {
"discord.js": "^12.4.1"
}
}
我究竟做错了什么?为什么机器人启动了,但似乎什么也做不了?我错过了什么?
解决方案
我不知道您可以使用的.exe
文件代码但是您可以使用.bat
文件并将其放在桌面上并创建快捷方式或将其放在shell:startup
您想要编写的位置
@echo off
node "js file path"
推荐阅读
- angular - Angular 2(v6)内联,如果其他?
- python - Scrapy 自定义设置
- php - 在一个 foreach 循环中合并 2 个单独的数据库查询或将查询合并为一个
- angular - Angular6按服务打开/显示组件
- r - Azure 上的 R 服务器
- javascript - 为 A-Frame 中的所有对象加载 html 和 js 后调用函数
- java - 如何在 java eclipse 中创建一个新的数据库
- html - 顶部带有按钮的背景图像
- python - 在 python pandas 上使用 np.where 设置多个条件?
- python - 阀门关闭时水力发电厂 (HPP) 中水体的振荡