Google Cloud Run not logging into the bot

Hello devs, I am using Cloud Run to run a Discord bot docker image built like this:
# 1. Build

FROM node:20-slim as BUILD

WORKDIR /condor

COPY . .

RUN npm install && npm run compile

# 2. Export

FROM node:20-slim

WORKDIR /condor

ARG TOKEN
ARG EMOJI_SERVER_ID
ARG OPENAI_API_KEY
ARG FB_PROJECT_ID
ARG FB_PRIVATE_KEY
ARG FB_CLIENT_EMAIL
ARG GOOGLEAPI_PRIVATE_KEY
ARG GOOGLEAPI_CLIENT_EMAIL
ARG CLOUDRUN_PORT

ENV TOKEN=$TOKEN
ENV EMOJI_SERVER_ID=$EMOJI_SERVER_ID
ENV OPENAI_API_KEY=$OPENAI_API_KEY
ENV FB_PROJECT_ID=$FB_PROJECT_ID
ENV FB_PRIVATE_KEY=$FB_PRIVATE_KEY
ENV FB_CLIENT_EMAIL=$FB_CLIENT_EMAIL
ENV GOOGLEAPI_PRIVATE_KEY=$GOOGLEAPI_PRIVATE_KEY
ENV GOOGLEAPI_CLIENT_EMAIL=$GOOGLEAPI_CLIENT_EMAIL
ENV CLOUDRUN_PORT=$CLOUDRUN_PORT

COPY package.json ./
COPY tsconfig.json ./

RUN ls -la && npm install --omit=dev

COPY --from=BUILD /condor/dist ./dist

CMD ["sh", "-c", "npm run start || tail -f /dev/null"]
# 1. Build

FROM node:20-slim as BUILD

WORKDIR /condor

COPY . .

RUN npm install && npm run compile

# 2. Export

FROM node:20-slim

WORKDIR /condor

ARG TOKEN
ARG EMOJI_SERVER_ID
ARG OPENAI_API_KEY
ARG FB_PROJECT_ID
ARG FB_PRIVATE_KEY
ARG FB_CLIENT_EMAIL
ARG GOOGLEAPI_PRIVATE_KEY
ARG GOOGLEAPI_CLIENT_EMAIL
ARG CLOUDRUN_PORT

ENV TOKEN=$TOKEN
ENV EMOJI_SERVER_ID=$EMOJI_SERVER_ID
ENV OPENAI_API_KEY=$OPENAI_API_KEY
ENV FB_PROJECT_ID=$FB_PROJECT_ID
ENV FB_PRIVATE_KEY=$FB_PRIVATE_KEY
ENV FB_CLIENT_EMAIL=$FB_CLIENT_EMAIL
ENV GOOGLEAPI_PRIVATE_KEY=$GOOGLEAPI_PRIVATE_KEY
ENV GOOGLEAPI_CLIENT_EMAIL=$GOOGLEAPI_CLIENT_EMAIL
ENV CLOUDRUN_PORT=$CLOUDRUN_PORT

COPY package.json ./
COPY tsconfig.json ./

RUN ls -la && npm install --omit=dev

COPY --from=BUILD /condor/dist ./dist

CMD ["sh", "-c", "npm run start || tail -f /dev/null"]
Everything is defined properly, but bot.login doesn't seem to be registering in the Cloud Run, because neither .then nor .catch were called.
import bot from '@bot';
import { ApplicationCommandRegistries, RegisterBehavior } from "@sapphire/framework";
import * as http from 'http';

// require('dotenv').config();

ApplicationCommandRegistries.setDefaultBehaviorWhenNotIdentical(RegisterBehavior.BulkOverwrite);

const server = http.createServer((req, res) => {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Just for testing purposes\n');
});

server.listen(process.env.CLOUDRUN_PORT, () => {
console.log('Server running at http://localhost:' + process.env.CLOUDRUN_PORT + '/');
console.log(`bot.id: ${bot.id}`)
console.log(`TOKEN: ${process.env.TOKEN}`)
bot.login(process.env.TOKEN)
.then(() => {
console.log('Bot is ready');
})
.catch((error) => {
console.error('Error while logging in', error);
});
});
import bot from '@bot';
import { ApplicationCommandRegistries, RegisterBehavior } from "@sapphire/framework";
import * as http from 'http';

// require('dotenv').config();

ApplicationCommandRegistries.setDefaultBehaviorWhenNotIdentical(RegisterBehavior.BulkOverwrite);

const server = http.createServer((req, res) => {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Just for testing purposes\n');
});

server.listen(process.env.CLOUDRUN_PORT, () => {
console.log('Server running at http://localhost:' + process.env.CLOUDRUN_PORT + '/');
console.log(`bot.id: ${bot.id}`)
console.log(`TOKEN: ${process.env.TOKEN}`)
bot.login(process.env.TOKEN)
.then(() => {
console.log('Bot is ready');
})
.catch((error) => {
console.error('Error while logging in', error);
});
});
No description
6 Replies
d.js toolkit
d.js toolkit3w ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by staff
Mercenary Ike
Mercenary IkeOP3w ago
Further: in the first deploy, there were problems with the token, so an error is properly logged. But right now, there is no logging from Discord at all
No description
Unknown User
Unknown User3w ago
Message Not Public
Sign In & Join Server To View
Mercenary Ike
Mercenary IkeOP3w ago
Yeah, is this not appriopriate?
Unknown User
Unknown User3w ago
Message Not Public
Sign In & Join Server To View
Mercenary Ike
Mercenary IkeOP3w ago
Got it
Want results from more Discord servers?
Add your server