Deathknife / sourcemod-discord

Discord API for Sourcemod
61 stars 36 forks source link

WebSocket issue #2

Closed Flegma closed 7 years ago

Flegma commented 7 years ago

Hello, ive compiled your example plugins (only changed bot token in calladmin) and i've gor smx files which i uploaded and the plugins seems to work. But the Bot on the discord seems to not be working. I've created a bot user, even added it to the server, but the websocket connection (in chrome console) is giving me the error: http://take.ms/GsExtE

Deathknife commented 7 years ago

Try to execute the 3 commands seperately. i.e

var ws = new WebSocket('wss://gateway.discord.gg');

Wait a second or two, then:

var mystring = JSON.stringify({
 "op": 2,
 "d": {
 "token": "<bot token>",
 "properties": {
 "$os": "linux",
 "$browser": "sometestingbrowser",
 "$device": "sometestingdevice",
 "$referrer": "",
 "$referring_domain": "",
 },
 "compress": true,
 "large_threshold": 250,
 }
});

and finally: ws.send(mystring);

Flegma commented 7 years ago

Another error:

VM1459:35 Refused to connect to 'wss://gateway.discord.gg/' because it violates the following Content Security Policy directive: "connect-src 'self' uploads.github.com status.github.com collector.githubapp.com api.github.com www.google-analytics.com github-cloud.s3.amazonaws.com wss://live.github.com".

WrappedWebSocket @ VM1459:35 (anonymous) @ VM1812:1 VM1459:35 Uncaught DOMException: Failed to construct 'WebSocket': Refused to connect to 'wss://gateway.discord.gg/' because it violates the document's Content Security Policy. at WrappedWebSocket (:35:21) at :1:10

Deathknife commented 7 years ago

Solved by opening console on another page such as google.com