This can be done using socket.io First install socket.io npm i socket.io
Then update your application to use the socket.io engine.
const app = express();
const http = require('http').Server(app);
const io = require('socket.io')(http);
const Discord = require('discord.js')
const config = require('./config.json')
const bodyParser = require("body-parser")
Update "index" file. Make sure the text your trying to update has id="count"
.
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io();
socket.on('count', function(data){
$('#count').html(data.count);
});
</script>
Now finally update command.
client.on("message", function(message) {
console.log(message.author.username + " : "+ message.content)
data = message.author.username + " : "+ message.content
io.sockets.on('connection', function(sockets){
sockets.emit('count',{count:data});
})
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…