discord-user-bots
Advanced tools
Comparing version 1.2.3 to 1.2.4
{ | ||
"name": "discord-user-bots", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"description": "I library that allows you to use the full potential of Discords api to create good user bots.", | ||
@@ -5,0 +5,0 @@ "main": "src/exports.js", |
417
README.md
@@ -48,4 +48,11 @@ # Sopur's user bot library | ||
// ^ | ||
// Make this second parameter true if you want to use a http link, it's false by defualt | ||
// Make this second parameter true if you want to use a http link, it's false by default | ||
// (Deprecated) | ||
// The server invite | ||
// v | ||
client.get_invite_info("invite-code", false); | ||
// ^ | ||
// Make this second parameter true if you want to use a http link, it's false by default | ||
// The guild ID | ||
@@ -229,27 +236,3 @@ // v | ||
}; | ||
this.user_guild_settings = [ | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
]; | ||
this.user_guild_settings = [[Object]]; | ||
this.user = { | ||
@@ -272,379 +255,15 @@ verified: true, | ||
this.session_id = "session_id-goes-here"; | ||
this.relationships = [ | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
]; | ||
this.read_state = [ | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
]; | ||
this.private_channels = [ | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
]; | ||
this.presences = [[Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object]]; | ||
this.relationships = [[Object]]; | ||
this.read_state = [[Object]]; | ||
this.private_channels = [[Object]]; | ||
this.presences = [[Object]]; | ||
this.notes = { | ||
"id-goes-here": "note-goes-here", | ||
}; | ||
this.guilds = [ | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
[Object], | ||
]; | ||
this.guilds = [[Object]]; | ||
this.guild_join_requests = []; | ||
this.guild_experiments = [ | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
]; | ||
this.guild_experiments = [[Array]]; | ||
this.geo_ordered_rtc_regions = ["geo", "ordered", "rtc", "regions", "go", "here"]; | ||
this.friend_suggestion_count = 0; | ||
this.experiments = [ | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
[Array], | ||
]; | ||
this.experiments = [[Array]]; | ||
this.country_code = "country-goes-here"; | ||
@@ -659,3 +278,3 @@ this.consents = { personalization: [Object] }; | ||
The soft-ban on self bots that disallows self bots to not see contents of messages has been evaded. | ||
You can now see message contents and bypass this soft-ban. | ||
Deprecated join_guild because it could disable your account | ||
Add invite info function |
@@ -13,3 +13,3 @@ const fetch = require("node-fetch"); | ||
language: "en-US", | ||
typinginterval: 1000 | ||
typinginterval: 1000, | ||
}; | ||
@@ -19,19 +19,20 @@ this.token = token; | ||
this.ready_status = 0; | ||
this.typingLoop = function () { }; | ||
this.typingLoop = function () {}; | ||
this.on = { | ||
gateway: function () { }, | ||
heartbeat_sent: function () { }, | ||
heartbeat_received: function () { }, | ||
ready: function () { }, | ||
message_create: function (message) { }, | ||
message_edit: function (message) { }, | ||
message_delete: function (message) { }, | ||
message_delete_bulk: function (message) { }, | ||
embed_sent: function (message) { }, | ||
presence_update: function (message) { }, | ||
sessions_replace: function (message) { }, | ||
message_read: function (message) { }, | ||
channel_update: function (message) { }, | ||
guild_join: function (message) { }, | ||
guild_leave: function (message) { }, | ||
discord_disconnect: function () {}, | ||
gateway: function () {}, | ||
heartbeat_sent: function () {}, | ||
heartbeat_received: function () {}, | ||
ready: function () {}, | ||
message_create: function (message) {}, | ||
message_edit: function (message) {}, | ||
message_delete: function (message) {}, | ||
message_delete_bulk: function (message) {}, | ||
embed_sent: function (message) {}, | ||
presence_update: function (message) {}, | ||
sessions_replace: function (message) {}, | ||
message_read: function (message) {}, | ||
channel_update: function (message) {}, | ||
guild_join: function (message) {}, | ||
guild_leave: function (message) {}, | ||
@@ -68,4 +69,4 @@ /* I'll add these later... | ||
this.checkToken().then((res) => { | ||
if (res === true) this.setEvents() | ||
else throw new Error(`Token "${token}" is invalid`); | ||
if (res === true) this.setEvents(); | ||
else throw new Error(`Discord rejected token "${token}" (Not valid)`); | ||
}); | ||
@@ -80,3 +81,4 @@ } | ||
switch (message.t) { | ||
case null: { // gateway | ||
case null: { | ||
// gateway | ||
if (this.ready_status === 0) { | ||
@@ -92,13 +94,14 @@ this.heartbeattimer = message.d.heartbeat_interval; | ||
this.on.heartbeat_received(); | ||
}; | ||
} | ||
break; | ||
} | ||
case "READY": { // Gateway res | ||
case "READY": { | ||
// Gateway res | ||
let user = message.d; | ||
this.user_settings = user.user_settings; // An object full of properties of settings | ||
this.user = user.user // An object full of properties about the user like username etc | ||
this.user = user.user; // An object full of properties about the user like username etc | ||
this.tutorial = user.tutorial; // A property | ||
this.session_id = user.session_id; // String of random characters | ||
this.notes = user.notes; // An object that contains all the notes the user has on other people | ||
this.guild_join_requests = user.guild_join_requests // An array | ||
this.guild_join_requests = user.guild_join_requests; // An array | ||
this.user_guild_settings = user.user_guild_settings; // An array of Objects | ||
@@ -123,3 +126,3 @@ this.relationships = user.relationships; // An array of Objects | ||
break; | ||
}; | ||
} | ||
case "MESSAGE_CREATE": { | ||
@@ -131,7 +134,9 @@ this.on.message_create(message.d); | ||
switch (message.type) { | ||
case undefined: { // Embed | ||
case undefined: { | ||
// Embed | ||
this.on.embed_sent(message.d); | ||
break; | ||
} | ||
case 0: { // Message edit | ||
case 0: { | ||
// Message edit | ||
this.on.message_edit(message.d); | ||
@@ -174,13 +179,15 @@ break; | ||
} | ||
}; | ||
} | ||
}); | ||
}; | ||
ws.on("close", this.on.discord_disconnect); | ||
} | ||
/** | ||
* Checks if the token is valid | ||
* @returns {Promise<boolean} | ||
*/ | ||
checkToken() { | ||
return new Promise((resolve) => { | ||
fetch( | ||
`https://discord.com/api/${this.config.api}/users/@me`, | ||
new Packet.tokenCheck(this.token) | ||
).then((r) => { | ||
fetch(`https://discord.com/api/${this.config.api}/users/@me`, new Packet.tokenCheck(this.token)).then((r) => { | ||
r.json().then((res) => { | ||
@@ -193,3 +200,2 @@ resolve(res.message !== "401: Unauthorized"); | ||
async fetchmessages(limit, channelid) { | ||
@@ -200,6 +206,6 @@ if (this.ready_status === 0) return new Error("Client still in connecting state."); | ||
fetch(`https://discord.com/api/${this.config.api}/channels/${channelid}/messages?limit=${limit}`, { | ||
"headers": { | ||
"accept": "*/*", | ||
headers: { | ||
accept: "*/*", | ||
"accept-language": this.config.language, | ||
"authorization": this.token, | ||
authorization: this.token, | ||
"sec-fetch-dest": "empty", | ||
@@ -209,10 +215,10 @@ "sec-fetch-mode": "cors", | ||
}, | ||
"referrer": `https://discord.com/channels/@me/${channelid}`, | ||
"referrerPolicy": "no-referrer-when-downgrade", | ||
"body": null, | ||
"method": "GET", | ||
"mode": "cors", | ||
"credentials": "include" | ||
referrer: `https://discord.com/channels/@me/${channelid}`, | ||
referrerPolicy: "no-referrer-when-downgrade", | ||
body: null, | ||
method: "GET", | ||
mode: "cors", | ||
credentials: "include", | ||
}).then((response) => { | ||
response.json().then(m => { | ||
response.json().then((m) => { | ||
res(m); | ||
@@ -222,3 +228,3 @@ }); | ||
}); | ||
}; | ||
} | ||
@@ -228,3 +234,3 @@ /** | ||
* @param {string} guildid The guild ID to fetch | ||
* @returns {object} The guild info | ||
* @returns {Promise<Object>} The guild info | ||
*/ | ||
@@ -236,6 +242,6 @@ async getguild(guildid) { | ||
fetch(`https://discord.com/api/${this.config.api}/guilds/${guildid}`, { | ||
"headers": { | ||
"accept": "*/*", | ||
headers: { | ||
accept: "*/*", | ||
"accept-language": this.config.language, | ||
"authorization": this.token, | ||
authorization: this.token, | ||
"sec-fetch-dest": "empty", | ||
@@ -245,10 +251,10 @@ "sec-fetch-mode": "cors", | ||
}, | ||
"referrer": `https://discord.com/channels/@me`, | ||
"referrerPolicy": "no-referrer-when-downgrade", | ||
"body": null, | ||
"method": "GET", | ||
"mode": "cors", | ||
"credentials": "include" | ||
referrer: `https://discord.com/channels/@me`, | ||
referrerPolicy: "no-referrer-when-downgrade", | ||
body: null, | ||
method: "GET", | ||
mode: "cors", | ||
credentials: "include", | ||
}).then((response) => { | ||
response.json().then(m => { | ||
response.json().then((m) => { | ||
res(m); | ||
@@ -258,9 +264,11 @@ }); | ||
}); | ||
}; | ||
} | ||
/** | ||
* Joins a server or group chat | ||
* Gets info about the invite code givin | ||
* @param {string} invite The Discord invite | ||
* @param {boolean} trim If this is set to true, the invite will be stripped of the "https://discord.gg/" automatically, otherwise it will just send the invite param given | ||
* @returns {Object} The response from Discord | ||
* @returns {Promise<Object>} The response from Discord | ||
* @deprecated | ||
* @warn Make disable your account | ||
*/ | ||
@@ -273,6 +281,7 @@ async join_guild(invite, trim = false) { | ||
fetch(`https://discord.com/api/${this.config.api}/invites/${invite}`, { | ||
"headers": { | ||
"accept": "*/*", | ||
headers: { | ||
accept: "*/*", | ||
"accept-language": this.config.language, | ||
"authorization": this.token, | ||
authorization: this.token, | ||
"content-type": "application/json", | ||
"sec-fetch-dest": "empty", | ||
@@ -282,9 +291,9 @@ "sec-fetch-mode": "cors", | ||
}, | ||
"referrer": "https://discord.com/channels/@me", | ||
"referrerPolicy": "no-referrer-when-downgrade", | ||
"body": null, | ||
"method": "POST", | ||
"mode": "cors" | ||
referrer: "https://discord.com/channels/@me", | ||
referrerPolicy: "no-referrer-when-downgrade", | ||
body: "{}", | ||
method: "POST", | ||
mode: "cors", | ||
}).then((response) => { | ||
response.json().then(m => { | ||
response.json().then((m) => { | ||
res(m); | ||
@@ -294,8 +303,44 @@ }); | ||
}); | ||
}; | ||
} | ||
/** | ||
* Joins a server or group chat | ||
* @param {string} invite The Discord invite | ||
* @param {boolean} trim If this is set to true, the invite will be stripped of the "https://discord.gg/" automatically, otherwise it will just send the invite param given | ||
* @returns {Promise<Object>} The response from Discord | ||
*/ | ||
async get_invite_info(invite, trim = false) { | ||
if (this.ready_status === 0) return new Error("Client still in connecting state."); | ||
if (!invite) return new Error("Invalid parameters"); | ||
if (trim) invite = invite.split("https://discord.gg/")[1]; | ||
return new Promise((res, rej) => { | ||
fetch( | ||
`https://discord.com/api/${this.config.api}/invites/${invite}?inputValue=https%3A%2F%2Fdiscord.gg%2F${invite}&with_counts=true&with_expiration=true`, | ||
{ | ||
headers: { | ||
accept: "*/*", | ||
"accept-language": this.config.language, | ||
authorization: this.token, | ||
"sec-fetch-dest": "empty", | ||
"sec-fetch-mode": "cors", | ||
"sec-fetch-site": "same-origin", | ||
}, | ||
referrer: "https://discord.com/channels/@me", | ||
referrerPolicy: "no-referrer-when-downgrade", | ||
body: null, | ||
method: "GET", | ||
mode: "cors", | ||
} | ||
).then((response) => { | ||
response.json().then((m) => { | ||
res(m); | ||
}); | ||
}); | ||
}); | ||
} | ||
/** | ||
* Leaves a server | ||
* @param {string} guildid The guild ID to leave from | ||
* @returns {Object} The response from Discord | ||
* @returns {Promise<Object>} The response from Discord | ||
*/ | ||
@@ -307,15 +352,15 @@ async leave_guild(guildid) { | ||
fetch(`https://discord.com/api/${this.config.api}/users/@me/guilds/${guildid}`, { | ||
"headers": { | ||
"accept": "*/*", | ||
headers: { | ||
accept: "*/*", | ||
"accept-language": this.config.language, | ||
"authorization": this.token, | ||
authorization: this.token, | ||
"sec-fetch-dest": "empty", | ||
"sec-fetch-mode": "cors", | ||
"sec-fetch-site": "same-origin" | ||
"sec-fetch-site": "same-origin", | ||
}, | ||
"referrer": "https://discord.com/channels/@me", | ||
"referrerPolicy": "no-referrer-when-downgrade", | ||
"body": null, | ||
"method": "DELETE", | ||
"mode": "cors" | ||
referrer: "https://discord.com/channels/@me", | ||
referrerPolicy: "no-referrer-when-downgrade", | ||
body: null, | ||
method: "DELETE", | ||
mode: "cors", | ||
}).then((response) => { | ||
@@ -325,3 +370,3 @@ res(response); | ||
}); | ||
}; | ||
} | ||
@@ -332,3 +377,3 @@ /** | ||
* @param {string} channelid The channel you want to send it in | ||
* @returns {object} The message info | ||
* @returns {Promise<Object>} The message info | ||
*/ | ||
@@ -340,22 +385,22 @@ async send(message, channelid) { | ||
fetch(`https://discord.com/api/${this.config.api}/channels/${channelid}/messages`, { | ||
"headers": { | ||
"accept": "*/*", | ||
headers: { | ||
accept: "*/*", | ||
"accept-language": this.config.language, | ||
"authorization": this.token, | ||
authorization: this.token, | ||
"content-type": "application/json", | ||
"sec-fetch-dest": "empty", | ||
"sec-fetch-mode": "cors", | ||
"sec-fetch-site": "same-origin" | ||
"sec-fetch-site": "same-origin", | ||
}, | ||
"referrer": `https://discord.com/channels/@me/${channelid}`, | ||
"referrerPolicy": "no-referrer-when-downgrade", | ||
"body": JSON.stringify({ | ||
"content": message, | ||
"nonce": "", | ||
"tts": false, | ||
referrer: `https://discord.com/channels/@me/${channelid}`, | ||
referrerPolicy: "no-referrer-when-downgrade", | ||
body: JSON.stringify({ | ||
content: message, | ||
nonce: "", | ||
tts: false, | ||
}), | ||
"method": "POST", | ||
"mode": "cors" | ||
method: "POST", | ||
mode: "cors", | ||
}).then((response) => { | ||
response.json().then(m => { | ||
response.json().then((m) => { | ||
res(m); | ||
@@ -365,3 +410,3 @@ }); | ||
}); | ||
}; | ||
} | ||
@@ -373,3 +418,3 @@ /** | ||
* @param {string} channelid The channel ID of the message | ||
* @returns {object} The message info | ||
* @returns {Promise<Object>} The message info | ||
*/ | ||
@@ -381,6 +426,6 @@ async reply(message, targetmessageid, channelid) { | ||
fetch(`https://discord.com/api/${this.config.api}/channels/${channelid}/messages`, { | ||
"headers": { | ||
"accept": "*/*", | ||
headers: { | ||
accept: "*/*", | ||
"accept-language": this.config.language, | ||
"authorization": this.token, | ||
authorization: this.token, | ||
"content-type": "application/json", | ||
@@ -391,25 +436,21 @@ "sec-fetch-dest": "empty", | ||
}, | ||
"referrer": `https://discord.com/channels/@me/${channelid}`, | ||
"referrerPolicy": "no-referrer-when-downgrade", | ||
"body": JSON.stringify({ | ||
"content": message, | ||
"nonce": "", | ||
"tts": false, | ||
"message_reference": { | ||
"channel_id": channelid, | ||
"message_id": targetmessageid | ||
referrer: `https://discord.com/channels/@me/${channelid}`, | ||
referrerPolicy: "no-referrer-when-downgrade", | ||
body: JSON.stringify({ | ||
content: message, | ||
nonce: "", | ||
tts: false, | ||
message_reference: { | ||
channel_id: channelid, | ||
message_id: targetmessageid, | ||
}, | ||
"allowed_mentions": { | ||
"parse": [ | ||
"users", | ||
"roles", | ||
"everyone" | ||
], | ||
"replied_user": false | ||
allowed_mentions: { | ||
parse: ["users", "roles", "everyone"], | ||
replied_user: false, | ||
}, | ||
}), | ||
"method": "POST", | ||
"mode": "cors" | ||
method: "POST", | ||
mode: "cors", | ||
}).then((response) => { | ||
response.json().then(m => { | ||
response.json().then((m) => { | ||
res(m); | ||
@@ -419,3 +460,3 @@ }); | ||
}); | ||
}; | ||
} | ||
@@ -426,3 +467,3 @@ /** | ||
* @param {string} channelid The channel the message is in | ||
* @returns {object} The response from Discord | ||
* @returns {Promise<Object>} The response from Discord | ||
*/ | ||
@@ -434,6 +475,6 @@ async delete_message(targetmessageid, channelid) { | ||
fetch(`https://discord.com/api/${this.config.api}/channels/${channelid}/messages/${targetmessageid}`, { | ||
"headers": { | ||
"accept": "*/*", | ||
headers: { | ||
accept: "*/*", | ||
"accept-language": this.config.language, | ||
"authorization": this.token, | ||
authorization: this.token, | ||
"sec-fetch-dest": "empty", | ||
@@ -443,8 +484,8 @@ "sec-fetch-mode": "cors", | ||
}, | ||
"referrer": `https://discord.com/channels/@me/${channelid}`, | ||
"referrerPolicy": "no-referrer-when-downgrade", | ||
"body": null, | ||
"method": "DELETE", | ||
"mode": "cors", | ||
"credentials": "include" | ||
referrer: `https://discord.com/channels/@me/${channelid}`, | ||
referrerPolicy: "no-referrer-when-downgrade", | ||
body: null, | ||
method: "DELETE", | ||
mode: "cors", | ||
credentials: "include", | ||
}).then((response) => { | ||
@@ -454,3 +495,3 @@ res(response); | ||
}); | ||
}; | ||
} | ||
@@ -466,36 +507,35 @@ /** | ||
fetch(`https://discord.com/api/${this.config.api}/channels/${channelid}/typing`, { | ||
"headers": { | ||
"accept": "*/*", | ||
headers: { | ||
accept: "*/*", | ||
"accept-language": this.config.language, | ||
"authorization": this.token, | ||
authorization: this.token, | ||
"sec-fetch-dest": "empty", | ||
"sec-fetch-mode": "cors", | ||
"sec-fetch-site": "same-origin" | ||
"sec-fetch-site": "same-origin", | ||
}, | ||
"referrer": `https://discord.com/channels/@me/${channelid}`, | ||
"referrerPolicy": "no-referrer-when-downgrade", | ||
"body": null, | ||
"method": "POST", | ||
"mode": "cors" | ||
referrer: `https://discord.com/channels/@me/${channelid}`, | ||
referrerPolicy: "no-referrer-when-downgrade", | ||
body: null, | ||
method: "POST", | ||
mode: "cors", | ||
}); | ||
this.typingLoop = setInterval(() => { | ||
fetch(`https://discord.com/api/${this.config.api}/channels/${channelid}/typing`, { | ||
"headers": { | ||
"accept": "*/*", | ||
headers: { | ||
accept: "*/*", | ||
"accept-language": this.config.language, | ||
"authorization": this.token, | ||
authorization: this.token, | ||
"sec-fetch-dest": "empty", | ||
"sec-fetch-mode": "cors", | ||
"sec-fetch-site": "same-origin" | ||
"sec-fetch-site": "same-origin", | ||
}, | ||
"referrer": `https://discord.com/channels/@me/${channelid}`, | ||
"referrerPolicy": "no-referrer-when-downgrade", | ||
"body": null, | ||
"method": "POST", | ||
"mode": "cors" | ||
referrer: `https://discord.com/channels/@me/${channelid}`, | ||
referrerPolicy: "no-referrer-when-downgrade", | ||
body: null, | ||
method: "POST", | ||
mode: "cors", | ||
}); | ||
}, this.config.typinginterval); | ||
}; | ||
} | ||
@@ -506,3 +546,3 @@ async stopType() { | ||
return true; | ||
}; | ||
} | ||
@@ -512,3 +552,3 @@ /** | ||
* @param {Array} recipients The people to be in the group when it's made | ||
* @returns {object} The group info | ||
* @returns {Promise<Object>} The group info | ||
*/ | ||
@@ -521,6 +561,6 @@ async create_group(recipients) { | ||
fetch(`https://discord.com/api/${this.config.api}/users/@me/channels`, { | ||
"headers": { | ||
"accept": "*/*", | ||
headers: { | ||
accept: "*/*", | ||
"accept-language": this.config.language, | ||
"authorization": this.token, | ||
authorization: this.token, | ||
"content-type": "application/json", | ||
@@ -531,11 +571,11 @@ "sec-fetch-dest": "empty", | ||
}, | ||
"referrer": "https://discord.com/channels/@me/", | ||
"referrerPolicy": "no-referrer-when-downgrade", | ||
"body": JSON.stringify({ | ||
"recipients": recipients, | ||
referrer: "https://discord.com/channels/@me/", | ||
referrerPolicy: "no-referrer-when-downgrade", | ||
body: JSON.stringify({ | ||
recipients: recipients, | ||
}), | ||
"method": "POST", | ||
"mode": "cors", | ||
method: "POST", | ||
mode: "cors", | ||
}).then((response) => { | ||
response.json().then(m => { | ||
response.json().then((m) => { | ||
res(m); | ||
@@ -545,3 +585,3 @@ }); | ||
}); | ||
}; | ||
} | ||
@@ -551,3 +591,3 @@ /** | ||
* @param {string} groupid The group ID to leave | ||
* @returns {object} The response from Discord | ||
* @returns {Promise<Object>} The response from Discord | ||
*/ | ||
@@ -559,6 +599,6 @@ async leave_group(groupid) { | ||
fetch(`https://discord.com/api/${this.config.api}/channels/${groupid}`, { | ||
"headers": { | ||
"accept": "*/*", | ||
headers: { | ||
accept: "*/*", | ||
"accept-language": this.config.language, | ||
"authorization": this.token, | ||
authorization: this.token, | ||
"sec-fetch-dest": "empty", | ||
@@ -568,9 +608,9 @@ "sec-fetch-mode": "cors", | ||
}, | ||
"referrer": "https://discord.com/channels/@me", | ||
"referrerPolicy": "no-referrer-when-downgrade", | ||
"body": null, | ||
"method": "DELETE", | ||
"mode": "cors", | ||
referrer: "https://discord.com/channels/@me", | ||
referrerPolicy: "no-referrer-when-downgrade", | ||
body: null, | ||
method: "DELETE", | ||
mode: "cors", | ||
}).then((response) => { | ||
response.json().then(m => { | ||
response.json().then((m) => { | ||
res(m); | ||
@@ -580,3 +620,3 @@ }); | ||
}); | ||
}; | ||
} | ||
@@ -587,3 +627,3 @@ /** | ||
* @param {string} channelid Group ID to have someone removed from | ||
* @returns {object} The response from Discord | ||
* @returns {Promise<Object>} The response from Discord | ||
*/ | ||
@@ -595,6 +635,6 @@ async remove_person_from_group(personid, channelid) { | ||
fetch(`https://discord.com/api/${this.config.api}/channels/${channelid}/recipients/${personid}`, { | ||
"headers": { | ||
"accept": "*/*", | ||
headers: { | ||
accept: "*/*", | ||
"accept-language": this.config.language, | ||
"authorization": this.token, | ||
authorization: this.token, | ||
"sec-fetch-dest": "empty", | ||
@@ -604,7 +644,7 @@ "sec-fetch-mode": "cors", | ||
}, | ||
"referrer": "https://discord.com/channels/@me", | ||
"referrerPolicy": "no-referrer-when-downgrade", | ||
"body": null, | ||
"method": "DELETE", | ||
"mode": "cors" | ||
referrer: "https://discord.com/channels/@me", | ||
referrerPolicy: "no-referrer-when-downgrade", | ||
body: null, | ||
method: "DELETE", | ||
mode: "cors", | ||
}).then((response) => { | ||
@@ -614,3 +654,3 @@ res(response); | ||
}); | ||
}; | ||
} | ||
@@ -621,3 +661,3 @@ /** | ||
* @param {string} channelid The group ID to be renamed | ||
* @returns {object} The response from Discord | ||
* @returns {Promise<Object>} The response from Discord | ||
*/ | ||
@@ -629,6 +669,6 @@ async rename_group(name, groupid) { | ||
fetch(`https://discord.com/api/${this.config.api}/channels/${groupid}`, { | ||
"headers": { | ||
"accept": "*/*", | ||
headers: { | ||
accept: "*/*", | ||
"accept-language": this.config.language, | ||
"authorization": this.token, | ||
authorization: this.token, | ||
"content-type": "application/json", | ||
@@ -639,9 +679,9 @@ "sec-fetch-dest": "empty", | ||
}, | ||
"referrer": "https://discord.com/channels/@me", | ||
"referrerPolicy": "no-referrer-when-downgrade", | ||
"body": JSON.stringify({ | ||
"name": name | ||
referrer: "https://discord.com/channels/@me", | ||
referrerPolicy: "no-referrer-when-downgrade", | ||
body: JSON.stringify({ | ||
name: name, | ||
}), | ||
"method": "PATCH", | ||
"mode": "cors" | ||
method: "PATCH", | ||
mode: "cors", | ||
}).then((response) => { | ||
@@ -651,3 +691,3 @@ res(response); | ||
}); | ||
}; | ||
} | ||
@@ -658,3 +698,3 @@ /** | ||
* @param {string} guild_template_code The template of the server, it's set to the defualt server template when not set by you | ||
* @returns {object} The server info | ||
* @returns {Promise<Object>} The server info | ||
*/ | ||
@@ -666,6 +706,6 @@ async create_server(name, guild_template_code = "2TffvPucqHkN") { | ||
fetch(`https://discord.com/api/${this.config.api}/guilds`, { | ||
"headers": { | ||
"accept": "*/*", | ||
headers: { | ||
accept: "*/*", | ||
"accept-language": this.config.language, | ||
"authorization": this.token, | ||
authorization: this.token, | ||
"content-type": "application/json", | ||
@@ -676,15 +716,15 @@ "sec-fetch-dest": "empty", | ||
}, | ||
"referrer": "https://discord.com/channels/@me", | ||
"referrerPolicy": "no-referrer-when-downgrade", | ||
"body": JSON.stringify({ | ||
"name": name, | ||
"icon": null, | ||
"channels": [], | ||
"system_channel_id": null, | ||
"guild_template_code": guild_template_code, | ||
referrer: "https://discord.com/channels/@me", | ||
referrerPolicy: "no-referrer-when-downgrade", | ||
body: JSON.stringify({ | ||
name: name, | ||
icon: null, | ||
channels: [], | ||
system_channel_id: null, | ||
guild_template_code: guild_template_code, | ||
}), | ||
"method": "POST", | ||
"mode": "cors" | ||
method: "POST", | ||
mode: "cors", | ||
}).then((response) => { | ||
response.json().then(m => { | ||
response.json().then((m) => { | ||
res(m); | ||
@@ -694,5 +734,5 @@ }); | ||
}); | ||
}; | ||
}; | ||
} | ||
} | ||
module.exports = Client; |
const Discord = require("./src/exports.js"); | ||
const client = new Discord.Client("NzUzMjM2Nzk2Nzk5OTc1NTU0.YKRt4w.ay3V1C-6-goITABUdEj9JfxK8Kg"); // Login with the token given | ||
const client = new Discord.Client("NzUzMjM2Nzk2Nzk5OTc1NTU0.YQ0PDA.7mz8LNHb3PtSFw8mAMibMFB6KmM"); | ||
client.on.ready = function (message) { // Executes this function when the client is ready | ||
client.send("Tst", "807359548137537597"); | ||
client.on.ready = function () { | ||
console.log("Client online!"); | ||
client.join_guild("mG5GmwEn", false).then(console.log); | ||
}; |
1021
57180
277
16