lgcord.js
Advanced tools
Comparing version 0.6.0 to 0.6.3
@@ -7,2 +7,3 @@ "use strict"; | ||
this.resume = false; | ||
this.resume_url = ''; | ||
this.session_id = ''; | ||
@@ -9,0 +10,0 @@ this.seq = -1; |
export declare enum DiscordButtonStyle { | ||
/** | ||
* blurple | ||
*/ | ||
PRIMARY = 1, | ||
/** | ||
* grey | ||
*/ | ||
SECONDARY = 2, | ||
/** | ||
* green | ||
*/ | ||
SUCCESS = 3, | ||
/** | ||
* red | ||
*/ | ||
DANGER = 4, | ||
/** | ||
* grey | ||
*/ | ||
LINK = 5 | ||
} |
@@ -6,7 +6,22 @@ "use strict"; | ||
(function (DiscordButtonStyle) { | ||
/** | ||
* blurple | ||
*/ | ||
DiscordButtonStyle[DiscordButtonStyle["PRIMARY"] = 1] = "PRIMARY"; | ||
/** | ||
* grey | ||
*/ | ||
DiscordButtonStyle[DiscordButtonStyle["SECONDARY"] = 2] = "SECONDARY"; | ||
/** | ||
* green | ||
*/ | ||
DiscordButtonStyle[DiscordButtonStyle["SUCCESS"] = 3] = "SUCCESS"; | ||
/** | ||
* red | ||
*/ | ||
DiscordButtonStyle[DiscordButtonStyle["DANGER"] = 4] = "DANGER"; | ||
/** | ||
* grey | ||
*/ | ||
DiscordButtonStyle[DiscordButtonStyle["LINK"] = 5] = "LINK"; | ||
})(DiscordButtonStyle = exports.DiscordButtonStyle || (exports.DiscordButtonStyle = {})); |
export declare enum DiscordComponentType { | ||
/** | ||
* A container for other components | ||
*/ | ||
ACTION_ROW = 1, | ||
/** | ||
* A button object | ||
*/ | ||
BUTTON = 2, | ||
/** | ||
* A select menu for picking from choices | ||
*/ | ||
SELECT_MENU = 3 | ||
} |
@@ -6,5 +6,14 @@ "use strict"; | ||
(function (DiscordComponentType) { | ||
/** | ||
* A container for other components | ||
*/ | ||
DiscordComponentType[DiscordComponentType["ACTION_ROW"] = 1] = "ACTION_ROW"; | ||
/** | ||
* A button object | ||
*/ | ||
DiscordComponentType[DiscordComponentType["BUTTON"] = 2] = "BUTTON"; | ||
/** | ||
* A select menu for picking from choices | ||
*/ | ||
DiscordComponentType[DiscordComponentType["SELECT_MENU"] = 3] = "SELECT_MENU"; | ||
})(DiscordComponentType = exports.DiscordComponentType || (exports.DiscordComponentType = {})); |
export declare enum DiscordInteractionCallbackType { | ||
/** | ||
* ACK a Ping | ||
*/ | ||
PONG = 1, | ||
/** | ||
* A button object | ||
*/ | ||
CHANNEL_MESSAGE_WITH_SOURCE = 4, | ||
/** | ||
* ACK an interaction and edit a response later, the user sees a loading state | ||
*/ | ||
DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE = 5, | ||
/** | ||
* For components, ACK an interaction and edit the original message later; the user does not see a loading state | ||
*/ | ||
DEFERRED_UPDATE_MESSAGE = 6, | ||
/** | ||
* For components, edit the message the component was attached to | ||
*/ | ||
UPDATE_MESSAGE = 7 | ||
} |
@@ -6,7 +6,22 @@ "use strict"; | ||
(function (DiscordInteractionCallbackType) { | ||
/** | ||
* ACK a Ping | ||
*/ | ||
DiscordInteractionCallbackType[DiscordInteractionCallbackType["PONG"] = 1] = "PONG"; | ||
/** | ||
* A button object | ||
*/ | ||
DiscordInteractionCallbackType[DiscordInteractionCallbackType["CHANNEL_MESSAGE_WITH_SOURCE"] = 4] = "CHANNEL_MESSAGE_WITH_SOURCE"; | ||
/** | ||
* ACK an interaction and edit a response later, the user sees a loading state | ||
*/ | ||
DiscordInteractionCallbackType[DiscordInteractionCallbackType["DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE"] = 5] = "DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE"; | ||
/** | ||
* For components, ACK an interaction and edit the original message later; the user does not see a loading state | ||
*/ | ||
DiscordInteractionCallbackType[DiscordInteractionCallbackType["DEFERRED_UPDATE_MESSAGE"] = 6] = "DEFERRED_UPDATE_MESSAGE"; | ||
/** | ||
* For components, edit the message the component was attached to | ||
*/ | ||
DiscordInteractionCallbackType[DiscordInteractionCallbackType["UPDATE_MESSAGE"] = 7] = "UPDATE_MESSAGE"; | ||
})(DiscordInteractionCallbackType = exports.DiscordInteractionCallbackType || (exports.DiscordInteractionCallbackType = {})); |
@@ -5,4 +5,5 @@ export declare class DiscordAPIError { | ||
errors: any; | ||
method: string; | ||
endpoint: string; | ||
constructor(code: number, message: string, errors: any, endpoint: string); | ||
constructor(code: number, message: string, errors: any, method: string, endpoint: string); | ||
} |
@@ -5,6 +5,7 @@ "use strict"; | ||
class DiscordAPIError { | ||
constructor(code, message, errors, endpoint) { | ||
constructor(code, message, errors, method, endpoint) { | ||
this.code = code; | ||
this.message = message; | ||
this.errors = errors; | ||
this.method = method; | ||
this.endpoint = endpoint; | ||
@@ -11,0 +12,0 @@ } |
import { DiscordApplicationCommandOptionType } from '../custom-types/discord-application-command-option-type'; | ||
export default class DiscordApplicationCommandInteractionDataOption { | ||
/** | ||
* The name of the parameter | ||
*/ | ||
name: string; | ||
/** | ||
* Value of application command option type | ||
*/ | ||
type: DiscordApplicationCommandOptionType; | ||
/** | ||
* The value of the option resulting from user input | ||
*/ | ||
value?: string | number; | ||
/** | ||
* Present if this option is a group or subcommand | ||
*/ | ||
options?: DiscordApplicationCommandInteractionDataOption[]; | ||
/** | ||
* true if this option is the currently focused option for autocomplete | ||
*/ | ||
focused?: boolean; | ||
@@ -8,0 +23,0 @@ constructor(name: string, type: DiscordApplicationCommandOptionType); |
export declare class DiscordApplicationCommandOptionChoiceStructure { | ||
/** | ||
* 1-100 character choice name | ||
*/ | ||
name: string; | ||
/** | ||
* Value of the choice, up to 100 characters if string | ||
*/ | ||
value: string | number; | ||
@@ -4,0 +10,0 @@ constructor(name: string, value: string | number); |
@@ -5,11 +5,53 @@ import { DiscordApplicationCommandOptionType } from '../custom-types/discord-application-command-option-type'; | ||
export declare class DiscordApplicationCommandOption { | ||
/** | ||
* One of application command option type the type of option | ||
*/ | ||
type: DiscordApplicationCommandOptionType; | ||
/** | ||
* 1-32 character name | ||
*/ | ||
name: string; | ||
/** | ||
* Localization dictionary for the name field. Values follow the same restrictions as name | ||
*/ | ||
name_localizations?: { | ||
[key: string]: string; | ||
}; | ||
/** | ||
* 1 - 100 character description | ||
*/ | ||
description: string; | ||
/** | ||
* Localization dictionary for the description field. Values follow the same restrictions as description | ||
*/ | ||
description_localizations?: { | ||
[key: string]: string; | ||
}; | ||
/** | ||
* If the parameter is required or optional--default false | ||
*/ | ||
required?: boolean; | ||
/** | ||
* Types for the user to pick from, max 25 | ||
*/ | ||
choices: DiscordApplicationCommandOptionChoiceStructure[]; | ||
/** | ||
* Array of application command option if the option is a subcommand or subcommand group type, these nested options will be the parameters | ||
*/ | ||
options: DiscordApplicationCommandOption[]; | ||
/** | ||
* If the option is a channel type, the channels shown will be restricted to these types | ||
*/ | ||
channel_types: DiscordChannelType[]; | ||
/** | ||
* For INTEGER options, double for NUMBER options if the option is an INTEGER or NUMBER type, the minimum value permitted | ||
*/ | ||
min_value?: number; | ||
/** | ||
* For INTEGER options, double for NUMBER options if the option is an INTEGER or NUMBER type, the maximum value permitted | ||
*/ | ||
max_value?: number; | ||
/** | ||
* If autocomplete interactions are enabled for this STRING, INTEGER, or NUMBER type option | ||
*/ | ||
autocomplete?: boolean; | ||
@@ -16,0 +58,0 @@ constructor(name: string, description: string, type: DiscordApplicationCommandOptionType); |
@@ -9,5 +9,14 @@ "use strict"; | ||
constructor(name, description, type) { | ||
this.choices = []; // Types for the user to pick from, max 25 | ||
this.options = []; // Array of application command option if the option is a subcommand or subcommand group type, these nested options will be the parameters | ||
this.channel_types = []; // If the option is a channel type, the channels shown will be restricted to these types | ||
/** | ||
* Types for the user to pick from, max 25 | ||
*/ | ||
this.choices = []; | ||
/** | ||
* Array of application command option if the option is a subcommand or subcommand group type, these nested options will be the parameters | ||
*/ | ||
this.options = []; | ||
/** | ||
* If the option is a channel type, the channels shown will be restricted to these types | ||
*/ | ||
this.channel_types = []; | ||
this.name = name; | ||
@@ -14,0 +23,0 @@ this.description = description; |
@@ -5,10 +5,49 @@ import { DiscordApplicationCommandType } from '../custom-types/discord-application-command-type'; | ||
export declare class DiscordApplicationCommand { | ||
/** | ||
* Unique id of the command | ||
*/ | ||
id?: Snowflake; | ||
/** | ||
* One of application command type the type of command, defaults 1 if not set | ||
*/ | ||
type: DiscordApplicationCommandType; | ||
/** | ||
* Unique id of the parent application | ||
*/ | ||
application_id: Snowflake; | ||
/** | ||
* Guild id of the command, if not global | ||
*/ | ||
guild_id?: Snowflake; | ||
/** | ||
* 1 - 32 character name | ||
*/ | ||
name: string; | ||
/** | ||
* Localization dictionary for the name field. Values follow the same restrictions as name | ||
*/ | ||
name_localizations?: { | ||
[key: string]: string; | ||
}; | ||
/** | ||
* 1 - 100 character description for CHAT_INPUT commands, empty string for USER and MESSAGE commands | ||
*/ | ||
description: string; | ||
/** | ||
* Localization dictionary for the description field. Values follow the same restrictions as description | ||
*/ | ||
description_localizations?: { | ||
[key: string]: string; | ||
}; | ||
/** | ||
* The parameters for the command, max 25 CHAT_INPUT | ||
*/ | ||
options: DiscordApplicationCommandOption[]; | ||
/** | ||
* Whether the command is enabled by default when the app is added to a guild | ||
*/ | ||
default_permission?: boolean; | ||
/** | ||
* Autoincrementing version identifier updated during substantial record changes | ||
*/ | ||
version?: Snowflake; | ||
@@ -15,0 +54,0 @@ constructor(application_id: Snowflake, name: string, description: string); |
@@ -10,3 +10,6 @@ "use strict"; | ||
constructor(application_id, name, description) { | ||
this.options = []; // The parameters for the command, max 25 CHAT_INPUT | ||
/** | ||
* The parameters for the command, max 25 CHAT_INPUT | ||
*/ | ||
this.options = []; | ||
this.application_id = application_id; | ||
@@ -13,0 +16,0 @@ this.name = name; |
import { Snowflake } from '../custom-types/snowflake'; | ||
export default class DiscordApplication { | ||
/** | ||
* The id of the app | ||
*/ | ||
id: Snowflake; | ||
constructor(id: Snowflake); | ||
/** | ||
* The name of the app | ||
*/ | ||
name: string; | ||
/** | ||
* The icon hash of the app | ||
*/ | ||
icon?: string; | ||
/** | ||
* the description of the app | ||
*/ | ||
description: string; | ||
/** | ||
* An array of rpc origin urls, if rpc is enabled | ||
*/ | ||
rpc_origins?: string[]; | ||
/** | ||
* when false only app owner can join the app's bot to guilds | ||
*/ | ||
bot_public: boolean; | ||
constructor(id: Snowflake, name: string, description: string, bot_public: boolean); | ||
static fromJson(json: any): DiscordApplication; | ||
} |
@@ -6,7 +6,2 @@ "use strict"; | ||
class DiscordApplication { | ||
// name string the name of the app | ||
// icon ?string the icon hash of the app | ||
// description string the description of the app | ||
// rpc_origins? array of strings an array of rpc origin urls, if rpc is enabled | ||
// bot_public boolean when false only app owner can join the app's bot to guilds | ||
// bot_require_code_grant boolean when true the app's bot will only join upon completion of the full oauth2 code grant flow | ||
@@ -24,7 +19,11 @@ // terms_of_service_url? string the url of the app's terms of service | ||
// flags? integer the application's public flags | ||
constructor(id) { | ||
constructor(id, name, description, bot_public) { | ||
this.id = id; | ||
this.name = name; | ||
this.description = description; | ||
this.bot_public = bot_public; | ||
} | ||
static fromJson(json) { | ||
const newInst = new DiscordApplication(json.id); | ||
const newInst = new DiscordApplication(json.id, json.name, json.description, json.bot_public); | ||
newInst.icon = json.icon; | ||
return newInst; | ||
@@ -31,0 +30,0 @@ } |
import { DiscordComponentType } from '../custom-types/discord-component-types'; | ||
export default class DiscordComponent { | ||
/** | ||
* Component type | ||
*/ | ||
type: DiscordComponentType; | ||
} |
export default class DiscordEmbedAuthor { | ||
/** | ||
* Name of author | ||
*/ | ||
name: string; | ||
/** | ||
* URL of author | ||
*/ | ||
url?: string; | ||
/** | ||
* URL of author icon(only supports http(s) and attachments) | ||
*/ | ||
icon_url?: string; | ||
/** | ||
* A proxied url of author icon | ||
*/ | ||
proxy_icon_url?: string; | ||
constructor(name: string, url?: string, iconUrl?: string, proxyIconUrl?: string); | ||
} |
export default class DiscordEmbedField { | ||
/** | ||
* Name of the field | ||
*/ | ||
name: string; | ||
/** | ||
* Value of the field | ||
*/ | ||
value: string; | ||
/** | ||
* Whether or not this field should display inline | ||
*/ | ||
inline?: boolean; | ||
constructor(name: string, value: string, inline?: boolean); | ||
} |
export default class DiscordEmbedFooter { | ||
/** | ||
* Footer text | ||
*/ | ||
text: string; | ||
/** | ||
* Url of footer icon (only supports http(s) and attachments) | ||
*/ | ||
icon_url?: string; | ||
/** | ||
* A proxied url of footer icon | ||
*/ | ||
proxy_icon_url?: string; | ||
constructor(text: string, iconUrl?: string, proxyIconUrl?: string); | ||
} |
export default class DiscordEmbedImage { | ||
/** | ||
* Source url of image (only supports http(s) and attachments) | ||
*/ | ||
url: string; | ||
/** | ||
* A proxied url of the image | ||
*/ | ||
proxy_url?: string; | ||
/** | ||
* Height of image | ||
*/ | ||
height?: number; | ||
/** | ||
* Width of image | ||
*/ | ||
width?: number; | ||
constructor(url: string, proxyUrl?: string, height?: number, width?: number); | ||
} |
@@ -6,9 +6,41 @@ import DiscordEmbedAuthor from './discord-embed-author'; | ||
export declare class DiscordEmbed { | ||
/** | ||
* Title of embed | ||
*/ | ||
title?: string; | ||
/** | ||
* Type of embed (always "rich" for webhook embeds) | ||
*/ | ||
type?: string; | ||
/** | ||
* Description of embed | ||
*/ | ||
description?: string; | ||
/** | ||
* Url of embed | ||
*/ | ||
url?: string; | ||
/** | ||
* timestamp of embed content (ISO8601 timestamp) | ||
*/ | ||
timestamp?: string; | ||
/** | ||
* Color code of the embed | ||
*/ | ||
color?: number; | ||
/** | ||
* Footer information | ||
*/ | ||
footer?: DiscordEmbedFooter; | ||
/** | ||
* Image information | ||
*/ | ||
image?: DiscordEmbedImage; | ||
/** | ||
* Embed author object author information | ||
*/ | ||
author?: DiscordEmbedAuthor; | ||
/** | ||
* Array of embed field objects fields information | ||
*/ | ||
fields?: DiscordEmbedField[]; | ||
@@ -15,0 +47,0 @@ setColor(color: number | string): DiscordEmbed; |
@@ -13,3 +13,6 @@ "use strict"; | ||
constructor() { | ||
this.fields = []; // Array of embed field objects fields information | ||
/** | ||
* Array of embed field objects fields information | ||
*/ | ||
this.fields = []; | ||
} | ||
@@ -16,0 +19,0 @@ setColor(color) { |
import { Snowflake } from '../custom-types/snowflake'; | ||
import { DiscordRole } from './discord-role'; | ||
import { DiscordUser } from './discord-user'; | ||
export declare class DiscordEmoji { | ||
/** | ||
* Emoji id | ||
*/ | ||
id?: Snowflake; | ||
/** | ||
* (can be null only in reaction emoji objects) emoji name | ||
*/ | ||
name?: string; | ||
/** | ||
* Roles allowed to use this emoji | ||
*/ | ||
roles?: DiscordRole[]; | ||
/** | ||
* user object user that created this emoji | ||
*/ | ||
user?: DiscordUser; | ||
/** | ||
* Whether this emoji must be wrapped in colons | ||
*/ | ||
require_colons?: boolean; | ||
/** | ||
* Whether this emoji is managed | ||
*/ | ||
managed?: boolean; | ||
/** | ||
* Whether this emoji is animated | ||
*/ | ||
animated?: boolean; | ||
/** | ||
* Whether this emoji can be used, may be false due to loss of Server Boosts | ||
*/ | ||
available?: boolean; | ||
static fromJson(json: any): DiscordEmoji; | ||
} |
@@ -5,10 +5,6 @@ "use strict"; | ||
exports.DiscordEmoji = void 0; | ||
const discord_role_1 = require("./discord-role"); | ||
const discord_user_1 = require("./discord-user"); | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
class DiscordEmoji { | ||
// roles? array of role object ids roles allowed to use this emoji | ||
// user? user object user that created this emoji | ||
// require_colons? boolean whether this emoji must be wrapped in colons | ||
// managed? boolean whether this emoji is managed | ||
// animated? boolean whether this emoji is animated | ||
// available? boolean whether this emoji can be used, may be false due to loss of Server Boosts | ||
static fromJson(json) { | ||
@@ -18,2 +14,8 @@ const newInst = new DiscordEmoji(); | ||
newInst.name = json.name; | ||
newInst.roles = json.roles.map((r) => discord_role_1.DiscordRole.fromJson(r)); | ||
newInst.user = discord_user_1.DiscordUser.fromJson(json.user); | ||
newInst.require_colons = json.require_colons; | ||
newInst.managed = json.managed; | ||
newInst.animated = json.animated; | ||
newInst.available = json.available; | ||
return newInst; | ||
@@ -20,0 +22,0 @@ } |
export declare class DiscordGatewayBotInfo { | ||
/** | ||
* The WSS URL that can be used for connecting to the gateway | ||
*/ | ||
url: string; | ||
/** | ||
* The recommended number of shards to use when connecting | ||
*/ | ||
shards: number; | ||
/** | ||
* Information on the current session start limit | ||
*/ | ||
session_start_limit: DiscordGatewaySessionStartLimit; | ||
@@ -8,7 +17,19 @@ constructor(json: any); | ||
export declare class DiscordGatewaySessionStartLimit { | ||
/** | ||
* The total number of session starts the current user is allowed | ||
*/ | ||
total: number; | ||
/** | ||
* The remaining number of session starts the current user is allowed | ||
*/ | ||
remaining: number; | ||
/** | ||
* The number of milliseconds after which the limit resets | ||
*/ | ||
reset_after: number; | ||
/** | ||
* The number of identify requests allowed per 5 seconds | ||
*/ | ||
max_concurrency: number; | ||
constructor(json: any); | ||
} |
import { Snowflake } from '../custom-types/snowflake'; | ||
import { DiscordUser } from './discord-user'; | ||
export declare class DiscordGuildMember { | ||
/** | ||
* The user this guild member represents | ||
*/ | ||
user?: DiscordUser; | ||
/** | ||
* This users guild nickname | ||
*/ | ||
nick?: string; | ||
/** | ||
* The member's guild avatar hash | ||
*/ | ||
avatar?: string; | ||
/** | ||
* Array of role object ids | ||
*/ | ||
roles: Snowflake[]; | ||
/** | ||
* Total permissions of the member in the channel, including overwrites, returned when in the interaction object | ||
*/ | ||
permissions?: string; | ||
static fromJson(json: any, parentUser?: DiscordUser | undefined): DiscordGuildMember; | ||
} |
@@ -9,4 +9,6 @@ "use strict"; | ||
constructor() { | ||
// public avatar? ?string the member's guild avatar hash | ||
this.roles = []; // Array of role object ids | ||
/** | ||
* Array of role object ids | ||
*/ | ||
this.roles = []; | ||
} | ||
@@ -17,2 +19,3 @@ static fromJson(json, parentUser = undefined) { | ||
newInst.nick = json.nick; | ||
newInst.avatar = json.avatar; | ||
newInst.roles = json.roles ?? []; | ||
@@ -19,0 +22,0 @@ newInst.permissions = json.permissions; |
import { Snowflake } from '../custom-types/snowflake'; | ||
import { DiscordChannel } from './discord-channel'; | ||
import { DiscordGuildMember } from './discord-guild-memeber'; | ||
import { DiscordRole } from './discord-role'; | ||
export declare class DiscordGuild { | ||
/** | ||
* Guild id | ||
*/ | ||
id: Snowflake; | ||
/** | ||
* Guild name (2-100 characters, excluding trailing and leading whitespace) | ||
*/ | ||
name: string; | ||
/** | ||
* icon hash | ||
*/ | ||
icon?: string; | ||
/** | ||
* Returned when in the template object | ||
*/ | ||
icon_hash?: string; | ||
/** | ||
* Id of owner | ||
*/ | ||
owner_id: Snowflake; | ||
/** | ||
* Roles in the guild | ||
*/ | ||
roles: DiscordRole[]; | ||
/** | ||
* True if this guild is unavailable due to an outage | ||
*/ | ||
unavailable?: boolean; | ||
/** | ||
* Users in the guild | ||
*/ | ||
members?: DiscordGuildMember[]; | ||
/** | ||
* Channels in the guild | ||
*/ | ||
channels?: DiscordChannel[]; | ||
constructor(id: Snowflake, name: string, owner_id: Snowflake); | ||
static fromJson(json: any): DiscordGuild; | ||
} |
@@ -5,9 +5,7 @@ "use strict"; | ||
exports.DiscordGuild = void 0; | ||
const discord_channel_1 = require("./discord-channel"); | ||
const discord_guild_memeber_1 = require("./discord-guild-memeber"); | ||
const discord_role_1 = require("./discord-role"); | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
class DiscordGuild { | ||
// member_count? * integer total number of members in this guild | ||
// voice_states? * array of partial voice state objects states of members currently in voice channels; lacks the guild_id key | ||
// members? * array of guild member objects users in the guild | ||
// channels? * array of channel objects channels in the guild | ||
// threads? * array of channel objects all active threads in the guild that current user has permission to view | ||
@@ -42,3 +40,6 @@ // presences? * array of partial presence update objects presences of the members in the guild, will only include non-offline members if the size is greater than large threshold | ||
// explicit_content_filter integer explicit content filter level | ||
this.roles = []; // Roles in the guild | ||
/** | ||
* Roles in the guild | ||
*/ | ||
this.roles = []; | ||
this.id = id; | ||
@@ -54,2 +55,4 @@ this.name = name; | ||
newInst.unavailable = json.unavailable; | ||
newInst.members = json.members?.map(discord_guild_memeber_1.DiscordGuildMember.fromJson); | ||
newInst.channels = json.channels?.map(discord_channel_1.DiscordChannel.fromJson); | ||
return newInst; | ||
@@ -56,0 +59,0 @@ } |
@@ -6,10 +6,37 @@ import { DiscordComponentType } from '../custom-types/discord-component-types'; | ||
export default class DiscordInteractionData { | ||
/** | ||
* The ID of the invoked command | ||
*/ | ||
id: Snowflake; | ||
/** | ||
* The name of the invoked command | ||
*/ | ||
name: string; | ||
/** | ||
* The type of the invoked command | ||
*/ | ||
type: number; | ||
/** | ||
* Converted users + roles + channels | ||
*/ | ||
resolved?: DiscordInteractionResolvedData; | ||
/** | ||
* The params + values from the user | ||
*/ | ||
options: DiscordApplicationCommandInteractionDataOption[]; | ||
/** | ||
* The custom_id of the component | ||
*/ | ||
custom_id?: string; | ||
/** | ||
* The type of the component | ||
*/ | ||
component_type?: DiscordComponentType; | ||
/** | ||
* The values the user selected | ||
*/ | ||
values: string[]; | ||
/** | ||
* Id the of user or message targetted by a user or message command | ||
*/ | ||
target_id?: Snowflake; | ||
@@ -16,0 +43,0 @@ constructor(id: Snowflake, name: string, type: number); |
@@ -10,4 +10,10 @@ "use strict"; | ||
constructor(id, name, type) { | ||
this.options = []; // The params + values from the user | ||
this.values = []; // The values the user selected | ||
/** | ||
* The params + values from the user | ||
*/ | ||
this.options = []; | ||
/** | ||
* The values the user selected | ||
*/ | ||
this.values = []; | ||
this.id = id; | ||
@@ -14,0 +20,0 @@ this.name = name; |
@@ -18,5 +18,17 @@ import { DiscordGuildMember } from './discord-guild-memeber'; | ||
export default class DiscordInteractionResolvedData { | ||
/** | ||
* Map of Snowflakes to user objects | ||
*/ | ||
users?: UserMap; | ||
/** | ||
* Map of Snowflakes to partial member objects | ||
*/ | ||
members?: MemberMap; | ||
/** | ||
* Map of Snowflakes to role objects | ||
*/ | ||
roles?: RoleMap; | ||
/** | ||
* Map of Snowflakes to partial messages objects | ||
*/ | ||
messages?: MessageMap; | ||
@@ -23,0 +35,0 @@ static fromJson(json: any): DiscordInteractionResolvedData; |
import DiscordComponent from './discord-component'; | ||
import { DiscordEmbed } from './discord-embed'; | ||
export default class DiscordInteractionResponseData { | ||
/** | ||
* Is the response TTS | ||
*/ | ||
tts?: boolean; | ||
/** | ||
* Message content | ||
*/ | ||
content?: string; | ||
/** | ||
* Supports up to 10 embeds | ||
*/ | ||
embeds?: DiscordEmbed[]; | ||
/** | ||
* Interaction callback data flags | ||
*/ | ||
flags?: number; | ||
/** | ||
* Message components | ||
*/ | ||
components?: DiscordComponent[]; | ||
} |
import { DiscordInteractionCallbackType } from '../custom-types/discord-interaction-callback-type'; | ||
import DiscordInteractionResponseData from './discord-interaction-response-data'; | ||
export default class DiscordInteractionResponse { | ||
/** | ||
* The type of response | ||
*/ | ||
type: DiscordInteractionCallbackType; | ||
/** | ||
* An optional response message | ||
*/ | ||
data?: DiscordInteractionResponseData; | ||
} |
@@ -5,12 +5,45 @@ import { DiscordGuildMember, DiscordInteractionType, DiscordMessage, DiscordMessageCreate, DiscordUser, Snowflake } from '..'; | ||
export declare class DiscordInteraction { | ||
/** | ||
* Id of the interaction | ||
*/ | ||
id: Snowflake; | ||
/** | ||
* Id of the application this interaction is for | ||
*/ | ||
application_id: Snowflake; | ||
/** | ||
* Interaction type the type of interaction | ||
*/ | ||
type: DiscordInteractionType; | ||
/** | ||
* The command data payload | ||
*/ | ||
data?: DiscordInteractionData; | ||
/** | ||
* The guild it was sent from | ||
*/ | ||
guild_id?: Snowflake; | ||
/** | ||
* The channel it was sent from | ||
*/ | ||
channel_id?: Snowflake; | ||
/** | ||
* Guild member data for the invoking user, including permissions | ||
*/ | ||
member?: DiscordGuildMember; | ||
/** | ||
* User object for the invoking user, if invoked in a DM | ||
*/ | ||
user?: DiscordUser; | ||
/** | ||
* A continuation token for responding to the interaction | ||
*/ | ||
token: string; | ||
/** | ||
* Read-only property, always 1 | ||
*/ | ||
version?: number; | ||
/** | ||
* For components, the message they were attached to | ||
*/ | ||
message?: DiscordMessage; | ||
@@ -17,0 +50,0 @@ constructor(id: Snowflake, application_id: Snowflake, type: DiscordInteractionType, token: string); |
import DiscordComponent from './discord-component'; | ||
export declare class DiscordMessageActionRow extends DiscordComponent { | ||
/** | ||
* A list of child components | ||
*/ | ||
components: DiscordComponent[]; | ||
@@ -4,0 +7,0 @@ constructor(); |
@@ -12,3 +12,6 @@ "use strict"; | ||
super(); | ||
this.components = []; // A list of child components | ||
/** | ||
* A list of child components | ||
*/ | ||
this.components = []; | ||
super.type = discord_component_types_1.DiscordComponentType.ACTION_ROW; | ||
@@ -15,0 +18,0 @@ } |
@@ -5,7 +5,25 @@ import { DiscordButtonStyle } from '../custom-types/discord-button-styles'; | ||
export declare class DiscordMessageButton extends DiscordComponent { | ||
/** | ||
* A developer-defined identifier for the component, max 100 characters | ||
*/ | ||
custom_id?: string; | ||
/** | ||
* Whether the component is disabled, default false | ||
*/ | ||
disabled?: boolean; | ||
/** | ||
* One of button styles | ||
*/ | ||
style?: DiscordButtonStyle; | ||
/** | ||
* Text that appears on the button, max 80 characters | ||
*/ | ||
label?: string; | ||
/** | ||
* Partial emoji name, id, and animated | ||
*/ | ||
emoji?: DiscordEmoji; | ||
/** | ||
* A url for link - style buttons | ||
*/ | ||
url?: string; | ||
@@ -12,0 +30,0 @@ constructor(); |
@@ -12,3 +12,6 @@ "use strict"; | ||
super(); | ||
this.disabled = false; // Whether the component is disabled, default false | ||
/** | ||
* Whether the component is disabled, default false | ||
*/ | ||
this.disabled = false; | ||
super.type = discord_component_types_1.DiscordComponentType.BUTTON; | ||
@@ -15,0 +18,0 @@ } |
@@ -6,9 +6,30 @@ import { Snowflake } from '../custom-types/snowflake'; | ||
export declare class DiscordMessageCreate { | ||
/** | ||
* The message contents(up to 2000 characters) | ||
*/ | ||
content?: string; | ||
/** | ||
* True if this is a TTS message | ||
*/ | ||
tts?: boolean; | ||
/** | ||
* Embedded rich content(up to 6000 characters) | ||
*/ | ||
embeds?: DiscordEmbed[]; | ||
/** | ||
* JSON encoded body of non - file params | ||
*/ | ||
payload_json?: string; | ||
/** | ||
* Include to make your message a reply | ||
*/ | ||
message_reference?: DiscordMessageRefrence; | ||
/** | ||
* The components to include with the message | ||
*/ | ||
components?: DiscordComponent[]; | ||
/** | ||
* IDs of up to 3 stickers in the server to send in the message | ||
*/ | ||
sticker_ids?: Snowflake[]; | ||
} |
import { Snowflake } from '../custom-types/snowflake'; | ||
export declare class DiscordMessageDeleteBulk { | ||
/** | ||
* The ids of the messages | ||
*/ | ||
ids: Snowflake[]; | ||
/** | ||
* The id of the channel | ||
*/ | ||
channel_id: Snowflake; | ||
/** | ||
* The id of the guild | ||
*/ | ||
guild_id?: Snowflake; | ||
@@ -6,0 +15,0 @@ constructor(ids: Snowflake[], channel_id: Snowflake); |
import { Snowflake } from '../custom-types/snowflake'; | ||
export declare class DiscordMessageDelete { | ||
/** | ||
* The id of the message | ||
*/ | ||
id: Snowflake; | ||
/** | ||
* The id of the channel | ||
*/ | ||
channel_id: Snowflake; | ||
/** | ||
* The id of the guild | ||
*/ | ||
guild_id?: Snowflake; | ||
@@ -6,0 +15,0 @@ constructor(id: Snowflake, channel_id: Snowflake); |
import DiscordComponent from './discord-component'; | ||
import { DiscordEmbed } from './discord-embed'; | ||
export default class DiscordMessageEdit { | ||
/** | ||
* The message contents(up to 2000 characters) | ||
*/ | ||
content?: string; | ||
/** | ||
* Embedded rich content(up to 6000 characters) | ||
*/ | ||
embeds?: DiscordEmbed[]; | ||
/** | ||
* Edit the flags of a message (only SUPPRESS_EMBEDS can currently be set/unset) | ||
*/ | ||
flags?: number; | ||
/** | ||
* JSON encoded body of non - file params | ||
*/ | ||
payload_json?: string; | ||
/** | ||
* The components to include with the message | ||
*/ | ||
components?: DiscordComponent[]; | ||
} |
@@ -5,7 +5,25 @@ import { Snowflake } from '../custom-types/snowflake'; | ||
export declare class DiscordMessageReactionAdd { | ||
/** | ||
* The id of the user | ||
*/ | ||
user_id: Snowflake; | ||
/** | ||
* The id of the channel | ||
*/ | ||
channel_id: Snowflake; | ||
/** | ||
* The id of the message | ||
*/ | ||
message_id: Snowflake; | ||
/** | ||
* The id of the guild | ||
*/ | ||
guild_id?: Snowflake; | ||
/** | ||
* The member who reacted if this happened in a guild | ||
*/ | ||
member?: DiscordGuildMember; | ||
/** | ||
* A partial emoji object, the emoji used to react | ||
*/ | ||
emoji: DiscordEmoji; | ||
@@ -12,0 +30,0 @@ constructor(user_id: Snowflake, channel_id: Snowflake, message_id: Snowflake, emoji: DiscordEmoji); |
import { Snowflake } from '../custom-types/snowflake'; | ||
export default class DiscordMessageRefrence { | ||
/** | ||
* Id of the originating message | ||
*/ | ||
message_id?: Snowflake; | ||
/** | ||
* Id of the originating message's channel | ||
*/ | ||
channel_id?: Snowflake; | ||
/** | ||
* Id of the originating message's guild | ||
*/ | ||
guild_id?: Snowflake; | ||
/** | ||
* When sending, whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message, default true | ||
*/ | ||
fail_if_not_exists?: boolean; | ||
} |
@@ -8,13 +8,49 @@ import { Snowflake } from '../custom-types/snowflake'; | ||
export declare class DiscordMessage { | ||
/** | ||
* Id of the message | ||
*/ | ||
id: Snowflake; | ||
/** | ||
* Id of the channel the message was sent in | ||
*/ | ||
channel_id: Snowflake; | ||
/** | ||
* Id of the guild the message was sent in | ||
*/ | ||
guild_id?: Snowflake; | ||
/** | ||
* The author of this message(not guaranteed to be a valid user, see below) | ||
*/ | ||
author: DiscordUser; | ||
/** | ||
* Partial guild member object, member properties for this message's author | ||
*/ | ||
member?: DiscordGuildMember; | ||
/** | ||
* Contents of the message | ||
*/ | ||
content: string; | ||
/** | ||
* Timestamp when this message was sent | ||
*/ | ||
timestamp: string; | ||
/** | ||
* Timestamp when this message was edited(or null if never) | ||
*/ | ||
edited_timestamp?: string; | ||
/** | ||
* Whether this was a TTS message | ||
*/ | ||
tts: boolean; | ||
/** | ||
* Whether this message mentions everyone | ||
*/ | ||
mention_everyone: boolean; | ||
/** | ||
* Users specifically mentioned in the message | ||
*/ | ||
mentions: DiscordUser[]; | ||
/** | ||
* Reactions to the message | ||
*/ | ||
reactions?: DiscordReaction; | ||
@@ -21,0 +57,0 @@ constructor(id: Snowflake, channel_id: Snowflake, author: DiscordUser, content: string, timestamp: string); |
@@ -25,2 +25,5 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -32,4 +35,4 @@ exports.DiscordMessage = void 0; | ||
const discord_guild_memeber_1 = require("./discord-guild-memeber"); | ||
const discord_reaction_1 = __importDefault(require("./discord-reaction")); | ||
const discord_user_1 = require("./discord-user"); | ||
const __1 = require(".."); | ||
class DiscordMessage { | ||
@@ -52,4 +55,10 @@ // public nonce ? integer or string used for validating a message was sent | ||
constructor(id, channel_id, author, content, timestamp) { | ||
const client = __1.Client.client_id | ||
this.client_id = client | ||
/** | ||
* Whether this was a TTS message | ||
*/ | ||
this.tts = false; | ||
/** | ||
* Users specifically mentioned in the message | ||
*/ | ||
this.mentions = []; | ||
this.id = id; | ||
@@ -69,2 +78,3 @@ this.channel_id = channel_id; | ||
newInst.mentions = json.mentions.map(discord_user_1.DiscordUser.fromJson); | ||
newInst.reactions = json.reactions?.map(discord_reaction_1.default.fromJson); | ||
return newInst; | ||
@@ -74,3 +84,3 @@ } | ||
return DiscordAPI.createMessage(this.channel_id, { | ||
...message, | ||
...message, | ||
message_reference: { | ||
@@ -77,0 +87,0 @@ message_id: this.id, |
import { DiscordEmoji } from './discord-emoji'; | ||
export default class DiscordReaction { | ||
/** | ||
* Times this emoji has been used to react | ||
*/ | ||
count: number; | ||
/** | ||
* Whether the current user reacted using this emoji | ||
*/ | ||
me: boolean; | ||
/** | ||
* Partial emoji object - emoji information | ||
*/ | ||
emoji: DiscordEmoji; | ||
constructor(count: number, me: boolean, emoji: DiscordEmoji); | ||
static fromJson(json: any): DiscordReaction; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const discord_emoji_1 = require("./discord-emoji"); | ||
class DiscordReaction { | ||
constructor(count, me, emoji) { | ||
this.count = count; | ||
this.me = me; | ||
this.emoji = emoji; | ||
} | ||
static fromJson(json) { | ||
const reaction = new DiscordReaction(json.count, json.me, discord_emoji_1.DiscordEmoji.fromJson(json.emoji)); | ||
return reaction; | ||
} | ||
} | ||
exports.default = DiscordReaction; |
@@ -5,9 +5,31 @@ import DiscordApplication from './discord-application'; | ||
export declare class DiscordReady { | ||
/** | ||
* Gateway version | ||
*/ | ||
v: number; | ||
/** | ||
* Information about the user including email | ||
*/ | ||
user: DiscordUser; | ||
/** | ||
* The guilds the user is in | ||
*/ | ||
guilds: DiscordGuild[]; | ||
/** | ||
* Used for resuming connections | ||
*/ | ||
session_id: string; | ||
/** | ||
* Gateway url for resuming connections | ||
*/ | ||
resume_gateway_url: string; | ||
/** | ||
* Array of two integers(shard_id, num_shards) the shard information associated with this session, if sent when identifying | ||
*/ | ||
shard?: number[]; | ||
/** | ||
* Partial application object, contains id and flags | ||
*/ | ||
application: DiscordApplication; | ||
constructor(json: any); | ||
} |
@@ -18,2 +18,3 @@ "use strict"; | ||
this.session_id = json.session_id; | ||
this.resume_gateway_url = json.resume_gateway_url; | ||
this.shard = json.shard; | ||
@@ -20,0 +21,0 @@ this.application = discord_application_1.default.fromJson(json.application); |
import { Snowflake } from '../custom-types/snowflake'; | ||
export declare class DiscordRole { | ||
/** | ||
* Role id | ||
*/ | ||
id: Snowflake; | ||
/** | ||
* Role name | ||
*/ | ||
name: string; | ||
/** | ||
* Integer representation of hexadecimal color code | ||
*/ | ||
color: number; | ||
/** | ||
* If this role is pinned in the user listing | ||
*/ | ||
hoist: boolean; | ||
/** | ||
* Role icon hash | ||
*/ | ||
icon?: string; | ||
/** | ||
* Role unicode emoji | ||
*/ | ||
unicode_emoji?: string; | ||
/** | ||
* Position of this role | ||
*/ | ||
position: number; | ||
/** | ||
* Permission bit set | ||
*/ | ||
permissions: number; | ||
constructor(id: Snowflake, name: string, permissions: number); | ||
constructor(id: Snowflake, name: string, permissions: number, color: number, hoist: boolean, position: number); | ||
static fromJson(json: any): DiscordRole; | ||
} |
@@ -10,9 +10,14 @@ "use strict"; | ||
// tags? role tags object the tags this role has | ||
constructor(id, name, permissions) { | ||
constructor(id, name, permissions, color, hoist, position) { | ||
this.id = id; | ||
this.name = name; | ||
this.permissions = permissions; | ||
this.color = color; | ||
this.hoist = hoist; | ||
this.position = position; | ||
} | ||
static fromJson(json) { | ||
const newInst = new DiscordRole(json.id, json.name, json.permissions); | ||
const newInst = new DiscordRole(json.id, json.name, json.permissions, json.color, json.hoist, json.position); | ||
newInst.icon = json.icon; | ||
newInst.unicode_emoji = json.unicode_emoji; | ||
return newInst; | ||
@@ -19,0 +24,0 @@ } |
import DiscordComponent from './discord-component'; | ||
import { DiscordSelectOption } from './discord-select-option'; | ||
export declare class DiscordSelectMenu extends DiscordComponent { | ||
/** | ||
* A developer-defined identifier for the component, max 100 characters | ||
*/ | ||
custom_id?: string; | ||
/** | ||
* Whether the component is disabled, default false | ||
*/ | ||
disabled?: boolean; | ||
/** | ||
* The choices in the select, max 25 | ||
*/ | ||
options: DiscordSelectOption[]; | ||
/** | ||
* Custom placeholder text if nothing is selected, max 100 characters | ||
*/ | ||
placeholder?: string; | ||
/** | ||
* The minimum number of items that must be chosen; default 1, min 0, max 25 | ||
*/ | ||
min_values?: number; | ||
/** | ||
* The maximum number of items that can be chosen; default 1, max 25 | ||
*/ | ||
max_values?: number; | ||
@@ -10,0 +28,0 @@ constructor(); |
@@ -14,4 +14,18 @@ "use strict"; | ||
super(); | ||
this.disabled = false; // Whether the component is disabled, default false | ||
this.options = []; // The choices in the select, max 25 | ||
/** | ||
* Whether the component is disabled, default false | ||
*/ | ||
this.disabled = false; | ||
/** | ||
* The choices in the select, max 25 | ||
*/ | ||
this.options = []; | ||
/** | ||
* The minimum number of items that must be chosen; default 1, min 0, max 25 | ||
*/ | ||
this.min_values = 1; | ||
/** | ||
* The maximum number of items that can be chosen; default 1, max 25 | ||
*/ | ||
this.max_values = 1; | ||
super.type = discord_component_types_1.DiscordComponentType.SELECT_MENU; | ||
@@ -18,0 +32,0 @@ } |
import { DiscordEmoji } from './discord-emoji'; | ||
export declare class DiscordSelectOption { | ||
/** | ||
* The user-facing name of the option, max 100 characters | ||
*/ | ||
label: string; | ||
/** | ||
* The dev-define value of the option, max 100 characters | ||
*/ | ||
value: string; | ||
/** | ||
* An additional description of the option, max 100 characters | ||
*/ | ||
description?: string; | ||
/** | ||
* Partial emoji object id, name, and animated | ||
*/ | ||
emoji?: DiscordEmoji; | ||
/** | ||
* Will render this option as selected by default | ||
*/ | ||
default?: boolean; | ||
@@ -8,0 +23,0 @@ constructor(label: string, value: string); |
import { Snowflake } from '../custom-types/snowflake'; | ||
export declare class DiscordUser { | ||
/** | ||
* The user's id | ||
*/ | ||
id: Snowflake; | ||
/** | ||
* The user's username, not unique across the platform | ||
*/ | ||
username: string; | ||
/** | ||
* The user's 4-digit discord-tag | ||
*/ | ||
discriminator: string; | ||
/** | ||
* The user's avatar hash | ||
*/ | ||
avatar?: string; | ||
/** | ||
* Whether the user belongs to an OAuth2 application | ||
*/ | ||
bot?: boolean; | ||
constructor(id: Snowflake, username: string, discriminator: string); | ||
@@ -7,0 +24,0 @@ static fromJson(json: any): DiscordUser; |
@@ -7,4 +7,2 @@ "use strict"; | ||
class DiscordUser { | ||
// public avatar ? string the user's avatar hash identify | ||
// public bot ? boolean whether the user belongs to an OAuth2 application identify | ||
// public system ? boolean whether the user is an Official Discord System user(part of the urgent message system) identify | ||
@@ -27,2 +25,4 @@ // public mfa_enabled ? boolean whether the user has two factor enabled on their account identify | ||
const newInst = new DiscordUser(json.id, json.username, json.discriminator); | ||
newInst.avatar = json.avatar; | ||
newInst.bot = json.bot; | ||
return newInst; | ||
@@ -29,0 +29,0 @@ } |
@@ -1,3 +0,3 @@ | ||
export * from './discord-minimal'; | ||
export * from './lgcord'; | ||
export * from './data-objects'; | ||
export * from './custom-types'; |
"use strict"; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } }); | ||
}) : (function (o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function (o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
}) : function (o, v) { | ||
o["default"] = v; | ||
@@ -35,5 +35,65 @@ }); | ||
const _1 = require("."); | ||
const discord_message_reaction_remove_1 = require("./data-objects/discord-message-reaction-remove"); | ||
const discord_message_reaction_remove_all_1 = require("./data-objects/discord-message-reaction-remove-all"); | ||
const discord_message_reaction_remove_emoji_1 = require("./data-objects/discord-message-reaction-remove-emoji"); | ||
const discord_guild_memeber_remove_1 = require("./data-objects/discord-guild-memeber-remove"); | ||
const discord_guild_memeber_update_1 = require("./data-objects/discord-guild-memeber-update"); | ||
const discord_guild_role_upsert_1 = require("./data-objects/discord-guild-role-upsert"); | ||
const discord_guild_role_delete_1 = require("./data-objects/discord-guild-role-delete"); | ||
const discord_channel_1 = require("./data-objects/discord-channel"); | ||
const discord_thread_list_sync_1 = require("./data-objects/discord-thread-list-sync"); | ||
const discord_stage_instance_1 = require("./data-objects/discord-stage-instance"); | ||
const discord_channel_pins_update_1 = require("./data-objects/discord-channel-pins-update"); | ||
const discord_application_command_permissions_1 = require("./data-objects/discord-application-command-permissions"); | ||
const EVENTS_MAP = {}; | ||
function addEvent(type, eventId, dataMap) { | ||
EVENTS_MAP[type] = { eventId, dataMap }; | ||
} | ||
addEvent('MESSAGE_CREATE', 'messageCreate', d => _1.DiscordMessage.fromJson(d)); | ||
addEvent('MESSAGE_UPDATE', 'messageUpdate', d => _1.DiscordMessage.fromJson(d)); | ||
addEvent('MESSAGE_DELETE', 'messageDelete', d => _1.DiscordMessageDelete.fromJson(d)); | ||
addEvent('MESSAGE_DELETE_BULK', 'messageDeleteBulk', d => _1.DiscordMessageDeleteBulk.fromJson(d)); | ||
addEvent('MESSAGE_REACTION_ADD', 'messageReactionAdd', d => _1.DiscordMessageReactionAdd.fromJson(d)); | ||
addEvent('MESSAGE_REACTION_REMOVE', 'messageReactionRemove', d => discord_message_reaction_remove_1.DiscordMessageReactionRemove.fromJson(d)); | ||
addEvent('MESSAGE_REACTION_REMOVE_ALL', 'messageReactionRemoveAll', d => discord_message_reaction_remove_all_1.DiscordMessageReactionRemoveAll.fromJson(d)); | ||
addEvent('MESSAGE_REACTION_REMOVE_EMOJI', 'messageReactionRemoveEmoji', d => discord_message_reaction_remove_emoji_1.DiscordMessageReactionRemoveEmoji.fromJson(d)); | ||
addEvent('INTERACTION_CREATE', 'interactionCreate', d => _1.DiscordInteraction.fromJson(d)); | ||
addEvent('GUILD_CREATE', 'guildCreate', d => { | ||
_1.DiscordGuild.fromJson(d) | ||
this.guilds = [] | ||
this.guilds.cache = new Map() | ||
this.guilds.push(_1.DiscordGuild.fromJson(d)) | ||
this.guilds.forEach(gg => { | ||
this.guilds.cache.set(`${gg.id}`, gg) | ||
}) | ||
} | ||
); | ||
addEvent('GUILD_DELETE', 'guildDelete', d => _1.DiscordGuild.fromJson(d)); | ||
addEvent('GUILD_UPDATE', 'guildUpdate', d => _1.DiscordGuild.fromJson(d)); | ||
addEvent('GUILD_MEMBER_ADD', 'guildMemberAdd', d => data_objects_1.DiscordGuildMember.fromJson(d)); | ||
addEvent('GUILD_MEMBER_REMOVE', 'guildMemberRemove', d => discord_guild_memeber_remove_1.DiscordGuildMemberRemove.fromJson(d)); | ||
addEvent('GUILD_MEMBER_UPDATE', 'guildMemberUpdate', d => discord_guild_memeber_update_1.DiscordGuildMemberUpdate.fromJson(d)); | ||
addEvent('GUILD_ROLE_CREATE', 'guildRoleCreate', d => discord_guild_role_upsert_1.DiscordGuildRoleUpsert.fromJson(d)); | ||
addEvent('GUILD_ROLE_UPDATE', 'guildRoleUpdate', d => discord_guild_role_upsert_1.DiscordGuildRoleUpsert.fromJson(d)); | ||
addEvent('GUILD_ROLE_DELETE', 'guildRoleDelete', d => discord_guild_role_delete_1.DiscordGuildRoleDelete.fromJson(d)); | ||
addEvent('CHANNEL_CREATE', 'channelCreate', d => discord_channel_1.DiscordChannel.fromJson(d)); | ||
addEvent('CHANNEL_UPDATE', 'channelUpdate', d => discord_channel_1.DiscordChannel.fromJson(d)); | ||
addEvent('CHANNEL_DELETE', 'channelDelete', d => discord_channel_1.DiscordChannel.fromJson(d)); | ||
addEvent('CHANNEL_PINS_UPDATE', 'channelPinsUpdate', d => discord_channel_pins_update_1.DiscordChannelPinsUpdate.fromJson(d)); | ||
// eslint-disable-next-line max-len | ||
addEvent('APPLICATION_COMMAND_PERMISSIONS_UPDATE', 'applicationCommandPermissionsUpdate', d => discord_application_command_permissions_1.DiscordApplicationCommandPermissions.fromJson(d)); | ||
addEvent('STAGE_INSTANCE_CREATE', 'stageInstanceCreate', d => discord_stage_instance_1.DiscordStageInstance.fromJson(d)); | ||
addEvent('STAGE_INSTANCE_DELETE', 'stageInstanceDelete', d => discord_stage_instance_1.DiscordStageInstance.fromJson(d)); | ||
addEvent('STAGE_INSTANCE_UPDATE', 'stageInstanceUpdate', d => discord_stage_instance_1.DiscordStageInstance.fromJson(d)); | ||
addEvent('THREAD_LIST_SYNC', 'threadListSync', d => discord_thread_list_sync_1.DiscordThreadListSync.fromJson(d)); | ||
addEvent('USER_UPDATE', 'userUpdate', d => data_objects_1.DiscordUser.fromJson(d)); | ||
class Client extends events_1.default.EventEmitter { | ||
constructor(intents) { | ||
super(); | ||
const client = this.client | ||
const guilds = this.guilds | ||
this.guilds = [] | ||
this.client_inf = client | ||
this.websocket = []; | ||
@@ -47,2 +107,4 @@ this.heartbeat = []; | ||
Client.token = token; | ||
if (!Client.token || typeof Client.token !== 'string') throw new Error("LGcord Error #1372\nInvalid token provided. Provide a valid token to login in to your bot"); | ||
this.debug(`Connecting to discord gateway`) | ||
const gatewayInfo = await (0, discord_api_1.getGatewayBot)().catch(e => { console.log(e); return new data_objects_1.DiscordGatewayBotInfo({}); }); | ||
@@ -59,3 +121,6 @@ this.gatewayUrl = gatewayInfo.url; | ||
}, 7000); | ||
} | ||
initGatewaySocket(gatewayUrl, shardId) { | ||
@@ -70,2 +135,4 @@ const ws = new ws_1.default(`${gatewayUrl}/?v=8&encoding=json`); | ||
} | ||
onMessage(wsd, event, shardNum) { | ||
@@ -75,3 +142,2 @@ const message = Object.assign(new payloads_1.GatewayPayload(), JSON.parse(event.data)); | ||
wsd.seq = message.s; | ||
this.debug(`Message on shard \`${shardNum}\` | OP: ${message.op}`); | ||
switch (message.op) { | ||
@@ -100,2 +166,5 @@ case 0: | ||
} | ||
debug(message) { | ||
@@ -105,3 +174,3 @@ this.emit('debug', message); | ||
onOpen(event, shardId) { | ||
this.debug(`Shard \`${shardId}\` open! Event type: ${event.type} `); | ||
this.debug(`Shard \`${shardId}\` OPEN! Event type: ${event.type} `); | ||
} | ||
@@ -111,3 +180,3 @@ onClose(event, shardId) { | ||
clearInterval(this.heartbeat[shardId]); | ||
this.debug(`Shard \`${shardId}\` closed! Code: ${code} | Reason: ${event.reason} `); | ||
this.debug(`Shard \`${shardId}\` CLOSED! Code: ${code} | Reason: ${event.reason} `); | ||
switch (code) { | ||
@@ -152,105 +221,31 @@ case -1: | ||
} | ||
onEvent(json, wsd) { | ||
const eventId = json.t; | ||
this.debug(`Event recieved | Shard: ${wsd.shard} | ID: ${eventId}`); | ||
switch (eventId) { | ||
case 'READY': | ||
// eslint-disable-next-line no-case-declarations | ||
const ready = new _1.DiscordReady(json.d); | ||
wsd.session_id = ready.session_id; | ||
this.emit('ready', ready); | ||
break; | ||
case 'RESUMED': | ||
//TODO! | ||
break; | ||
case 'MESSAGE_CREATE': | ||
this.emit('messageCreate', _1.DiscordMessage.fromJson(json.d)); | ||
break; | ||
case 'MESSAGE_UPDATE': | ||
//TODO! | ||
break; | ||
case 'MESSAGE_DELETE': | ||
this.emit('messageDelete', _1.DiscordMessageDelete.fromJson(json.d)); | ||
break; | ||
case 'MESSAGE_DELETE_BULK': | ||
this.emit('messageDeleteBulk', _1.DiscordMessageDeleteBulk.fromJson(json.d)); | ||
break; | ||
case 'MESSAGE_REACTION_ADD': | ||
this.emit('messageReactionAdd', _1.DiscordMessageReactionAdd.fromJson(json.d)); | ||
break; | ||
case 'MESSAGE_REACTION_REMOVE': | ||
//TODO! | ||
break; | ||
case 'MESSAGE_REACTION_REMOVE_EMOJI': | ||
//TODO! | ||
break; | ||
case 'MESSAGE_REACTION_REMOVE_ALL': | ||
//TODO! | ||
break; | ||
case 'INTERACTION_CREATE': | ||
this.emit('interactionCreate', _1.DiscordInteraction.fromJson(json.d)); | ||
break; | ||
case 'GUILD_CREATE': | ||
this.emit('guildCreate', _1.DiscordGuild.fromJson(json.d)); | ||
break; | ||
case 'GUILD_DELETE': | ||
this.emit('guildDelete', _1.DiscordGuild.fromJson(json.d)); | ||
break; | ||
case 'GUILD_UPDATE': | ||
this.emit('guildUpdate', _1.DiscordGuild.fromJson(json.d)); | ||
break; | ||
case 'GUILD_MEMBER_UPDATE': | ||
//TODO! | ||
break; | ||
case 'GUILD_ROLE_CREATE': | ||
//TODO! | ||
break; | ||
case 'GUILD_ROLE_UPDATE': | ||
//TODO! | ||
break; | ||
case 'GUILD_ROLE_DELETE': | ||
//TODO! | ||
break; | ||
case 'GUILD_JOIN_REQUEST_UPDATE': | ||
//TODO! | ||
break; | ||
case 'GUILD_JOIN_REQUEST_DELETE': | ||
//TODO! | ||
break; | ||
case 'CHANNEL_CREATE': | ||
//TODO! | ||
break; | ||
case 'CHANNEL_UPDATE': | ||
//TODO! | ||
break; | ||
case 'CHANNEL_DELETE': | ||
//TODO! | ||
break; | ||
case 'CHANNEL_PINS_UPDATE': | ||
//TODO! | ||
break; | ||
case 'APPLICATION_COMMAND_PERMISSIONS_UPDATE': | ||
//TODO! | ||
break; | ||
case 'STAGE_INSTANCE_CREATE': | ||
//TODO! | ||
break; | ||
case 'STAGE_INSTANCE_DELETE': | ||
//TODO! | ||
break; | ||
case 'STAGE_INSTANCE_UPDATE': | ||
//TODO! | ||
break; | ||
case 'THREAD_LIST_SYNC': | ||
//TODO! | ||
break; | ||
case 'USER_UPDATE': | ||
//TODO! | ||
break; | ||
case 'GIFT_CODE_UPDATE': | ||
//TODO! | ||
break; | ||
default: | ||
console.log('UNKNOWN EVENT!', eventId); | ||
this.debug(`${this.baseStr('Event recieved')} | Shard: ${wsd.shard} | ID: ${eventId}`); | ||
if (!eventId) { | ||
return; | ||
} | ||
const event = EVENTS_MAP[eventId]; | ||
if (event) { | ||
this.emit(event.eventId, event.dataMap(json.d)); | ||
} | ||
else if (eventId === 'READY') { | ||
const ready = new _1.DiscordReady(json.d); | ||
this.emit('ready', ready); | ||
this.client_inf = ready | ||
this.client_inf.guilds.cache = new Map(); | ||
wsd.session_id = ready.session_id; | ||
wsd.resume_url = ready.resume_gateway_url; | ||
} | ||
else if (eventId === 'RESUMED') { | ||
this.emit('resumed'); | ||
} | ||
// eslint-disable-next-line max-len | ||
else if (['GUILD_JOIN_REQUEST_UPDATE', 'GUILD_JOIN_REQUEST_DELETE', 'GUILD_APPLICATION_COMMAND_INDEX_UPDATE', 'GIFT_CODE_UPDATE'].includes(eventId)) { | ||
//TODO: I've seen these event id's but no idea what their payload is... Can't find docs on them | ||
} | ||
else { | ||
console.log('UNKNOWN EVENT!', eventId); | ||
} | ||
} | ||
@@ -262,3 +257,3 @@ startHeartbeat(wsd, shardNum, heartbeatDelay) { | ||
this.sendPayload(wsd.ws, new payloads_1.HeartBeatPayload(wsd.seq)); | ||
this.debug(`Heartbeat | Shard: ${shardNum} | Delay: ${heartbeatDelay}`); | ||
this.debug(`${this.baseStr('Heartbeat')} | Shard: ${shardNum} | Delay: ${heartbeatDelay}`); | ||
}, heartbeatDelay); | ||
@@ -269,4 +264,8 @@ } | ||
} | ||
baseStr(str) { | ||
return str + ' '.repeat(20 - str.length); | ||
} | ||
} | ||
exports.Client = Client; | ||
exports.default = Client; |
{ | ||
"name": "lgcord.js", | ||
"version": "0.6.0", | ||
"version": "0.6.3", | ||
"description": "tcord beta", | ||
"main": "./output/index.js", | ||
"types": "./output/index.d.ts", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/tga098/lgcord.js.git" | ||
}, | ||
"scripts": { | ||
"build": "npx tsc", | ||
"test": "npx tsc & node ./output/test/test-bot.js" | ||
"test": "node ./test/test-bot.js" | ||
}, | ||
@@ -26,1 +30,3 @@ "author": "tga098", | ||
} | ||
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
75
0
147953
147
3725
1