-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
15 changed files
with
1,791 additions
and
1,536 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Extending Discord.js-selfbot-v13 | ||
> `credit: Discum` | ||
How to add extra API wraps to Discord.js-selfbot-v13? | ||
# Table of Contents | ||
- [HTTP APIs](#HTTP-APIs) | ||
- [Gateway APIs](#Gateway-APIs) | ||
|
||
### HTTP APIs: | ||
|
||
```js | ||
URL example: | ||
'https://discord.com/api/v9/users/@me' | ||
const url = client.api.users['@me']; | ||
/* Method: GET | POST | PUT | PATCH | DELETE */ | ||
``` | ||
|
||
|
||
###### GET: | ||
```js | ||
await client.api.users['@me'].get({ versioned: true }); | ||
/* Request: https://discord.com/api/v9/users/@me */ | ||
await client.api.users['@me'].get({ versioned: false }); | ||
/* Request: https://discord.com/api/users/@me */ | ||
``` | ||
###### POST: | ||
```js | ||
await client.api.channels[channel.id].messages.post({ versioned: true, data: {}, files: [] }); | ||
/* Request: https://discord.com/api/v9/channels/{channel.id}/messages */ | ||
``` | ||
###### PUT: | ||
```js | ||
await client.api | ||
.guilds(guild.id) | ||
.bans(user.id) | ||
.put({ | ||
versioned: true, | ||
data: {}, | ||
}); | ||
/* Request: https://discord.com/api/guilds/{guild.id}/bans/{user.id} */ | ||
``` | ||
###### PATCH: | ||
```js | ||
await client.api.users['@me'].patch({ versioned: true, data: {} }); | ||
/* Request: https://discord.com/api/v9/users/@me */ | ||
``` | ||
###### DELETE: | ||
```js | ||
await client.api.hypesquad.online.delete({ versioned: true }); | ||
/* Request: https://discord.com/api/v9/hypesquad/online */ | ||
``` | ||
### Gateway APIs | ||
You need to send data to the port and listen for an event. This is quite complicated but if you want to use an existing event, here are the instructions | ||
|
||
###### SEND: | ||
```js | ||
const { Constants } = require('discord.js-selfbot-v13'); | ||
// Global gateway (example update presence) | ||
client.ws.broadcast({ | ||
op: Constants.Opcodes.STATUS_UPDATE, | ||
d: {}, | ||
}); | ||
// Guild gateway (example get all members) | ||
guild.shard.send({ | ||
op: Constants.Opcodes.REQUEST_GUILD_MEMBERS, | ||
d: {}, | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/client/websocket/handlers/GUILD_APPLICATION_COMMANDS_UPDATE.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict'; | ||
|
||
module.exports = (client, { d: data }) => { | ||
if (!data.application_commands[0]) return; | ||
for (const command of data.application_commands) { | ||
const user = client.users.cache.get(command.application_id); | ||
if (!user) continue; | ||
user.applications._add(command, true); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
'use strict'; | ||
const { Events } = require('../../../util/Constants'); | ||
|
||
module.exports = (client, packet) => { | ||
client.actions.InteractionCreate.handle(packet.d); | ||
if (client.user.bot) client.actions.InteractionCreate.handle(packet.d); | ||
else client.emit(Events.INTERACTION_CREATE, packet.d); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use strict'; | ||
const { Events } = require('../../../util/Constants'); | ||
|
||
module.exports = (client, { d: data }) => { | ||
client.emit(Events.INTERACTION_FAILED, data); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use strict'; | ||
const { Events } = require('../../../util/Constants'); | ||
|
||
module.exports = (client, { d: data }) => { | ||
client.emit(Events.INTERACTION_SUCCESS, data); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.