1.3.4
Get interaction commands using gateway
This commit is contained in:
parent
f73525f278
commit
d78a10ed76
@ -9,6 +9,7 @@
|
||||
- [<strong>Guild</strong>](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/Guild.md)
|
||||
- [<strong>Message</strong>](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/Message.md)
|
||||
- [<strong>User</strong>](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/User.md)
|
||||
- [<strong>API</strong>](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/API.md)
|
||||
|
||||
## More features
|
||||
|
||||
|
68
Document/API.md
Normal file
68
Document/API.md
Normal file
@ -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: {},
|
||||
});
|
||||
```
|
@ -4,6 +4,30 @@
|
||||
|
||||
## Interaction
|
||||
<details>
|
||||
<summary>Fetch Commands data</summary>
|
||||
|
||||
```js
|
||||
/* Save to cache */
|
||||
// In guild (Opcode 24)
|
||||
await guild.searchInteraction(
|
||||
{
|
||||
limit: 100, // default: 1
|
||||
query: 'ping', // optional
|
||||
type: 'CHAT_INPUT', // default: 'CHAT_INPUT'
|
||||
offset: 0, // default: 0
|
||||
botID: ['botid1', 'botid2'], // optional
|
||||
}
|
||||
);
|
||||
// Fetch all commands (1 bot) Shouldn't be used
|
||||
await bot.applications.fetch(
|
||||
{
|
||||
guildId: 'guild id to search', // optional
|
||||
force: false, // Using cache or createDMs to bot
|
||||
}
|
||||
);
|
||||
```
|
||||
</details>
|
||||
<details>
|
||||
<summary>Button Click</summary>
|
||||
|
||||
```js
|
||||
@ -57,6 +81,7 @@ await message.contextMenu(botID, commandName);
|
||||
> In this way, all Slash commands can be obtained
|
||||
- I will try to find another way to not need to create DMs with Bot anymore
|
||||
- Credit: [Here](https://www.reddit.com/r/Discord_selfbots/comments/tczprx/discum_help_creating_a_selfbot_that_can_do_ping/)
|
||||
- <strong>Update: Now to get more secure interaction commands you need to use guild.searchInteraction() (using gateway)</strong>
|
||||
</details>
|
||||
|
||||
## MessageEmbed ?
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "discord.js-selfbot-v13",
|
||||
"version": "1.3.3",
|
||||
"version": "1.3.4",
|
||||
"description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]",
|
||||
"main": "./src/index.js",
|
||||
"types": "./typings/index.d.ts",
|
||||
|
@ -60,7 +60,7 @@ class InteractionCreateAction extends Action {
|
||||
InteractionType = AutocompleteInteraction;
|
||||
break;
|
||||
default:
|
||||
client.emit(Events.DEBUG, `[INTERACTION] Received interaction with unknown type: ${data.type}`);
|
||||
client.emit(Events.DEBUG, `[INTERACTION] Received [BOT] / Send (Selfbot) interactionID ${data.id} with unknown type: ${data.type}`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
};
|
||||
};
|
@ -9,6 +9,7 @@ module.exports = (client, { d: data }) => {
|
||||
const guild = client.guilds.cache.get(data.guild_id);
|
||||
if (!guild) return;
|
||||
const members = new Collection();
|
||||
// Get Member from side Discord Channel (online counting if large server)
|
||||
for (const object of data.ops) {
|
||||
if (object.op == 'SYNC') {
|
||||
for (const member_ of object.items) {
|
||||
|
@ -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);
|
||||
};
|
||||
|
6
src/client/websocket/handlers/INTERACTION_FAILED.js
Normal file
6
src/client/websocket/handlers/INTERACTION_FAILED.js
Normal file
@ -0,0 +1,6 @@
|
||||
'use strict';
|
||||
const { Events } = require('../../../util/Constants');
|
||||
|
||||
module.exports = (client, { d: data }) => {
|
||||
client.emit(Events.INTERACTION_FAILED, data);
|
||||
};
|
6
src/client/websocket/handlers/INTERACTION_SUCCESS.js
Normal file
6
src/client/websocket/handlers/INTERACTION_SUCCESS.js
Normal file
@ -0,0 +1,6 @@
|
||||
'use strict';
|
||||
const { Events } = require('../../../util/Constants');
|
||||
|
||||
module.exports = (client, { d: data }) => {
|
||||
client.emit(Events.INTERACTION_SUCCESS, data);
|
||||
};
|
@ -18,6 +18,10 @@ const handlers = Object.fromEntries([
|
||||
['GUILD_MEMBER_UPDATE', require('./GUILD_MEMBER_UPDATE')],
|
||||
['GUILD_MEMBERS_CHUNK', require('./GUILD_MEMBERS_CHUNK')],
|
||||
['GUILD_MEMBER_LIST_UPDATE', require('./GUILD_MEMBER_LIST_UPDATE.js')],
|
||||
[
|
||||
'GUILD_APPLICATION_COMMANDS_UPDATE',
|
||||
require('./GUILD_APPLICATION_COMMANDS_UPDATE.js'),
|
||||
],
|
||||
['GUILD_INTEGRATIONS_UPDATE', require('./GUILD_INTEGRATIONS_UPDATE')],
|
||||
['GUILD_ROLE_CREATE', require('./GUILD_ROLE_CREATE')],
|
||||
['GUILD_ROLE_DELETE', require('./GUILD_ROLE_DELETE')],
|
||||
@ -50,6 +54,8 @@ const handlers = Object.fromEntries([
|
||||
['VOICE_SERVER_UPDATE', require('./VOICE_SERVER_UPDATE')],
|
||||
['WEBHOOKS_UPDATE', require('./WEBHOOKS_UPDATE')],
|
||||
['INTERACTION_CREATE', require('./INTERACTION_CREATE')],
|
||||
['INTERACTION_SUCCESS', require('./INTERACTION_SUCCESS')],
|
||||
['INTERACTION_FAILED', require('./INTERACTION_FAILED')],
|
||||
['STAGE_INSTANCE_CREATE', require('./STAGE_INSTANCE_CREATE')],
|
||||
['STAGE_INSTANCE_UPDATE', require('./STAGE_INSTANCE_UPDATE')],
|
||||
['STAGE_INSTANCE_DELETE', require('./STAGE_INSTANCE_DELETE')],
|
||||
|
@ -84,7 +84,7 @@ class ApplicationCommandManager extends CachedManager {
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async fetch(id, { guildId, cache = true, force = false } = {}) {
|
||||
await this.user.createDM().catch(() => {});
|
||||
// change from user.createDM to opcode (risky action)
|
||||
if (typeof id === 'object') {
|
||||
({ guildId, cache = true } = id);
|
||||
} else if (id) {
|
||||
@ -92,10 +92,11 @@ class ApplicationCommandManager extends CachedManager {
|
||||
const existing = this.cache.get(id);
|
||||
if (existing) return existing;
|
||||
}
|
||||
await this.user.createDM().catch(() => {});
|
||||
const command = await this.commandPath({ id, guildId }).get();
|
||||
return this._add(command, cache);
|
||||
}
|
||||
|
||||
await this.user.createDM().catch(() => {});
|
||||
const data = await this.commandPath({ guildId }).get();
|
||||
return data.reduce((coll, command) => coll.set(command.id, this._add(command, cache, guildId)), new Collection());
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ const {
|
||||
Status,
|
||||
MFALevels,
|
||||
PremiumTiers,
|
||||
Opcodes,
|
||||
} = require('../util/Constants');
|
||||
const DataResolver = require('../util/DataResolver');
|
||||
const SystemChannelFlags = require('../util/SystemChannelFlags');
|
||||
@ -311,7 +312,8 @@ class Guild extends AnonymousGuild {
|
||||
* The explicit content filter level of the guild
|
||||
* @type {ExplicitContentFilterLevel}
|
||||
*/
|
||||
this.explicitContentFilter = ExplicitContentFilterLevels[data.explicit_content_filter];
|
||||
this.explicitContentFilter =
|
||||
ExplicitContentFilterLevels[data.explicit_content_filter];
|
||||
}
|
||||
|
||||
if ('mfa_level' in data) {
|
||||
@ -335,7 +337,8 @@ class Guild extends AnonymousGuild {
|
||||
* The default message notification level of the guild
|
||||
* @type {DefaultMessageNotificationLevel}
|
||||
*/
|
||||
this.defaultMessageNotifications = DefaultMessageNotificationLevels[data.default_message_notifications];
|
||||
this.defaultMessageNotifications =
|
||||
DefaultMessageNotificationLevels[data.default_message_notifications];
|
||||
}
|
||||
|
||||
if ('system_channel_flags' in data) {
|
||||
@ -343,7 +346,9 @@ class Guild extends AnonymousGuild {
|
||||
* The value set for the guild's system channel flags
|
||||
* @type {Readonly<SystemChannelFlags>}
|
||||
*/
|
||||
this.systemChannelFlags = new SystemChannelFlags(data.system_channel_flags).freeze();
|
||||
this.systemChannelFlags = new SystemChannelFlags(
|
||||
data.system_channel_flags,
|
||||
).freeze();
|
||||
}
|
||||
|
||||
if ('max_members' in data) {
|
||||
@ -499,7 +504,8 @@ class Guild extends AnonymousGuild {
|
||||
* @type {GuildStickerManager}
|
||||
*/
|
||||
this.stickers = new GuildStickerManager(this);
|
||||
if (data.stickers) for (const sticker of data.stickers) this.stickers._add(sticker);
|
||||
if (data.stickers)
|
||||
for (const sticker of data.stickers) this.stickers._add(sticker);
|
||||
} else if (data.stickers) {
|
||||
this.client.actions.GuildStickersUpdate.handle({
|
||||
guild_id: this.id,
|
||||
@ -523,7 +529,15 @@ class Guild extends AnonymousGuild {
|
||||
* @returns {?string}
|
||||
*/
|
||||
discoverySplashURL({ format, size } = {}) {
|
||||
return this.discoverySplash && this.client.rest.cdn.DiscoverySplash(this.id, this.discoverySplash, format, size);
|
||||
return (
|
||||
this.discoverySplash &&
|
||||
this.client.rest.cdn.DiscoverySplash(
|
||||
this.id,
|
||||
this.discoverySplash,
|
||||
format,
|
||||
size,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -617,6 +631,51 @@ class Guild extends AnonymousGuild {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Search slash command / message context
|
||||
* @param {guildSearchInteraction} options
|
||||
* {
|
||||
*
|
||||
* type: 1 | 2 | 3, [CHAT_INPUT | USER | MESSAGE]
|
||||
*
|
||||
* query: string | undefined,
|
||||
*
|
||||
* limit: number | 1,
|
||||
*
|
||||
* offset: number | 0,
|
||||
*
|
||||
* botID: [Snowflake] | undefined,
|
||||
*
|
||||
* }
|
||||
*/
|
||||
async searchInteraction(options = {}) {
|
||||
let { query, type, limit, offset, botID } = Object.assign(
|
||||
{ query: undefined, type: 1, limit: 1, offset: 0, botID: [] },
|
||||
options,
|
||||
);
|
||||
if (typeof type == 'string') {
|
||||
if (type == 'CHAT_INPUT') type = 1;
|
||||
else if (type == 'USER') type = 2;
|
||||
else if (type == 'MESSAGE') type = 3;
|
||||
}
|
||||
if (type < 1 || type > 3)
|
||||
throw new RangeError('Type must be 1, 2, 3');
|
||||
if (typeof type !== 'number')
|
||||
throw new TypeError('Type must be a number | string');
|
||||
this.shard.send({
|
||||
op: Opcodes.REQUEST_APPLICATION_COMMANDS,
|
||||
d: {
|
||||
guild_id: this.id,
|
||||
applications: false,
|
||||
limit,
|
||||
offset,
|
||||
type,
|
||||
query: query,
|
||||
command_ids: Array.isArray(botID) ? botID : undefined,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a collection of integrations to this guild.
|
||||
* Resolves with a collection mapping integrations by their ids.
|
||||
@ -630,7 +689,11 @@ class Guild extends AnonymousGuild {
|
||||
async fetchIntegrations() {
|
||||
const data = await this.client.api.guilds(this.id).integrations.get();
|
||||
return data.reduce(
|
||||
(collection, integration) => collection.set(integration.id, new Integration(this.client, integration, this)),
|
||||
(collection, integration) =>
|
||||
collection.set(
|
||||
integration.id,
|
||||
new Integration(this.client, integration, this),
|
||||
),
|
||||
new Collection(),
|
||||
);
|
||||
}
|
||||
@ -642,7 +705,10 @@ class Guild extends AnonymousGuild {
|
||||
*/
|
||||
async fetchTemplates() {
|
||||
const templates = await this.client.api.guilds(this.id).templates.get();
|
||||
return templates.reduce((col, data) => col.set(data.code, new GuildTemplate(this.client, data)), new Collection());
|
||||
return templates.reduce(
|
||||
(col, data) => col.set(data.code, new GuildTemplate(this.client, data)),
|
||||
new Collection(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -661,7 +727,9 @@ class Guild extends AnonymousGuild {
|
||||
* @returns {Promise<GuildTemplate>}
|
||||
*/
|
||||
async createTemplate(name, description) {
|
||||
const data = await this.client.api.guilds(this.id).templates.post({ data: { name, description } });
|
||||
const data = await this.client.api
|
||||
.guilds(this.id)
|
||||
.templates.post({ data: { name, description } });
|
||||
return new GuildTemplate(this.client, data);
|
||||
}
|
||||
|
||||
@ -716,7 +784,8 @@ class Guild extends AnonymousGuild {
|
||||
async fetchWebhooks() {
|
||||
const apiHooks = await this.client.api.guilds(this.id).webhooks.get();
|
||||
const hooks = new Collection();
|
||||
for (const hook of apiHooks) hooks.set(hook.id, new Webhook(this.client, hook));
|
||||
for (const hook of apiHooks)
|
||||
hooks.set(hook.id, new Webhook(this.client, hook));
|
||||
return hooks;
|
||||
}
|
||||
|
||||
@ -762,7 +831,9 @@ class Guild extends AnonymousGuild {
|
||||
this.widgetChannelId = data.channel_id;
|
||||
return {
|
||||
enabled: data.enabled,
|
||||
channel: data.channel_id ? this.channels.cache.get(data.channel_id) : null,
|
||||
channel: data.channel_id
|
||||
? this.channels.cache.get(data.channel_id)
|
||||
: null,
|
||||
};
|
||||
}
|
||||
|
||||
@ -786,8 +857,10 @@ class Guild extends AnonymousGuild {
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async fetchAuditLogs(options = {}) {
|
||||
if (options.before && options.before instanceof GuildAuditLogs.Entry) options.before = options.before.id;
|
||||
if (typeof options.type === 'string') options.type = GuildAuditLogs.Actions[options.type];
|
||||
if (options.before && options.before instanceof GuildAuditLogs.Entry)
|
||||
options.before = options.before.id;
|
||||
if (typeof options.type === 'string')
|
||||
options.type = GuildAuditLogs.Actions[options.type];
|
||||
|
||||
const data = await this.client.api.guilds(this.id)['audit-logs'].get({
|
||||
query: {
|
||||
@ -865,16 +938,23 @@ class Guild extends AnonymousGuild {
|
||||
_data.afk_channel_id = this.client.channels.resolveId(data.afkChannel);
|
||||
}
|
||||
if (typeof data.systemChannel !== 'undefined') {
|
||||
_data.system_channel_id = this.client.channels.resolveId(data.systemChannel);
|
||||
_data.system_channel_id = this.client.channels.resolveId(
|
||||
data.systemChannel,
|
||||
);
|
||||
}
|
||||
if (data.afkTimeout) _data.afk_timeout = Number(data.afkTimeout);
|
||||
if (typeof data.icon !== 'undefined') _data.icon = await DataResolver.resolveImage(data.icon);
|
||||
if (typeof data.icon !== 'undefined')
|
||||
_data.icon = await DataResolver.resolveImage(data.icon);
|
||||
if (data.owner) _data.owner_id = this.client.users.resolveId(data.owner);
|
||||
if (typeof data.splash !== 'undefined') _data.splash = await DataResolver.resolveImage(data.splash);
|
||||
if (typeof data.splash !== 'undefined')
|
||||
_data.splash = await DataResolver.resolveImage(data.splash);
|
||||
if (typeof data.discoverySplash !== 'undefined') {
|
||||
_data.discovery_splash = await DataResolver.resolveImage(data.discoverySplash);
|
||||
_data.discovery_splash = await DataResolver.resolveImage(
|
||||
data.discoverySplash,
|
||||
);
|
||||
}
|
||||
if (typeof data.banner !== 'undefined') _data.banner = await DataResolver.resolveImage(data.banner);
|
||||
if (typeof data.banner !== 'undefined')
|
||||
_data.banner = await DataResolver.resolveImage(data.banner);
|
||||
if (typeof data.explicitContentFilter !== 'undefined') {
|
||||
_data.explicit_content_filter =
|
||||
typeof data.explicitContentFilter === 'number'
|
||||
@ -888,13 +968,19 @@ class Guild extends AnonymousGuild {
|
||||
: DefaultMessageNotificationLevels[data.defaultMessageNotifications];
|
||||
}
|
||||
if (typeof data.systemChannelFlags !== 'undefined') {
|
||||
_data.system_channel_flags = SystemChannelFlags.resolve(data.systemChannelFlags);
|
||||
_data.system_channel_flags = SystemChannelFlags.resolve(
|
||||
data.systemChannelFlags,
|
||||
);
|
||||
}
|
||||
if (typeof data.rulesChannel !== 'undefined') {
|
||||
_data.rules_channel_id = this.client.channels.resolveId(data.rulesChannel);
|
||||
_data.rules_channel_id = this.client.channels.resolveId(
|
||||
data.rulesChannel,
|
||||
);
|
||||
}
|
||||
if (typeof data.publicUpdatesChannel !== 'undefined') {
|
||||
_data.public_updates_channel_id = this.client.channels.resolveId(data.publicUpdatesChannel);
|
||||
_data.public_updates_channel_id = this.client.channels.resolveId(
|
||||
data.publicUpdatesChannel,
|
||||
);
|
||||
}
|
||||
if (typeof data.features !== 'undefined') {
|
||||
_data.features = data.features;
|
||||
@ -903,8 +989,11 @@ class Guild extends AnonymousGuild {
|
||||
_data.description = data.description;
|
||||
}
|
||||
if (data.preferredLocale) _data.preferred_locale = data.preferredLocale;
|
||||
if ('premiumProgressBarEnabled' in data) _data.premium_progress_bar_enabled = data.premiumProgressBarEnabled;
|
||||
const newData = await this.client.api.guilds(this.id).patch({ data: _data, reason });
|
||||
if ('premiumProgressBarEnabled' in data)
|
||||
_data.premium_progress_bar_enabled = data.premiumProgressBarEnabled;
|
||||
const newData = await this.client.api
|
||||
.guilds(this.id)
|
||||
.patch({ data: _data, reason });
|
||||
return this.client.actions.GuildUpdate.handle(newData).updated;
|
||||
}
|
||||
|
||||
@ -958,7 +1047,7 @@ class Guild extends AnonymousGuild {
|
||||
*/
|
||||
async editWelcomeScreen(data) {
|
||||
const { enabled, description, welcomeChannels } = data;
|
||||
const welcome_channels = welcomeChannels?.map(welcomeChannelData => {
|
||||
const welcome_channels = welcomeChannels?.map((welcomeChannelData) => {
|
||||
const emoji = this.emojis.resolve(welcomeChannelData.emoji);
|
||||
return {
|
||||
emoji_id: emoji?.id,
|
||||
@ -968,7 +1057,9 @@ class Guild extends AnonymousGuild {
|
||||
};
|
||||
});
|
||||
|
||||
const patchData = await this.client.api.guilds(this.id, 'welcome-screen').patch({
|
||||
const patchData = await this.client.api
|
||||
.guilds(this.id, 'welcome-screen')
|
||||
.patch({
|
||||
data: {
|
||||
welcome_channels,
|
||||
description,
|
||||
@ -1192,11 +1283,7 @@ class Guild extends AnonymousGuild {
|
||||
if (type == 1 || `${type}`.toUpperCase() === 'FOLDER') {
|
||||
folderID = folderID || this.folder.folderId;
|
||||
if (!['number', 'string'].includes(typeof folderID))
|
||||
throw new TypeError(
|
||||
'INVALID_TYPE',
|
||||
'folderID',
|
||||
'String | Number',
|
||||
);
|
||||
throw new TypeError('INVALID_TYPE', 'folderID', 'String | Number');
|
||||
// Get Data from Folder ID
|
||||
const folder = await this.client.setting.rawSetting.guild_folders.find(
|
||||
(obj) => obj.id == folderID,
|
||||
@ -1419,7 +1506,12 @@ class Guild extends AnonymousGuild {
|
||||
* @param {TextChannelResolvable} rulesChannel
|
||||
* @param {String} reason
|
||||
*/
|
||||
async setCommunity(stats = true, publicUpdatesChannel = '1', rulesChannel = '1', reason) {
|
||||
async setCommunity(
|
||||
stats = true,
|
||||
publicUpdatesChannel = '1',
|
||||
rulesChannel = '1',
|
||||
reason,
|
||||
) {
|
||||
if (stats) {
|
||||
// Check everyone role
|
||||
const everyoneRole = this.roles.everyone;
|
||||
@ -1442,13 +1534,16 @@ class Guild extends AnonymousGuild {
|
||||
reason,
|
||||
);
|
||||
} else {
|
||||
this.edit({
|
||||
this.edit(
|
||||
{
|
||||
publicUpdatesChannel: null,
|
||||
rulesChannel: null,
|
||||
features: this.features.filter(f => f !== 'COMMUNITY'),
|
||||
features: this.features.filter((f) => f !== 'COMMUNITY'),
|
||||
preferredLocale: this.preferredLocale,
|
||||
description: this.description,
|
||||
}, reason);
|
||||
},
|
||||
reason,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1474,10 +1569,10 @@ class Guild extends AnonymousGuild {
|
||||
* @readonly
|
||||
*/
|
||||
get voiceAdapterCreator() {
|
||||
return methods => {
|
||||
return (methods) => {
|
||||
this.client.voice.adapters.set(this.id, methods);
|
||||
return {
|
||||
sendPayload: data => {
|
||||
sendPayload: (data) => {
|
||||
if (this.shard.status !== Status.READY) return false;
|
||||
this.shard.send(data);
|
||||
return true;
|
||||
@ -1508,7 +1603,7 @@ class Guild extends AnonymousGuild {
|
||||
const category = channel.type === ChannelTypes.GUILD_CATEGORY;
|
||||
return Util.discordSort(
|
||||
this.channels.cache.filter(
|
||||
c =>
|
||||
(c) =>
|
||||
(['GUILD_TEXT', 'GUILD_NEWS', 'GUILD_STORE'].includes(channel.type)
|
||||
? ['GUILD_TEXT', 'GUILD_NEWS', 'GUILD_STORE'].includes(c.type)
|
||||
: c.type === channel.type) &&
|
||||
|
@ -347,6 +347,8 @@ exports.Events = {
|
||||
TYPING_START: 'typingStart',
|
||||
WEBHOOKS_UPDATE: 'webhookUpdate',
|
||||
INTERACTION_CREATE: 'interactionCreate',
|
||||
INTERACTION_SUCCESS: 'interactionSuccess',
|
||||
INTERACTION_FAILED: 'interactionFailed',
|
||||
ERROR: 'error',
|
||||
WARN: 'warn',
|
||||
DEBUG: 'debug',
|
||||
|
170
typings/index.d.ts
vendored
170
typings/index.d.ts
vendored
@ -146,6 +146,7 @@ import {
|
||||
RawWidgetData,
|
||||
RawWidgetMemberData,
|
||||
} from './rawDataTypes';
|
||||
import { RelationshipType } from '../src/util/Constants';
|
||||
|
||||
//#region Classes
|
||||
|
||||
@ -975,6 +976,7 @@ export class Guild extends AnonymousGuild {
|
||||
public fetchAuditLogs<T extends GuildAuditLogsResolvable = 'ALL'>(
|
||||
options?: GuildAuditLogsFetchOptions<T>,
|
||||
): Promise<GuildAuditLogs<T>>;
|
||||
public searchInteraction(options?: guildSearchInteraction): Promise<void>;
|
||||
public fetchIntegrations(): Promise<Collection<Snowflake | string, Integration>>;
|
||||
public fetchOwner(options?: BaseFetchOptions): Promise<GuildMember>;
|
||||
public fetchPreview(): Promise<GuildPreview>;
|
||||
@ -3886,6 +3888,14 @@ export interface BaseFetchOptions {
|
||||
force?: boolean;
|
||||
}
|
||||
|
||||
export interface guildSearchInteraction {
|
||||
type?: ApplicationCommandTypes,
|
||||
query?: String | void,
|
||||
limit?: Number,
|
||||
offset?: Number,
|
||||
botID?: Array<User.id>,
|
||||
}
|
||||
|
||||
export interface BaseMessageComponentOptions {
|
||||
type?: MessageComponentType | MessageComponentTypes;
|
||||
}
|
||||
@ -4052,6 +4062,11 @@ export interface ClientEvents extends BaseClientEvents {
|
||||
data: { count: number; index: number; nonce: string | undefined },
|
||||
];
|
||||
guildMemberUpdate: [oldMember: GuildMember | PartialGuildMember, newMember: GuildMember];
|
||||
guildMemberListUpdate: [
|
||||
members: Collection<Snowflake, GuildMember>,
|
||||
guild: Guild,
|
||||
data: {}, // see: https://luna.gitlab.io/discord-unofficial-docs/lazy_guilds.html
|
||||
]
|
||||
guildUpdate: [oldGuild: Guild, newGuild: Guild];
|
||||
inviteCreate: [invite: Invite];
|
||||
inviteDelete: [invite: Invite];
|
||||
@ -4089,7 +4104,9 @@ export interface ClientEvents extends BaseClientEvents {
|
||||
webhookUpdate: [channel: TextChannel | NewsChannel];
|
||||
/** @deprecated Use interactionCreate instead */
|
||||
interaction: [interaction: Interaction];
|
||||
interactionCreate: [interaction: Interaction];
|
||||
interactionCreate: [interaction: Interaction | { nonce: Snowflake, id: Snowflake }];
|
||||
interactionSuccess: [interaction: { nonce: Snowflake, id: Snowflake }];
|
||||
interactionFailed: [interaction: { nonce: Snowflake, id: Snowflake }];
|
||||
shardDisconnect: [closeEvent: CloseEvent, shardId: number];
|
||||
shardError: [error: Error, shardId: number];
|
||||
shardReady: [shardId: number, unavailableGuilds: Set<Snowflake> | undefined];
|
||||
@ -4106,6 +4123,16 @@ export interface ClientEvents extends BaseClientEvents {
|
||||
guildScheduledEventDelete: [guildScheduledEvent: GuildScheduledEvent];
|
||||
guildScheduledEventUserAdd: [guildScheduledEvent: GuildScheduledEvent, user: User];
|
||||
guildScheduledEventUserRemove: [guildScheduledEvent: GuildScheduledEvent, user: User];
|
||||
relationshipAdd: [
|
||||
id: Snowflake,
|
||||
type: RelationshipType,
|
||||
user: User,
|
||||
]
|
||||
relationshipRemove: [
|
||||
id: Snowflake,
|
||||
type: RelationshipType,
|
||||
user: User,
|
||||
]
|
||||
}
|
||||
|
||||
export interface ClientFetchInviteOptions {
|
||||
@ -4285,74 +4312,79 @@ export interface ConstantsEvents {
|
||||
/** @deprecated See [this issue](https://github.com/discord/discord-api-docs/issues/3690) for more information. */
|
||||
APPLICATION_COMMAND_DELETE: 'applicationCommandDelete';
|
||||
/** @deprecated See [this issue](https://github.com/discord/discord-api-docs/issues/3690) for more information. */
|
||||
APPLICATION_COMMAND_UPDATE: 'applicationCommandUpdate';
|
||||
GUILD_CREATE: 'guildCreate';
|
||||
GUILD_DELETE: 'guildDelete';
|
||||
GUILD_UPDATE: 'guildUpdate';
|
||||
INVITE_CREATE: 'inviteCreate';
|
||||
INVITE_DELETE: 'inviteDelete';
|
||||
GUILD_UNAVAILABLE: 'guildUnavailable';
|
||||
GUILD_MEMBER_ADD: 'guildMemberAdd';
|
||||
GUILD_MEMBER_REMOVE: 'guildMemberRemove';
|
||||
GUILD_MEMBER_UPDATE: 'guildMemberUpdate';
|
||||
GUILD_MEMBER_AVAILABLE: 'guildMemberAvailable';
|
||||
GUILD_MEMBERS_CHUNK: 'guildMembersChunk';
|
||||
GUILD_INTEGRATIONS_UPDATE: 'guildIntegrationsUpdate';
|
||||
GUILD_ROLE_CREATE: 'roleCreate';
|
||||
GUILD_ROLE_DELETE: 'roleDelete';
|
||||
GUILD_ROLE_UPDATE: 'roleUpdate';
|
||||
GUILD_EMOJI_CREATE: 'emojiCreate';
|
||||
GUILD_EMOJI_DELETE: 'emojiDelete';
|
||||
GUILD_EMOJI_UPDATE: 'emojiUpdate';
|
||||
GUILD_BAN_ADD: 'guildBanAdd';
|
||||
GUILD_BAN_REMOVE: 'guildBanRemove';
|
||||
CHANNEL_CREATE: 'channelCreate';
|
||||
CHANNEL_DELETE: 'channelDelete';
|
||||
CHANNEL_UPDATE: 'channelUpdate';
|
||||
CHANNEL_PINS_UPDATE: 'channelPinsUpdate';
|
||||
MESSAGE_CREATE: 'messageCreate';
|
||||
MESSAGE_DELETE: 'messageDelete';
|
||||
MESSAGE_UPDATE: 'messageUpdate';
|
||||
MESSAGE_BULK_DELETE: 'messageDeleteBulk';
|
||||
MESSAGE_REACTION_ADD: 'messageReactionAdd';
|
||||
MESSAGE_REACTION_REMOVE: 'messageReactionRemove';
|
||||
MESSAGE_REACTION_REMOVE_ALL: 'messageReactionRemoveAll';
|
||||
MESSAGE_REACTION_REMOVE_EMOJI: 'messageReactionRemoveEmoji';
|
||||
THREAD_CREATE: 'threadCreate';
|
||||
THREAD_DELETE: 'threadDelete';
|
||||
THREAD_UPDATE: 'threadUpdate';
|
||||
THREAD_LIST_SYNC: 'threadListSync';
|
||||
THREAD_MEMBER_UPDATE: 'threadMemberUpdate';
|
||||
THREAD_MEMBERS_UPDATE: 'threadMembersUpdate';
|
||||
USER_UPDATE: 'userUpdate';
|
||||
PRESENCE_UPDATE: 'presenceUpdate';
|
||||
VOICE_SERVER_UPDATE: 'voiceServerUpdate';
|
||||
VOICE_STATE_UPDATE: 'voiceStateUpdate';
|
||||
TYPING_START: 'typingStart';
|
||||
WEBHOOKS_UPDATE: 'webhookUpdate';
|
||||
INTERACTION_CREATE: 'interactionCreate';
|
||||
ERROR: 'error';
|
||||
WARN: 'warn';
|
||||
DEBUG: 'debug';
|
||||
CACHE_SWEEP: 'cacheSweep';
|
||||
SHARD_DISCONNECT: 'shardDisconnect';
|
||||
SHARD_ERROR: 'shardError';
|
||||
SHARD_RECONNECTING: 'shardReconnecting';
|
||||
SHARD_READY: 'shardReady';
|
||||
SHARD_RESUME: 'shardResume';
|
||||
INVALIDATED: 'invalidated';
|
||||
RAW: 'raw';
|
||||
STAGE_INSTANCE_CREATE: 'stageInstanceCreate';
|
||||
STAGE_INSTANCE_UPDATE: 'stageInstanceUpdate';
|
||||
STAGE_INSTANCE_DELETE: 'stageInstanceDelete';
|
||||
GUILD_STICKER_CREATE: 'stickerCreate';
|
||||
GUILD_STICKER_DELETE: 'stickerDelete';
|
||||
GUILD_STICKER_UPDATE: 'stickerUpdate';
|
||||
GUILD_SCHEDULED_EVENT_CREATE: 'guildScheduledEventCreate';
|
||||
GUILD_SCHEDULED_EVENT_UPDATE: 'guildScheduledEventUpdate';
|
||||
GUILD_SCHEDULED_EVENT_DELETE: 'guildScheduledEventDelete';
|
||||
GUILD_SCHEDULED_EVENT_USER_ADD: 'guildScheduledEventUserAdd';
|
||||
GUILD_SCHEDULED_EVENT_USER_REMOVE: 'guildScheduledEventUserRemove';
|
||||
APPLICATION_COMMAND_UPDATE: 'applicationCommandUpdate',
|
||||
GUILD_CREATE: 'guildCreate',
|
||||
GUILD_DELETE: 'guildDelete',
|
||||
GUILD_UPDATE: 'guildUpdate',
|
||||
GUILD_UNAVAILABLE: 'guildUnavailable',
|
||||
GUILD_MEMBER_ADD: 'guildMemberAdd',
|
||||
GUILD_MEMBER_REMOVE: 'guildMemberRemove',
|
||||
GUILD_MEMBER_UPDATE: 'guildMemberUpdate',
|
||||
GUILD_MEMBER_AVAILABLE: 'guildMemberAvailable',
|
||||
GUILD_MEMBERS_CHUNK: 'guildMembersChunk',
|
||||
GUILD_MEMBER_LIST_UPDATE: 'guildMemberListUpdate',
|
||||
GUILD_INTEGRATIONS_UPDATE: 'guildIntegrationsUpdate',
|
||||
GUILD_ROLE_CREATE: 'roleCreate',
|
||||
GUILD_ROLE_DELETE: 'roleDelete',
|
||||
INVITE_CREATE: 'inviteCreate',
|
||||
INVITE_DELETE: 'inviteDelete',
|
||||
GUILD_ROLE_UPDATE: 'roleUpdate',
|
||||
GUILD_EMOJI_CREATE: 'emojiCreate',
|
||||
GUILD_EMOJI_DELETE: 'emojiDelete',
|
||||
GUILD_EMOJI_UPDATE: 'emojiUpdate',
|
||||
GUILD_BAN_ADD: 'guildBanAdd',
|
||||
GUILD_BAN_REMOVE: 'guildBanRemove',
|
||||
CHANNEL_CREATE: 'channelCreate',
|
||||
CHANNEL_DELETE: 'channelDelete',
|
||||
CHANNEL_UPDATE: 'channelUpdate',
|
||||
CHANNEL_PINS_UPDATE: 'channelPinsUpdate',
|
||||
MESSAGE_CREATE: 'messageCreate',
|
||||
MESSAGE_DELETE: 'messageDelete',
|
||||
MESSAGE_UPDATE: 'messageUpdate',
|
||||
MESSAGE_BULK_DELETE: 'messageDeleteBulk',
|
||||
MESSAGE_REACTION_ADD: 'messageReactionAdd',
|
||||
MESSAGE_REACTION_REMOVE: 'messageReactionRemove',
|
||||
MESSAGE_REACTION_REMOVE_ALL: 'messageReactionRemoveAll',
|
||||
MESSAGE_REACTION_REMOVE_EMOJI: 'messageReactionRemoveEmoji',
|
||||
THREAD_CREATE: 'threadCreate',
|
||||
THREAD_DELETE: 'threadDelete',
|
||||
THREAD_UPDATE: 'threadUpdate',
|
||||
THREAD_LIST_SYNC: 'threadListSync',
|
||||
THREAD_MEMBER_UPDATE: 'threadMemberUpdate',
|
||||
THREAD_MEMBERS_UPDATE: 'threadMembersUpdate',
|
||||
USER_UPDATE: 'userUpdate',
|
||||
PRESENCE_UPDATE: 'presenceUpdate',
|
||||
VOICE_SERVER_UPDATE: 'voiceServerUpdate',
|
||||
VOICE_STATE_UPDATE: 'voiceStateUpdate',
|
||||
TYPING_START: 'typingStart',
|
||||
WEBHOOKS_UPDATE: 'webhookUpdate',
|
||||
INTERACTION_CREATE: 'interactionCreate',
|
||||
INTERACTION_SUCCESS: 'interactionSuccess',
|
||||
INTERACTION_FAILED: 'interactionFailed',
|
||||
ERROR: 'error',
|
||||
WARN: 'warn',
|
||||
DEBUG: 'debug',
|
||||
CACHE_SWEEP: 'cacheSweep',
|
||||
SHARD_DISCONNECT: 'shardDisconnect',
|
||||
SHARD_ERROR: 'shardError',
|
||||
SHARD_RECONNECTING: 'shardReconnecting',
|
||||
SHARD_READY: 'shardReady',
|
||||
SHARD_RESUME: 'shardResume',
|
||||
INVALIDATED: 'invalidated',
|
||||
RAW: 'raw',
|
||||
STAGE_INSTANCE_CREATE: 'stageInstanceCreate',
|
||||
STAGE_INSTANCE_UPDATE: 'stageInstanceUpdate',
|
||||
STAGE_INSTANCE_DELETE: 'stageInstanceDelete',
|
||||
GUILD_STICKER_CREATE: 'stickerCreate',
|
||||
GUILD_STICKER_DELETE: 'stickerDelete',
|
||||
GUILD_STICKER_UPDATE: 'stickerUpdate',
|
||||
GUILD_SCHEDULED_EVENT_CREATE: 'guildScheduledEventCreate',
|
||||
GUILD_SCHEDULED_EVENT_UPDATE: 'guildScheduledEventUpdate',
|
||||
GUILD_SCHEDULED_EVENT_DELETE: 'guildScheduledEventDelete',
|
||||
GUILD_SCHEDULED_EVENT_USER_ADD: 'guildScheduledEventUserAdd',
|
||||
GUILD_SCHEDULED_EVENT_USER_REMOVE: 'guildScheduledEventUserRemove',
|
||||
RELATIONSHIP_ADD: 'relationshipAdd',
|
||||
RELATIONSHIP_REMOVE: 'relationshipRemove',
|
||||
}
|
||||
|
||||
export interface ConstantsOpcodes {
|
||||
|
Loading…
Reference in New Issue
Block a user