小编Lar*_*nen的帖子

如何将 Discord.js 机器人部署到 Cloud Functions?

我想将在 Discord.js 上运行的 Discord 机器人部署到 Firebase Cloud Functions,但我无法让该机器人在 Firebase 中运行。如果我使用nodemon,它会完美运行,但如果我使用firebase部署,它不会启动机器人。

这是我当前的代码:

const functions = require('firebase-functions');

require('dotenv').config();
const token = process.env.TOKEN

const Discord = require('discord.js')
const Client = new Discord.Client();

Client.on('ready', () => {
    Client.channels.find(x => x.name === 'main-cannel').send('bot is deployed')
    Client.user.setGame(`The Cult | ${Client.guilds.size} servers`)
    Console.log('test')
});

Client.login(token);

//is is not working but de basic
//export.App = functions.... {Client}
exports.app = functions.https.onRequest((request, response) => {
    response.send("Test");
});
Run Code Online (Sandbox Code Playgroud)

node.js firebase google-cloud-functions discord.js

6
推荐指数
1
解决办法
1万
查看次数