I am making a Discord bot using Discord.js v13, and once I run the project it prints in the console.log:
Bot is on
Timestamp: [time I ran the bot]
My code to make it like that:
const Event = require("../Structures/Event.js");
const Discord = require('discord.js')
var today = new Date();
var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate()+' `'+today.getHours()+':'+today.getMinutes()+':'+today.getSeconds()+'`';
var hms = today.getHours()+':'+today.getMinutes()+':'+today.getSeconds();
module.exports = new Event("ready", client => {
console.log(`Bot is on\nTimestamp: ${hms} `)
client.channels.fetch("928241814639632404")
.then(channel => {
channel.send(`Started on ${date}`).then(sentMessage => {
setTimeout(() => {
sentMessage.delete()
}, 1000);
})
})
client.user.setActivity({ name: 'The World Failing', type: "WATCHING" })
client.user.setStatus('dnd')
})
Now I also have a simple host, shown in the discordjs guide
Code in index.js:
const express = require('express')
const app = express();
app.get('/', (request, response) => {
return response.sendFile('index.html', { root: '.' });
});
app.listen(port, () => console.log(`App listening at http://localhost:${port}`));
Code in index.html:
<!DOCTYPE html>
<html>
<head>
<title>My Discord OAuth2 App</title>
</head>
<body>
<div id="info">
Hoi!
</div>
</body>
</html>
My question is, how do I make it show on the web server when my bot started, just like it showed in the console.log?