There are discord.js bot (below: main.ts, basic logic in modules):
import {Client, GatewayIntentBits, ThreadChannel} from "discord.js";
import {startCommandBuilder} from "./builders/slashCommandBuilders";
import Database from "./classes/databaseClass";
import BotInteraction from "./classes/interactionClass";
import mainEvents from "./events/mainEvents";
import messageEvent from "./events/messageEvent";
export const client = new Client({intents: [
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildModeration,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildBans,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessagePolls,
GatewayIntentBits.GuildMessages
]})
const env = process.env
export const mysqlConfig = {
user: 'bot',
password: env.MYSQL_PASSWORD,
database: env.MYSQL_DATABASE,
host: env.MYSQL_HOST,
port: env.MYSQL_PORT
}
client.on('ready', async (event) => {
if (!event.user) return
event.user.setStatus("dnd")
await event.application.commands.create(startCommandBuilder)
const db = new Database()
await db.init()
console.log(`${event.user.displayName} started!`)
})
client.on('interactionCreate', async (event) => {
const interaction = new BotInteraction(event)
await mainEvents(interaction)
})
client.on('messageCreate', async (message) => {
if (!message.member || message.member.user.bot || !(message.channel instanceof ThreadChannel)) return
await messageEvent(message)
})
client.login(env.BOT_TOKEN)
When I run the bot locally, everything works fine, but when I try to do it in the docker container (in gitlab via pipline), an error occurs:
ReferenceError: ReadableStream is not defined
at Object.<anonymous> (/bot/node_modules/@discordjs/rest/node_modules/undici/lib/web/fetch/response.js:530:3)
at Module._compile (node:internal/modules/cjs/loader:1198:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
at Object.require.extensions.<computed> [as .js] (/bot/node_modules/ts-node/src/index.ts:1608:43)
at Module.load (node:internal/modules/cjs/loader:1076:32)
at Function.Module._load (node:internal/modules/cjs/loader:911:12)
at Module.require (node:internal/modules/cjs/loader:1100:19)
at require (node:internal/modules/cjs/helpers:119:18)
at Object.<anonymous> (/bot/node_modules/@discordjs/rest/node_modules/undici/lib/web/fetch/index.js:11:5)
at Module._compile (node:internal/modules/cjs/loader:1198:14)
/bot/node_modules/@discordjs/rest/node_modules/undici/lib/web/fetch/response.js:530
ReadableStream
^
What could make a mistake?
Almost nothing. Most installed pair node_modules