mirror of
https://github.com/ION606/custom_discordjs.git
synced 2026-05-14 22:26:54 +00:00
Initial code commit
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
config.json
|
||||
node_modules
|
||||
test.js
|
||||
Generated
+265
@@ -0,0 +1,265 @@
|
||||
{
|
||||
"name": "custom_discordjs",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "custom_discordjs",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"axios": "^1.3.4",
|
||||
"websocket": "^1.0.34"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.15.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "18.15.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.3.tgz",
|
||||
"integrity": "sha512-p6ua9zBxz5otCmbpb5D3U4B5Nanw6Pk3PPyX05xnxbB/fRv71N7CPmORg7uAD5P70T0xmx1pzAx/FUfa5X+3cw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.3.4.tgz",
|
||||
"integrity": "sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.15.0",
|
||||
"form-data": "^4.0.0",
|
||||
"proxy-from-env": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/bufferutil": {
|
||||
"version": "4.0.7",
|
||||
"resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.7.tgz",
|
||||
"integrity": "sha512-kukuqc39WOHtdxtw4UScxF/WVnMFVSQVKhtx3AjZJzhd0RGZZldcrfSEbVsWWe6KNH253574cq5F+wpv0G9pJw==",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"node-gyp-build": "^4.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.14.2"
|
||||
}
|
||||
},
|
||||
"node_modules/combined-stream": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||
"dependencies": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/d": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz",
|
||||
"integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==",
|
||||
"dependencies": {
|
||||
"es5-ext": "^0.10.50",
|
||||
"type": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||
"dependencies": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/es5-ext": {
|
||||
"version": "0.10.62",
|
||||
"resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz",
|
||||
"integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"es6-iterator": "^2.0.3",
|
||||
"es6-symbol": "^3.1.3",
|
||||
"next-tick": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/es6-iterator": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz",
|
||||
"integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==",
|
||||
"dependencies": {
|
||||
"d": "1",
|
||||
"es5-ext": "^0.10.35",
|
||||
"es6-symbol": "^3.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/es6-symbol": {
|
||||
"version": "3.1.3",
|
||||
"resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz",
|
||||
"integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==",
|
||||
"dependencies": {
|
||||
"d": "^1.0.1",
|
||||
"ext": "^1.1.2"
|
||||
}
|
||||
},
|
||||
"node_modules/ext": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz",
|
||||
"integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==",
|
||||
"dependencies": {
|
||||
"type": "^2.7.2"
|
||||
}
|
||||
},
|
||||
"node_modules/ext/node_modules/type": {
|
||||
"version": "2.7.2",
|
||||
"resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz",
|
||||
"integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw=="
|
||||
},
|
||||
"node_modules/follow-redirects": {
|
||||
"version": "1.15.2",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
|
||||
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://github.com/sponsors/RubenVerborgh"
|
||||
}
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=4.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"debug": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/form-data": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
|
||||
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
||||
"dependencies": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
"mime-types": "^2.1.12"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/is-typedarray": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
|
||||
"integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA=="
|
||||
},
|
||||
"node_modules/mime-db": {
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-types": {
|
||||
"version": "2.1.35",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
|
||||
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||
"dependencies": {
|
||||
"mime-db": "1.52.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
|
||||
},
|
||||
"node_modules/next-tick": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz",
|
||||
"integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ=="
|
||||
},
|
||||
"node_modules/node-gyp-build": {
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.6.0.tgz",
|
||||
"integrity": "sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ==",
|
||||
"bin": {
|
||||
"node-gyp-build": "bin.js",
|
||||
"node-gyp-build-optional": "optional.js",
|
||||
"node-gyp-build-test": "build-test.js"
|
||||
}
|
||||
},
|
||||
"node_modules/proxy-from-env": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
|
||||
},
|
||||
"node_modules/type": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz",
|
||||
"integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg=="
|
||||
},
|
||||
"node_modules/typedarray-to-buffer": {
|
||||
"version": "3.1.5",
|
||||
"resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz",
|
||||
"integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==",
|
||||
"dependencies": {
|
||||
"is-typedarray": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/utf-8-validate": {
|
||||
"version": "5.0.10",
|
||||
"resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.10.tgz",
|
||||
"integrity": "sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"node-gyp-build": "^4.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.14.2"
|
||||
}
|
||||
},
|
||||
"node_modules/websocket": {
|
||||
"version": "1.0.34",
|
||||
"resolved": "https://registry.npmjs.org/websocket/-/websocket-1.0.34.tgz",
|
||||
"integrity": "sha512-PRDso2sGwF6kM75QykIesBijKSVceR6jL2G8NGYyq2XrItNC2P5/qL5XeR056GhA+Ly7JMFvJb9I312mJfmqnQ==",
|
||||
"dependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"debug": "^2.2.0",
|
||||
"es5-ext": "^0.10.50",
|
||||
"typedarray-to-buffer": "^3.1.5",
|
||||
"utf-8-validate": "^5.0.2",
|
||||
"yaeti": "^0.0.6"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/yaeti": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz",
|
||||
"integrity": "sha512-MvQa//+KcZCUkBTIC9blM+CU9J2GzuTytsOUwf2lidtvkx/6gnEp1QvJv34t9vdjhFmha/mUiNDbN0D0mJWdug==",
|
||||
"engines": {
|
||||
"node": ">=0.10.32"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "custom_discordjs",
|
||||
"version": "1.0.0",
|
||||
"description": "because discord.js is annoying",
|
||||
"main": "test.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/ION606/custom_discordjs.git"
|
||||
},
|
||||
"author": "ION606",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/ION606/custom_discordjs/issues"
|
||||
},
|
||||
"homepage": "https://github.com/ION606/custom_discordjs#readme",
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.15.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.3.4",
|
||||
"websocket": "^1.0.34"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
const opts = require('./clientOpts.js');
|
||||
const gateWayIntents = require('../gateway/intents.js');
|
||||
const gateWayEvents = require('../gateway/dispatch.js');
|
||||
var WebSocketClient = require('websocket').client;
|
||||
const WebSocketConnection = require('websocket').connection;
|
||||
const handleResponses = require('./handleEvents.js');
|
||||
const { EventEmitter } = require('events');
|
||||
|
||||
|
||||
|
||||
class Client extends EventEmitter {
|
||||
/** @type {WebSocketClient} */
|
||||
ws;
|
||||
|
||||
/** @type {Number} */
|
||||
heartBeatInterval;
|
||||
|
||||
/** @type {Array<opts.intents>} */
|
||||
gwintents;
|
||||
|
||||
/** @type {String} */
|
||||
#token;
|
||||
|
||||
/** @type {WebSocketConnection}*/
|
||||
connection;
|
||||
|
||||
/** @type {Object} */
|
||||
user_settings;
|
||||
|
||||
/** @type {Object} */
|
||||
user_profile;
|
||||
|
||||
|
||||
/**
|
||||
* @param {opts} input
|
||||
*/
|
||||
constructor(input) {
|
||||
super();
|
||||
this.gwintents = input.intents;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Number} hbint
|
||||
*/
|
||||
async #startHeartBeat(hbint)
|
||||
{
|
||||
this.heartBeatInterval = hbint;
|
||||
console.log("INTERVAL SET TO: " + this.heartBeatInterval);
|
||||
|
||||
//Get the user intents
|
||||
let iCount = 0;
|
||||
for (let i of this.gwintents) {
|
||||
iCount += (i) ? i : 0;
|
||||
}
|
||||
|
||||
var idObj = {
|
||||
op: 2,
|
||||
d: {
|
||||
token: this.#token,
|
||||
intents: this.gwintents.value, //61440,
|
||||
properties: {
|
||||
os: "linux",
|
||||
browser: "ion_",
|
||||
device: "my_library"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.connection.send(JSON.stringify(idObj));
|
||||
}
|
||||
|
||||
|
||||
messageRecieved(msg) {
|
||||
this.emit("messageRecieved", msg);
|
||||
}
|
||||
|
||||
ready() {
|
||||
this.emit('ready');
|
||||
}
|
||||
|
||||
customError(err) {
|
||||
this.emit('error', err);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {String} token
|
||||
*/
|
||||
async login(token) {
|
||||
this.ws = new WebSocketClient({maxReceivedFrameSize: Infinity});
|
||||
this.#token = token;
|
||||
|
||||
this.ws.on('connect', async (connection) => {
|
||||
connection.on('message', async (msg) => {
|
||||
const data = JSON.parse(msg.utf8Data);
|
||||
|
||||
const response = await handleResponses(data);
|
||||
|
||||
if (response.op == 10) { this.#startHeartBeat(response.heartBeat, token); }
|
||||
else if (response.op == 0) {
|
||||
if (response.t == gateWayEvents.Ready) {
|
||||
this.user_profile = response.profile;
|
||||
this.user_settings = response.config;
|
||||
this.ready();
|
||||
}
|
||||
else if (response.t == gateWayEvents.MessageCreate) {
|
||||
this.messageRecieved(response.message);
|
||||
}
|
||||
else console.log(response.t);
|
||||
} else {
|
||||
console.log(response.t);
|
||||
}
|
||||
});
|
||||
|
||||
connection.on('close', (code, desc) => {
|
||||
console.log(`CONNECTION CLOSED WITH CODE ${code}\nREASON:\n ${desc}`);
|
||||
});
|
||||
|
||||
this.connection = connection;
|
||||
});
|
||||
|
||||
this.ws.on('connectFailed', (err) => { console.error(err); })
|
||||
|
||||
this.ws.connect("wss://gateway.discord.gg/?v=10&encoding=json");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//All client properties will be re-routed through this export
|
||||
module.exports = { Client, gateWayIntents }
|
||||
@@ -0,0 +1,7 @@
|
||||
const intents = require('../gateway/intents.js');
|
||||
|
||||
|
||||
module.exports = {
|
||||
/**@type {Array<intents>} */
|
||||
intents: []
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
const { exit } = require('process');
|
||||
const gateWayEvents = require('../gateway/dispatch.js');
|
||||
const { message } = require('../messages/message.js');
|
||||
|
||||
|
||||
/**
|
||||
* @description Returns true if this is a READY event and false otherwise
|
||||
* @param {Object} msg
|
||||
* @returns {Promise<Boolean>}
|
||||
*/
|
||||
module.exports = async function handleEvents(msgObj) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const op = msgObj["op"];
|
||||
const t = msgObj["t"];
|
||||
|
||||
if (op == 10) return resolve({op: op, heartBeat: msgObj["d"]["heartbeat_interval"]});
|
||||
|
||||
if (op == 0 && t == gateWayEvents.Ready) {
|
||||
resolve({op: op, t: t, config: msgObj["d"]["user_settings"], profile: msgObj["d"]["user"] });
|
||||
} else if (t == gateWayEvents.MessageCreate) {
|
||||
const msg = new message(msgObj["d"]);
|
||||
resolve({op: op, t: t, message: msg});
|
||||
}
|
||||
|
||||
else {
|
||||
// console.log(t);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
module.exports = Object.freeze({
|
||||
ApplicationCommandPermissionsUpdate: "APPLICATION_COMMAND_PERMISSIONS_UPDATE",
|
||||
ChannelCreate: "CHANNEL_CREATE",
|
||||
ChannelDelete: "CHANNEL_DELETE",
|
||||
ChannelPinsUpdate: "CHANNEL_PINS_UPDATE",
|
||||
ChannelUpdate: "CHANNEL_UPDATE",
|
||||
GuildBanAdd: "GUILD_BAN_ADD",
|
||||
GuildBanRemove: "GUILD_BAN_REMOVE",
|
||||
GuildCreate: "GUILD_CREATE",
|
||||
GuildDelete: "GUILD_DELETE",
|
||||
GuildEmojisUpdate: "GUILD_EMOJIS_UPDATE",
|
||||
GuildIntegrationsUpdate: "GUILD_INTEGRATIONS_UPDATE",
|
||||
GuildMemberAdd: "GUILD_MEMBER_ADD",
|
||||
GuildMemberRemove: "GUILD_MEMBER_REMOVE",
|
||||
GuildMembersChunk: "GUILD_MEMBERS_CHUNK",
|
||||
GuildMemberUpdate: "GUILD_MEMBER_UPDATE",
|
||||
GuildRoleCreate: "GUILD_ROLE_CREATE",
|
||||
GuildRoleDelete: "GUILD_ROLE_DELETE",
|
||||
GuildRoleUpdate: "GUILD_ROLE_UPDATE",
|
||||
GuildStickersUpdate: "GUILD_STICKERS_UPDATE",
|
||||
GuildUpdate: "GUILD_UPDATE",
|
||||
IntegrationCreate: "INTEGRATION_CREATE",
|
||||
IntegrationDelete: "INTEGRATION_DELETE",
|
||||
IntegrationUpdate: "INTEGRATION_UPDATE",
|
||||
InteractionCreate: "INTERACTION_CREATE",
|
||||
InviteCreate: "INVITE_CREATE",
|
||||
InviteDelete: "INVITE_DELETE",
|
||||
MessageCreate: "MESSAGE_CREATE",
|
||||
MessageDelete: "MESSAGE_DELETE",
|
||||
MessageDeleteBulk: "MESSAGE_DELETE_BULK",
|
||||
MessageReactionAdd: "MESSAGE_REACTION_ADD",
|
||||
MessageReactionRemove: "MESSAGE_REACTION_REMOVE",
|
||||
MessageReactionRemoveAll: "MESSAGE_REACTION_REMOVE_ALL",
|
||||
MessageReactionRemoveEmoji: "MESSAGE_REACTION_REMOVE_EMOJI",
|
||||
MessageUpdate: "MESSAGE_UPDATE",
|
||||
PresenceUpdate: "PRESENCE_UPDATE",
|
||||
StageInstanceCreate: "STAGE_INSTANCE_CREATE",
|
||||
StageInstanceDelete: "STAGE_INSTANCE_DELETE",
|
||||
StageInstanceUpdate: "STAGE_INSTANCE_UPDATE",
|
||||
Ready: "READY",
|
||||
Resumed: "RESUMED",
|
||||
ThreadCreate: "THREAD_CREATE",
|
||||
ThreadDelete: "THREAD_DELETE",
|
||||
ThreadListSync: "THREAD_LIST_SYNC",
|
||||
ThreadMembersUpdate: "THREAD_MEMBERS_UPDATE",
|
||||
ThreadMemberUpdate: "THREAD_MEMBER_UPDATE",
|
||||
ThreadUpdate: "THREAD_UPDATE",
|
||||
TypingStart: "TYPING_START",
|
||||
UserUpdate: "USER_UPDATE",
|
||||
VoiceServerUpdate: "VOICE_SERVER_UPDATE",
|
||||
VoiceStateUpdate: "VOICE_STATE_UPDATE",
|
||||
WebhooksUpdate: "WEBHOOKS_UPDATE",
|
||||
GuildScheduledEventCreate: "GUILD_SCHEDULED_EVENT_CREATE",
|
||||
GuildScheduledEventUpdate: "GUILD_SCHEDULED_EVENT_UPDATE",
|
||||
GuildScheduledEventDelete: "GUILD_SCHEDULED_EVENT_DELETE",
|
||||
GuildScheduledEventUserAdd: "GUILD_SCHEDULED_EVENT_USER_ADD",
|
||||
GuildScheduledEventUserRemove: "GUILD_SCHEDULED_EVENT_USER_REMOVE",
|
||||
AutoModerationRuleCreate: "AUTO_MODERATION_RULE_CREATE",
|
||||
AutoModerationRuleUpdate: "AUTO_MODERATION_RULE_UPDATE",
|
||||
AutoModerationRuleDelete: "AUTO_MODERATION_RULE_DELETE",
|
||||
AutoModerationActionExecution: "AUTO_MODERATION_ACTION_EXECUTION"
|
||||
});
|
||||
@@ -0,0 +1,46 @@
|
||||
module.exports = Object.freeze({
|
||||
Guilds: 1 << 0,
|
||||
GuildMembers: 1 << 1,
|
||||
GuildModeration: 1 << 2,
|
||||
GuildEmojisStickers: 1 << 3,
|
||||
GuildIntegrations: 1 << 4,
|
||||
GuildWebhooks: 1 << 5,
|
||||
GuildInvites: 1 << 6,
|
||||
GuildVoiceStates: 1 << 7,
|
||||
GuildPresences: 1 << 8,
|
||||
GuildMessages: 1 << 9,
|
||||
GuildMessageReactions: 1 << 10,
|
||||
GuildMessageTyping: 1 << 11,
|
||||
DirectMessages: 1 << 12,
|
||||
DirectMessageReactions: 1 << 13,
|
||||
DirectMessageTyping: 1 << 14,
|
||||
MessageContent: 1 << 15,
|
||||
GuildScheduledEvents: 1 << 16,
|
||||
AutoModerationConfiguration: 1 << 20,
|
||||
AutoModerationExecution: 1 << 21,
|
||||
});
|
||||
|
||||
/*
|
||||
module.exports = Object.freeze(class intents {
|
||||
constructor() {
|
||||
Guilds = 1 << 0,
|
||||
GuildMembers = 1 << 1,
|
||||
GuildModeration = 1 << 2,
|
||||
GuildEmojisStickers = 1 << 3,
|
||||
GuildIntegrations = 1 << 4,
|
||||
GuildWebhooks = 1 << 5,
|
||||
GuildInvites = 1 << 6,
|
||||
GuildVoiceStates = 1 << 7,
|
||||
GuildPresences = 1 << 8,
|
||||
GuildMessages = 1 << 9,
|
||||
GuildMessageReactions = 1 << 10,
|
||||
GuildMessageTyping = 1 << 11,
|
||||
DirectMessages = 1 << 12,
|
||||
DirectMessageReactions = 1 << 13,
|
||||
DirectMessageTyping = 1 << 14,
|
||||
MessageContent = 1 << 15,
|
||||
GuildScheduledEvents = 1 << 16,
|
||||
AutoModerationConfiguration = 1 << 20,
|
||||
AutoModerationExecution = 1 << 21
|
||||
}
|
||||
});*/
|
||||
@@ -0,0 +1,17 @@
|
||||
const axios = require("axios").create({baseUrl: "https://jsonplaceholder.typicode.com/"});
|
||||
|
||||
class Channel {
|
||||
/** @type {String} */
|
||||
id;
|
||||
|
||||
/**
|
||||
* @param {Object} inp
|
||||
*/
|
||||
async send(inp) {
|
||||
const toSend = (typeof inp == 'string') ? {content: inp} : inp;
|
||||
const response = axios.post(`${id}/messages`, {
|
||||
// Authorization:
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
const messageChannelTypes = require('./messageChannelTypes.js');
|
||||
|
||||
|
||||
class message {
|
||||
|
||||
|
||||
/** @type {Object} */
|
||||
author;
|
||||
|
||||
/** @type {Object} */
|
||||
channel_id;
|
||||
|
||||
/** @type {Object[]} */
|
||||
mentions;
|
||||
|
||||
/** @type {Object} */
|
||||
member;
|
||||
|
||||
/** @type {String} */
|
||||
id;
|
||||
|
||||
/** @type {Object} */
|
||||
content;
|
||||
|
||||
/** @type {Object[]} */
|
||||
attachments;
|
||||
|
||||
/** @type {String} */
|
||||
guild_id;
|
||||
|
||||
/** @type {Object} */
|
||||
type;
|
||||
|
||||
|
||||
/**
|
||||
* @param {Object} msgRaw
|
||||
*/
|
||||
constructor(msgRaw) {
|
||||
for (const k in this) {
|
||||
if (msgRaw[k] != undefined) {
|
||||
if (k == 'type') {
|
||||
this.type = (msgRaw['guild_id']) ? msgRaw[k] : 1;
|
||||
} else {
|
||||
this[k] = msgRaw[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = { message, messageChannelTypes };
|
||||
@@ -0,0 +1,81 @@
|
||||
//Blatantly stolen from https://github.com/discordjs/discord-api-types/blob/main/gateway/v10.ts
|
||||
|
||||
|
||||
module.exports = Object.freeze({
|
||||
/**
|
||||
* A text channel within a guild
|
||||
*/
|
||||
GuildText: 0,
|
||||
/**
|
||||
* A direct message between users
|
||||
*/
|
||||
DM: 1,
|
||||
/**
|
||||
* A voice channel within a guild
|
||||
*/
|
||||
GuildVoice: 2,
|
||||
/**
|
||||
* A direct message between multiple users
|
||||
*/
|
||||
GroupDM: 3,
|
||||
/**
|
||||
* An organizational category that contains up to 50 channels
|
||||
*
|
||||
* See https://support.discord.com/hc/articles/115001580171
|
||||
*/
|
||||
GuildCategory: 4,
|
||||
/**
|
||||
* A channel that users can follow and crosspost into their own guild
|
||||
*
|
||||
* See https://support.discord.com/hc/articles/360032008192
|
||||
*/
|
||||
GuildAnnouncement: 5,
|
||||
/**
|
||||
* A temporary sub-channel within a Guild Announcement channel
|
||||
*/
|
||||
AnnouncementThread: 10,
|
||||
/**
|
||||
* A temporary sub-channel within a Guild Text or Guild Forum channel
|
||||
*/
|
||||
PublicThread: 11,
|
||||
/**
|
||||
* A temporary sub-channel within a Guild Text channel that is only viewable by those invited and those with the Manage Threads permission
|
||||
*/
|
||||
PrivateThread: 12,
|
||||
/**
|
||||
* A voice channel for hosting events with an audience
|
||||
*
|
||||
* See https://support.discord.com/hc/articles/1500005513722
|
||||
*/
|
||||
GuildStageVoice: 13,
|
||||
/**
|
||||
* The channel in a Student Hub containing the listed servers
|
||||
*
|
||||
* See https://support.discord.com/hc/articles/4406046651927
|
||||
*/
|
||||
GuildDirectory: 14,
|
||||
/**
|
||||
* A channel that can only contain threads
|
||||
*/
|
||||
GuildForum: 15,
|
||||
/**
|
||||
* A channel that users can follow and crosspost into their own guild
|
||||
*
|
||||
* @deprecated This is the old name for {@apilink ChannelType#GuildAnnouncement}
|
||||
*
|
||||
* See https://support.discord.com/hc/articles/360032008192
|
||||
*/
|
||||
GuildNews: 5,
|
||||
/**
|
||||
* A temporary sub-channel within a Guild Announcement channel
|
||||
*
|
||||
* @deprecated This is the old name for {@apilink ChannelType#AnnouncementThread}
|
||||
*/
|
||||
GuildNewsThread: 10,
|
||||
/**
|
||||
* A temporary sub-channel within a Guild Text channel
|
||||
*
|
||||
* @deprecated This is the old name for {@apilink ChannelType#PublicThread}
|
||||
*/
|
||||
GuildPublicThread: 11,
|
||||
});
|
||||
Reference in New Issue
Block a user