Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overall Consistency Fixes & Minor Feature Additions #1379

Closed
wants to merge 57 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
6be7cc0
ThreadMetadata
DonovanDMC May 29, 2022
a2010bd
nullable publicUpdatesChannelID
DonovanDMC May 30, 2022
aecc86e
widgetEnabled isn't nullable
DonovanDMC May 30, 2022
3f84287
GUILD_STAGE -> GUILD_STAGE_VOICE
DonovanDMC May 30, 2022
197d484
all of the ExtendedUser properties are optional
DonovanDMC May 30, 2022
c5788d0
MessageActivityFlags -> ActivityFlags
DonovanDMC May 30, 2022
2a2f24c
name Activity#party tuple
DonovanDMC May 30, 2022
3706f05
Webhook#guild_id & source_guild optional
DonovanDMC May 30, 2022
9ff0ed6
nullable WebhookOptions#avatar
DonovanDMC May 30, 2022
d4f5978
use WebhookOptions in createWebhook
DonovanDMC May 30, 2022
ccbb5fb
EditSelfOptions & nullable avatar
DonovanDMC May 30, 2022
ba638c1
MessageActivityFlags -> MessageActivityTypes
DonovanDMC May 30, 2022
01f669a
add more guild features
DonovanDMC May 30, 2022
588f223
ActivityButto
DonovanDMC May 30, 2022
d319b0b
StickerItems -> StickerItem
DonovanDMC May 30, 2022
9b9fdc9
alphabetize stickers
DonovanDMC May 30, 2022
700fa7a
nullable Invite#channel
DonovanDMC May 30, 2022
644310d
Invites (pass 1)
DonovanDMC May 30, 2022
591845c
Invite#stageInstance docs
DonovanDMC May 30, 2022
5bab078
add invite expiresAt
DonovanDMC May 30, 2022
5a54b65
deprecate Invite#stageInstance
DonovanDMC May 30, 2022
aa1d6ff
update ApplicationInfo & add ApplicationFlags
DonovanDMC May 30, 2022
1ce717d
private threads always have invitable, whoops
DonovanDMC May 30, 2022
ca94b6a
OAuthTeamInfo#name
DonovanDMC May 30, 2022
ba92162
explicitly type OAuthTeamMember
DonovanDMC May 30, 2022
bb8f483
MembershipStates
DonovanDMC May 30, 2022
1773ccd
fix(types): fix types for `Shard#requestGuildMembers`
TTtie May 28, 2022
ab1a4ea
fix(types): fix types for `Shard#requestGuildMembers`
DonovanDMC May 30, 2022
d74eeb9
fix(types): fix types for `Shard#requestGuildMembers`
DonovanDMC May 30, 2022
efd33d8
Merge branch 'fixes-n-shit' of https://github.com/DonovanDMC/eris int…
DonovanDMC May 30, 2022
c3ac743
More constants. MORE
DonovanDMC Jun 1, 2022
fac06c4
ApplicationCommandPermissionTypes.CHANNEL
DonovanDMC Jun 1, 2022
ff0869d
nullable and optional topic
DonovanDMC Jun 1, 2022
153d534
Merge remote-tracking branch 'upstream/dev' into fixes-n-shit
DonovanDMC Jun 8, 2022
e14e297
e
DonovanDMC Jun 8, 2022
33c4826
fix(editChannel): fix `videoQualityMode` & add `permissionOverwrites`
aicushman Jun 8, 2022
d31c95e
Merge remote-tracking branch 'upstream/dev' into fixes-n-shit
DonovanDMC Jun 8, 2022
1eb3899
commit message
DonovanDMC Jun 9, 2022
d4fd4b9
fix thread_metadata access
DonovanDMC Jun 14, 2022
0193014
another fix
DonovanDMC Jun 27, 2022
95b6eeb
e
DonovanDMC Jun 30, 2022
b91ee71
Merge branch 'dev' into fixes-n-shit
DonovanDMC Jun 30, 2022
8d7e8af
sticker descriptions
DonovanDMC Jul 1, 2022
06dca14
Merge remote-tracking branch 'upstream/dev' into fixes-n-shit
DonovanDMC Jul 1, 2022
f388166
`GuildTextableWithThread` pluralization
DonovanDMC Jul 4, 2022
746279d
add hub types
DonovanDMC Jul 21, 2022
37e98c2
fix around various properties with channels
DonovanDMC Aug 7, 2022
943947b
lint
DonovanDMC Aug 7, 2022
42e84f1
fix docs for `Client#getRESTGuildChannels` & `Guild#getRESTChannels`
DonovanDMC Aug 7, 2022
f737ea7
separate out `permissionOverwrites` & `position`
DonovanDMC Aug 7, 2022
4c94388
I don't know why this is here
DonovanDMC Aug 8, 2022
93f559b
properly update toJSON and a few doc things for 37e98c2
DonovanDMC Aug 8, 2022
283c570
Update the `getDMChannel` to the moddern parameters
DonovanDMC Aug 8, 2022
ba48306
proper invite stage instance docs
DonovanDMC Aug 18, 2022
2a0c098
Merge branch 'dev' into fixes-n-shit
DonovanDMC Aug 18, 2022
ef2891f
Remove new select type names
DonovanDMC Aug 18, 2022
ca50226
lint
DonovanDMC Aug 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
294 changes: 198 additions & 96 deletions index.d.ts

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ class Client extends EventEmitter {
* @arg {String} channelID The ID of the channel to create the webhook in
* @arg {Object} options Webhook options
* @arg {String} options.name The default name
* @arg {String} [options.avatar] The default avatar as a base64 data URI. Note: base64 strings alone are not base64 data URI strings
* @arg {String?} [options.avatar] The default avatar as a base64 data URI. Note: base64 strings alone are not base64 data URI strings
* @arg {String} [reason] The reason to be displayed in audit logs
* @returns {Promise<Object>} Resolves with a webhook object
*/
Expand Down Expand Up @@ -688,7 +688,7 @@ class Client extends EventEmitter {
/**
* Create a guild sticker
* @arg {Object} options Sticker options
* @arg {String} [options.description] The description of the sticker
* @arg {String} options.description The description of the sticker
* @arg {Object} options.file A file object
* @arg {Buffer} options.file.file A buffer containing file data
* @arg {String} options.file.name What to name the file
Expand All @@ -699,7 +699,7 @@ class Client extends EventEmitter {
*/
createGuildSticker(guildID, options, reason) {
return this.requestHandler.request("POST", Endpoints.GUILD_STICKERS(guildID), true, {
description: options.description || "",
description: options.description,
name: options.name,
tags: options.tags,
reason: reason
Expand Down Expand Up @@ -1796,7 +1796,7 @@ class Client extends EventEmitter {
* Edit properties of the bot user
* @arg {Object} options The properties to edit
* @arg {String} [options.username] The new username
* @arg {String} [options.avatar] The new avatar as a base64 data URI. Note: base64 strings alone are not base64 data URI strings
* @arg {String?} [options.avatar] The new avatar as a base64 data URI. Note: base64 strings alone are not base64 data URI strings
* @returns {Promise<ExtendedUser>}
*/
editSelf(options) {
Expand Down Expand Up @@ -1939,7 +1939,7 @@ class Client extends EventEmitter {
* @arg {String} webhookID The ID of the webhook
* @arg {Object} options Webhook options
* @arg {String} [options.name] The new default name
* @arg {String} [options.avatar] The new default avatar as a base64 data URI. Note: base64 strings alone are not base64 data URI strings
* @arg {String?} [options.avatar] The new default avatar as a base64 data URI. Note: base64 strings alone are not base64 data URI strings
* @arg {String} [options.channelID] The new channel ID where webhooks should be sent to
* @arg {String} [token] The token of the webhook, used instead of the Bot Authorization token
* @arg {String} [reason] The reason to be displayed in audit logs
Expand Down Expand Up @@ -2274,8 +2274,7 @@ class Client extends EventEmitter {
return Promise.resolve(this.privateChannels.get(this.privateChannelMap[userID]));
}
return this.requestHandler.request("POST", Endpoints.USER_CHANNELS("@me"), true, {
recipients: [userID],
type: 1
recipient_id: userID
}).then((privateChannel) => new PrivateChannel(privateChannel, this));
}

Expand Down Expand Up @@ -2545,11 +2544,13 @@ class Client extends EventEmitter {
* Get info on an invite
* @arg {String} inviteID The ID of the invite
* @arg {Boolean} [withCounts] Whether to fetch additional invite info or not (approximate member counts, approximate presences, channel counts, etc.)
* @arg {Boolean} [withExpiration] Whether to fetch the expiration time or not
* @returns {Promise<Invite>}
*/
getInvite(inviteID, withCounts) {
getInvite(inviteID, withCounts, withExpiration) {
return this.requestHandler.request("GET", Endpoints.INVITE(inviteID), true, {
with_counts: withCounts
with_counts: withCounts,
with_expiration: withExpiration
}).then((invite) => new Invite(invite, this));
}

Expand Down Expand Up @@ -2753,7 +2754,7 @@ class Client extends EventEmitter {
/**
* Get a guild's channels via the REST API. REST mode is required to use this endpoint.
* @arg {String} guildID The ID of the guild
* @returns {Promise<Array<CategoryChannel> | Array<TextChannel> | Array<TextVoiceChannel> | Array<NewsChannel>>}
* @returns {Promise<Array<CategoryChannel | TextChannel | TextVoiceChannel | NewsChannel | StageChannel>>}
*/
getRESTGuildChannels(guildID) {
if(!this.options.restMode) {
Expand Down
138 changes: 106 additions & 32 deletions lib/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
module.exports.GATEWAY_VERSION = 9;
module.exports.REST_VERSION = 9;

module.exports.ActivityFlags = {
INSTANCE: 1 << 0,
JOIN: 1 << 1,
SPECTATE: 1 << 2,
JOIN_REQUEST: 1 << 3,
SYNC: 1 << 4,
PLAY: 1 << 5,
PARTY_PRIVACY_FRIENDS: 1 << 6,
PARTY_PRIVACY_VOICE_CHANNEL: 1 << 7,
EMBEDDED: 1 << 8
};

module.exports.ActivityTypes = {
GAME: 0,
STREAMING: 1,
Expand All @@ -22,12 +34,14 @@ module.exports.ApplicationCommandOptionTypes = {
CHANNEL: 7,
ROLE: 8,
MENTIONABLE: 9,
NUMBER: 10
NUMBER: 10,
ATTACHMENT: 11
};

module.exports.ApplicationCommandPermissionTypes = {
ROLE: 1,
USER: 2
ROLE: 1,
USER: 2,
CHANNEL: 3
};

module.exports.ApplicationCommandTypes = {
Expand All @@ -36,6 +50,21 @@ module.exports.ApplicationCommandTypes = {
MESSAGE: 3
};

module.exports.ApplicationFlags = {
EMBEDDED_RELEASED: 1 << 1,
MANAGED_EMOJI: 1 << 2,
GROUP_DM_CREATE: 1 << 4,
GATEWAY_PRESENCE: 1 << 12,
GATEWAY_PRESENCE_LIMITED: 1 << 13,
GATEWAY_GUILD_MEMBERS: 1 << 14,
GATEWAY_GUILD_MEMBERS_LIMITED: 1 << 15,
VERIFICATION_PENDING_GUILD_LIMIT: 1 << 16,
EMBEDDED: 1 << 17,
GATEWAY_MESSAGE_CONTENT: 1 << 18,
GATEWAY_MESSAGE_CONTENT_LIMITED: 1 << 19,
EMBEDDED_FIRST_PARTY: 1 << 20
};

module.exports.AuditLogActions = {
GUILD_UPDATE: 1,

Expand Down Expand Up @@ -97,7 +126,22 @@ module.exports.AuditLogActions = {
THREAD_UPDATE: 111,
THREAD_DELETE: 112,

APPLICATION_COMMAND_PERMISSION_UPDATE: 121
APPLICATION_COMMAND_PERMISSION_UPDATE: 121,

AUTO_MODERATION_RULE_CREATE: 140,
AUTO_MODERATION_RULE_UPDATE: 141,
AUTO_MODERATION_RULE_DELETE: 142,
AUTO_MODERATION_BLOCK_MESSAGE: 143,

CREATOR_MONETIZATION_REQUEST_CREATED: 150,
CREATOR_MONETIZATION_TERMS_ACCEPTED: 151,

ROLE_PROMPT_CREATE: 160,
ROLE_PROMPT_UPDATE: 161,
ROLE_PROMPT_DELETE: 162,

GUILD_HOME_FEATURE_ITEM: 171,
GUILD_HOME_REMOVE_ITEM: 172
};

module.exports.ButtonStyles = {
Expand Down Expand Up @@ -163,24 +207,42 @@ module.exports.GatewayOPCodes = {
};

module.exports.GuildFeatures = [
"ANIMATED_BANNER",
"ANIMATED_ICON",
"BANNER",
"COMMERCE",
"COMMUNITY",
"CREATOR_MONETIZABLE",
"CREATOR_MONETIZABLE_DISABLED",
"DISCOVERABLE",
"DISCOVERABLE_DISABLED",
"ENABLED_DISCOVERABLE_BEFORE",
"FEATURABLE",
"GUILD_HOME_TEST",
"HAS_DIRECTORY_ENTRY",
"HUB",
"INVITE_SPLASH",
"LINKED_TO_HUB",
"MEMBER_VERIFICATION_GATE_ENABLED",
"MONETIZATION_ENABLED",
"MORE_EMOJI",
"MORE_EMOJIS",
"MORE_STICKERS",
"NEWS",
"NEW_THREAD_PERMISSIONS",
"PARTNERED",
"PREVIEW_ENABLED",
"PREVIOUSLY_DISCOVERABLE",
"PRIVATE_THREADS",
"ROLE_ICONS",
"ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE",
"ROLE_SUBSCRIPTIONS_ENABLED",
"SEVEN_DAY_THREAD_ARCHIVE",
"TEXT_IN_VOICE_ENABLED",
"THREADS_ENABLED",
"THREADS_ENABLED_TESTING",
"THREE_DAY_THREAD_ARCHIVE",
"THREADS_ENABLED",
"TICKETED_EVENTS_ENABLED",
"VANITY_URL",
"VERIFIED",
Expand All @@ -205,6 +267,12 @@ module.exports.GuildNSFWLevels = {
AGE_RESTRICTED: 3
};

module.exports.HubTypes = {
DEFAULT: 0,
HIGH_SCHOOL: 1,
COLLEGE: 2
};

module.exports.ImageFormats = [
"jpg",
"jpeg",
Expand Down Expand Up @@ -266,7 +334,8 @@ module.exports.InteractionTypes = {
PING: 1,
APPLICATION_COMMAND: 2,
MESSAGE_COMPONENT: 3,
APPLICATION_COMMAND_AUTOCOMPLETE: 4
APPLICATION_COMMAND_AUTOCOMPLETE: 4,
MODAL_SUBMIT: 5
};

module.exports.InviteTargetTypes = {
Expand All @@ -279,34 +348,24 @@ module.exports.MFALevels = {
ELEVATED: 1
};

module.exports.MessageActivityFlags = {
INSTANCE: 1 << 0,
JOIN: 1 << 1,
SPECTATE: 1 << 2,
JOIN_REQUEST: 1 << 3,
SYNC: 1 << 4,
PLAY: 1 << 5,
PARTY_PRIVACY_FRIENDS: 1 << 6,
PARTY_PRIVACY_VOICE_CHANNEL: 1 << 7,
EMBEDDED: 1 << 8
};

module.exports.MessageActivityTypes = {
JOIN: 1,
SPECTATE: 2,
LISTEN: 3,
WATCH: 4,
JOIN_REQUEST: 5
};

module.exports.MessageFlags = {
CROSSPOSTED: 1 << 0,
IS_CROSSPOST: 1 << 1,
SUPPRESS_EMBEDS: 1 << 2,
SOURCE_MESSAGE_DELETED: 1 << 3,
URGENT: 1 << 4,
HAS_THREAD: 1 << 5,
EPHEMERAL: 1 << 6,
LOADING: 1 << 7
CROSSPOSTED: 1 << 0,
IS_CROSSPOST: 1 << 1,
SUPPRESS_EMBEDS: 1 << 2,
SOURCE_MESSAGE_DELETED: 1 << 3,
URGENT: 1 << 4,
HAS_THREAD: 1 << 5,
EPHEMERAL: 1 << 6,
LOADING: 1 << 7,
FAILED_TO_MENTION_SOME_ROLES_IN_THREAD: 1 << 8
};

module.exports.MessageTypes = {
Expand All @@ -323,7 +382,7 @@ module.exports.MessageTypes = {
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2: 10,
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3: 11,
CHANNEL_FOLLOW_ADD: 12,

GUILD_STREAM: 13,
GUILD_DISCOVERY_DISQUALIFIED: 14,
GUILD_DISCOVERY_REQUALIFIED: 15,
GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING: 16,
Expand All @@ -333,7 +392,14 @@ module.exports.MessageTypes = {
CHAT_INPUT_COMMAND: 20,
THREAD_STARTER_MESSAGE: 21,
GUILD_INVITE_REMINDER: 22,
CONTEXT_MENU_COMMAND: 23
CONTEXT_MENU_COMMAND: 23,
AUTO_MODERATION_ACTION: 24,
ROLE_SUBSCRIPTION_PURCHASE: 25
};

module.exports.MembershipState = {
INVITED: 1,
ACCEPTED: 2
};

module.exports.PermissionOverwriteTypes = {
Expand Down Expand Up @@ -465,10 +531,12 @@ module.exports.StickerTypes = {
};

module.exports.SystemChannelFlags = {
SUPPRESS_JOIN_NOTIFICATIONS: 1 << 0,
SUPPRESS_PREMIUM_SUBSCRIPTIONS: 1 << 1,
SUPPRESS_GUILD_REMINDER_NOTIFICATIONS: 1 << 2,
SUPPRESS_JOIN_NOTIFICATION_REPLIES : 1 << 3
SUPPRESS_JOIN_NOTIFICATIONS: 1 << 0,
SUPPRESS_PREMIUM_SUBSCRIPTIONS: 1 << 1,
SUPPRESS_GUILD_REMINDER_NOTIFICATIONS: 1 << 2,
SUPPRESS_JOIN_NOTIFICATION_REPLIES: 1 << 3,
SUPPRESS_ROLE_SUBSCRIPTION_PURCHASE_NOTIFICATIONS: 1 << 4,
SUPPRESS_ROLE_SUBSCRIPTION_PURCHASE_NOTIFICATION_REPLIES: 1 << 5
};

module.exports.SystemJoinMessages = [
Expand All @@ -487,6 +555,11 @@ module.exports.SystemJoinMessages = [
"Yay you made it, %user%!"
];

module.exports.TextComponentStyle = {
SMALL: 1,
PARAGRAPH: 2
};

module.exports.ThreadMemberFlags = {
HAS_INTERACTED: 1 << 0,
ALL_MESSAGES: 1 << 1,
Expand All @@ -510,7 +583,8 @@ module.exports.UserFlags = {
VERIFIED_BOT: 1 << 16,
VERIFIED_DEVELOPER: 1 << 17, EARLY_VERIFIED_BOT_DEVELOPER: 1 << 17, VERIFIED_BOT_DEVELOPER: 1 << 17,
CERTIFIED_MODERATOR: 1 << 18, DISCORD_CERTIFIED_MODERATOR: 1 << 18,
BOT_HTTP_INTERACTIONS: 1 << 19
BOT_HTTP_INTERACTIONS: 1 << 19,
SPAMMER: 1 << 20
};

module.exports.VerificationLevels = {
Expand Down
29 changes: 29 additions & 0 deletions lib/structures/CategoryChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,34 @@

const Collection = require("../util/Collection");
const GuildChannel = require("./GuildChannel");
const PermissionOverwrite = require("./PermissionOverwrite");

/**
* Represents a guild category channel. See GuildChannel for more properties and methods.
* @extends GuildChannel
* @prop {Collection<GuildChannel>} channels A collection of guild channels that are part of this category
* @prop {Collection<PermissionOverwrite>} permissionOverwrites Collection of PermissionOverwrites in this channel
* @prop {Number} position The position of the channel
*/
class CategoryChannel extends GuildChannel {
constructor(data, client) {
super(data, client);
this.update(data);
}

update(data) {
super.update(data);
if(data.permission_overwrites) {
this.permissionOverwrites = new Collection(PermissionOverwrite);
data.permission_overwrites.forEach((overwrite) => {
this.permissionOverwrites.add(overwrite);
});
}
if(data.position !== undefined) {
this.position = data.position;
}
}

get channels() {
const channels = new Collection(GuildChannel);
if(this.guild && this.guild.channels) {
Expand All @@ -20,6 +41,14 @@ class CategoryChannel extends GuildChannel {
}
return channels;
}

toJSON(props = []) {
return super.toJSON([
"permissionOverwrites",
"position",
...props
]);
}
}

module.exports = CategoryChannel;
Loading