So. I have a app that communicates with Javascript with a WebView2 Object, in C# WinForms. However, Most of the handling messages is done in javascript/html of course, so i setup a websocket, and it somewhat works? My and ONLY my messages content(s) are being shown, like, if i send a message, then it’ll log it in the console, with the profile picture and all. But if someone else sends a message, then it’ll log the profile picture and name, but not the message content? And then the websocket closes. My token is valid as well.
var ws = new WebSocket("wss://gateway.discord.gg/?v=9&encoding=json");
var interval = 0;
payload = {
op: 2
, d: {
token: ""
, intents: 512
, properties: {
$os: "linux", // this works fine
$browser: "chrome"
, $device: "chrome"
, }
, }
, };
ws.addEventListener("open", function open(x) {
ws.send(JSON.stringify(payload));
});
ws.addEventListener("message", function incoming(data) {
var x = data.data;
var payload = JSON.parse(x);
const {
t
, event
, op
, d
} = payload;
switch (op) {
case 10:
const {
heartbeat_interval
} = d;
setInterval(() => {
ws.send(JSON.stringify({
op: 2
, d: null
}));
}, heartbeat_interval);
break;
}
switch (t) {
// yes targetChannelId is CORRECT.
case "MESSAGE_CREATE":
if (d.channel_id === targetChannelId) {
var final = {
author: d.author.username
, content: d.content
, image: `${d.author.avatar ? `https://cdn.discordapp.com/avatars/${d.author.id}/${d.author.avatar}.png` : 'N/A'}`
}
appendMessageWithFrame(final); // call
console.log(d);
// this is where i'm confused. d.content is blank when someone else types? but when i type its not blank??
console.log(`${d.author.username}: ${d.content}, Avatar URL: ${d.author.avatar ? `https://cdn.discordapp.com/avatars/${d.author.id}/${d.author.avatar}.png` : 'N/A'}`);
}
break;
}
});
Tried double-checking my token, it was obviously correct, checked targetChannelId, ALSO correct, checked the d
array, still, correct, until someone else types, then d.content is empty and the websocket breaks.