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

feat: v0.1.3 backports #81

Merged
merged 22 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
cbc688e
feat(Constants): add useExternalSounds permission (#76)
TTtie May 30, 2023
4dc7dfb
feat: unique username system support (#70)
TTtie Jun 18, 2023
04c640a
feat: add port option to rest options (#78)
nazmigorkem Jul 1, 2023
580a22a
feat: add headers to REST options (#79)
nazmigorkem Jul 7, 2023
93acefb
types: RequestHandlerOptions#port should be a number (#80)
TTtie Jul 7, 2023
e37ec7d
docs(Client): remove missing options.maxShards option (#82)
mistval Jul 9, 2023
97bfe9e
types(PartialEmoji): make `id` optional (#83)
nazmigorkem Jul 10, 2023
bd07fd5
feat: add `defaultForumLayout` to createChannel() (#84)
TTtie Jul 14, 2023
e260ed5
feat: support role flags (#85)
TTtie Jul 15, 2023
f66d8e6
feat(Client): support `withCounts` parameter in getRESTGuilds() (#88)
TTtie Jul 15, 2023
20fc3a4
feat: support onboarding updates (#69)
TTtie Jul 18, 2023
816c600
feat: support attachment flags (#86)
TTtie Jul 18, 2023
1f88156
fix: #client -> _client
TTtie Jul 18, 2023
604a9ef
types(Client): make `editChannelOptions()` channel position optional …
TTtie Jul 18, 2023
221d1cc
feat: support `message_author_id` on uncached `MESSAGE_REACTION_ADD` …
TTtie Jul 18, 2023
6b2c3bf
refactor: don't call update() multiple times in the prototype chain (…
TTtie Jul 27, 2023
51c8064
fix(types): allow attachment command options in createCommand() and c…
TTtie Jul 30, 2023
8f2fe05
feat: add `Client#getApplication()` (#90)
TTtie Jul 30, 2023
cce0a38
fix(types): add ModalSubmitInteraction to AnyInteractionGateway (#97)
MertBhey Aug 3, 2023
e108cc7
types: correct gateway/REST versions in Constants interface (#98)
TTtie Aug 3, 2023
6d19a67
fix(Attachment): include `flags` in toJSON() output (#99)
TTtie Aug 8, 2023
1a1384c
feat: support GUILD_MEDIA channels (#96)
TTtie Aug 8, 2023
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
1 change: 1 addition & 0 deletions esm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const {
GuildTemplate,
Interaction,
Invite,
MediaChannel,
Member,
Message,
ModalSubmitInteraction,
Expand Down
92 changes: 76 additions & 16 deletions index.d.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Dysnomia.GuildScheduledEvent = require("./lib/structures/GuildScheduledEvent");
Dysnomia.GuildTemplate = require("./lib/structures/GuildTemplate");
Dysnomia.Interaction = require("./lib/structures/Interaction");
Dysnomia.Invite = require("./lib/structures/Invite");
Dysnomia.MediaChannel = require("./lib/structures/MediaChannel");
Dysnomia.Member = require("./lib/structures/Member");
Dysnomia.Message = require("./lib/structures/Message");
Dysnomia.ModalSubmitInteraction = require("./lib/structures/ModalSubmitInteraction.js");
Expand Down
41 changes: 33 additions & 8 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ class Client extends EventEmitter {
* @arg {Number | String} [options.gateway.maxShards=1] The total number of shards you want to run. If "auto" Dysnomia will use Discord's recommended shard count.
* @arg {Function} [options.gateway.reconnectDelay] A function which returns how long the bot should wait until reconnecting to Discord.
* @arg {Boolean} [options.gateway.seedVoiceConnections=false] Whether to populate bot.voiceConnections with existing connections the bot account has during startup. Note that this will disconnect connections from other bot sessions
* @arg {Number | String} [options.maxShards=1] The total number of shards you want to run. If "auto" Dysnomia will use Discord's recommended shard count. This option has been moved under `options.gateway`
* @arg {Number} [options.messageLimit=100] The maximum size of a channel message cache
* @arg {Boolean} [options.opusOnly=false] Whether to suppress the Opus encoder not found error or not
* @arg {Object} [options.rest] Options for the REST request handler
Expand All @@ -104,6 +103,8 @@ class Client extends EventEmitter {
* @arg {String} [options.rest.domain="discord.com"] The domain to use for API requests
* @arg {Boolean} [options.rest.https=true] Whether to make requests to the Discord API over HTTPS (true) or HTTP (false)
* @arg {Number} [options.rest.latencyThreshold=30000] The average request latency at which Dysnomia will start emitting latency errors
* @arg {Number} [options.rest.port] The port to use for API requests. Defaults to 443 (HTTPS) or 80 (HTTP)
* @arg {Object} [options.rest.headers] Headers to be appended in REST requests
* @arg {Number} [options.rest.ratelimiterOffset=0] A number of milliseconds to offset the ratelimit timing calculations by
* @arg {Number} [options.rest.requestTimeout=15000] A number of milliseconds before REST requests are considered timed out
* @arg {Boolean} [options.restMode=false] Whether to enable getting objects over REST. Even with this option enabled, it is recommended that you check the cache first before using REST
Expand Down Expand Up @@ -418,6 +419,7 @@ class Client extends EventEmitter {
* @arg {Array<Object>} [options.availableTags] Available tags for a forum channel
* @arg {Number} [options.bitrate] The bitrate of the channel (voice channels only)
* @arg {Number} [options.defaultAutoArchiveDuration] The default duration of newly created threads in minutes to automatically archive the thread after inactivity (60, 1440, 4320, 10080)
* @arg {Number} [options.defaultForumLayout] The default forum layout view used to display forum posts
* @arg {Object} [options.defaultReactionEmoji] The emoji to show as the reaction button (forum channels only)
* @arg {Object} [options.defaultSortOrder] The default thread sorting order
* @arg {Boolean} [options.nsfw] The nsfw status of the channel
Expand Down Expand Up @@ -445,6 +447,7 @@ class Client extends EventEmitter {
})),
bitrate: options.bitrate,
default_auto_archive_duration: options.defaultAutoArchiveDuration,
default_forum_layout: options.defaultForumLayout,
default_reaction_emoji: options.defaultReactionEmoji && {
emoji_id: options.defaultReactionEmoji.emojiID,
emoji_name: options.defaultReactionEmoji.emojiName
Expand Down Expand Up @@ -862,9 +865,9 @@ class Client extends EventEmitter {
* @arg {String} channelID The ID of the channel
* @arg {Object} options The thread options
* @arg {Number} [options.autoArchiveDuration] Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080
* @arg {Array<String>} [options.appliedTags] The tags to apply to the thread (available only for threads created in a `GUILD_FORUM` channel)
* @arg {Array<String>} [options.appliedTags] The tags to apply to the thread (available only in threads in thread-only channels)
* @arg {Boolean} [options.invitable] Whether non-moderators can add other non-moderators to the thread (private threads only)
* @arg {Object} [options.message] The message to attach to the thread (set only if creating a thread in a `GUILD_FORUM` channel)
* @arg {Object} [options.message] The message to attach to the thread (set only if creating a thread in a thread-only channel)
* @arg {Object} [options.message.allowedMentions] A list of mentions to allow (overrides default)
* @arg {Boolean} [options.message.allowedMentions.everyone] Whether or not to allow @everyone/@here.
* @arg {Boolean | Array<String>} [options.message.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
Expand Down Expand Up @@ -1247,7 +1250,7 @@ class Client extends EventEmitter {
* @arg {String} channelID The ID of the channel
* @arg {Object} options The properties to edit
* @arg {Boolean} [options.archived] The archive status of the channel (thread channels only)
* @arg {Array<String>} [options.appliedTags] An array of applied tag IDs for the thread (available in `GUILD_FORUM` threads only)
* @arg {Array<String>} [options.appliedTags] An array of applied tag IDs for the thread (available only in threads in thread-only channels)
* @arg {Number} [options.autoArchiveDuration] The duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080 (thread channels only)
* @arg {Array<Object>} [options.availableTags] Available tags for a forum channel
* @arg {Number} [options.bitrate] The bitrate of the channel (guild voice channels only)
Expand Down Expand Up @@ -1378,7 +1381,7 @@ class Client extends EventEmitter {
* @arg {String} guildID The ID of the guild
* @arg {Array<Object>} channelPositions An array of [ChannelPosition](https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions)
* @arg {String} channelPositions[].id The ID of the channel
* @arg {Number} channelPositions[].position The new position of the channel
* @arg {Number} [channelPositions[].position] The new position of the channel
* @arg {Boolean} [channelPositions[].lockPermissions] Whether to sync the channel's permissions with the new parent, if changing parents
* @arg {String} [channelPositions[].parentID] The new parent ID (category channel) for the channel that is moved. For each request, only one channel can change parents
* @returns {Promise}
Expand Down Expand Up @@ -1587,6 +1590,17 @@ class Client extends EventEmitter {
return this.requestHandler.request("POST", Endpoints.GUILD_MFA_LEVEL(guildID), true, options).then((data) => data.level);
}

/**
* Edits the onboarding flow of a guild, shown to new members
* @param {String} guildID The ID of the guild
* @param {Object} options The [guild onboarding](https://discord.com/developers/docs/resources/guild#guild-onboarding-object) object
* @param {String} [options.reason] The reason to be displayed in audit logs
* @returns {Promise<Object>} Resolves with the [guild onboarding object](https://discord.com/developers/docs/resources/guild#guild-onboarding-object)
*/
editGuildOnboarding(guildID, options) {
return this.requestHandler.request("PUT", Endpoints.GUILD_ONBOARDING(guildID), true, options);
}

/**
* Edit a guild scheduled event
* @arg {String} guildID The guild ID where the event will be edited
Expand Down Expand Up @@ -2109,6 +2123,15 @@ class Client extends EventEmitter {
});
}

/**
* Get data on the application associated with this bot account.
* The returned data is similar to the `getOAuthApplication()` method with additional information.
* @returns {Promise<Object>} The bot's application data. Refer to [Discord's Documentation](https://discord.com/developers/docs/resources/application#application-object) for object structure
*/
getApplication() {
return this.requestHandler.request("GET", Endpoints.APPLICATION, true);
}

/**
* Get all archived threads in a channel
* @arg {String} channelID The ID of the channel
Expand Down Expand Up @@ -2668,8 +2691,8 @@ class Client extends EventEmitter {
}

/**
* Get data on the bot's OAuth2 application
* @returns {Promise<Object>} The bot's application data. Refer to [Discord's Documentation](https://discord.com/developers/docs/topics/oauth2#get-current-application-information) for object structure
* Get data on the bot's OAuth2 application. See also `getApplication()` for more info.
* @returns {Promise<Object>} The bot's application data. Refer to [Discord's Documentation](https://discord.com/developers/docs/resources/application#application-object) for object structure
*/
getOAuthApplication() {
return this.requestHandler.request("GET", Endpoints.OAUTH2_APPLICATION, true);
Expand Down Expand Up @@ -2810,14 +2833,16 @@ class Client extends EventEmitter {
* @arg {Object} [options] Options for the request.
* @arg {String} [options.after] The highest guild ID of the previous page
* @arg {String} [options.before] The lowest guild ID of the next page
* @arg {Number} [options.limit=100] The max number of guilds to get (1 to 1000)
* @arg {Number} [options.limit=200] The max number of guilds to get (1 to 200)
* @arg {Boolean} [options.withCounts] Whether the guild objects will have approximateMemberCount and approximatePresenceCount
* @returns {Promise<Array<Guild>>}
*/
getRESTGuilds(options = {}) {
// TODO type
if(!this.options.restMode) {
return Promise.reject(new Error("Dysnomia REST mode is not enabled"));
}
options.with_counts = options.withCounts;
return this.requestHandler.request("GET", Endpoints.USER_GUILDS("@me"), true, options).then((guilds) => guilds.map((guild) => new Guild(guild, this)));
}

Expand Down
23 changes: 20 additions & 3 deletions lib/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ module.exports.ApplicationFlags = {
APPLICATION_COMMAND_BADGE: 1 << 23
};

module.exports.AttachmentFlags = {
IS_REMIX: 1 << 2
};

module.exports.AuditLogActions = {
GUILD_UPDATE: 1,

Expand Down Expand Up @@ -181,8 +185,9 @@ module.exports.ButtonStyles = {
};

module.exports.ChannelFlags = {
PINNED: 1 << 1,
REQUIRE_TAG: 1 << 4
PINNED: 1 << 1,
REQUIRE_TAG: 1 << 4,
HIDE_MEDIA_DOWNLOAD_OPTIONS: 1 << 15
};

module.exports.ChannelTypes = {
Expand All @@ -198,7 +203,8 @@ module.exports.ChannelTypes = {
PRIVATE_THREAD: 12, GUILD_PRIVATE_THREAD: 12, // [DEPRECATED]
GUILD_STAGE_VOICE: 13,
GUILD_DIRECTORY: 14,
GUILD_FORUM: 15
GUILD_FORUM: 15,
GUILD_MEDIA: 16
};

module.exports.ComponentTypes = {
Expand Down Expand Up @@ -451,6 +457,11 @@ module.exports.MembershipState = {
ACCEPTED: 2
};

module.exports.OnboardingModes = {
ONBOARDING_DEFAULT: 0,
ONBOARDING_ADVANCED: 1
};

module.exports.OnboardingPromptTypes = {
MULTIPLE_CHOICE: 0,
DROPDOWN: 1
Expand Down Expand Up @@ -505,6 +516,7 @@ const Permissions = {
moderateMembers: 1n << 40n,
viewCreatorMonetizationAnalytics: 1n << 41n,
useSoundboard: 1n << 42n,
useExternalSounds: 1n << 45n,
sendVoiceMessages: 1n << 46n
};
Permissions.allGuild = Permissions.kickMembers
Expand Down Expand Up @@ -557,6 +569,7 @@ Permissions.allVoice = Permissions.createInstantInvite
| Permissions.manageRoles
| Permissions.voiceRequestToSpeak
| Permissions.startEmbeddedActivities
| Permissions.useExternalSounds
| Permissions.useSoundboard;
Permissions.all = Permissions.allGuild | Permissions.allText | Permissions.allVoice;
module.exports.Permissions = Permissions;
Expand Down Expand Up @@ -603,6 +616,10 @@ module.exports.RoleConnectionMetadataTypes = {
BOOLEAN_NOT_EQUAL: 8
};

module.exports.RoleFlags = {
IN_PROMPT: 1 << 0
};

module.exports.StageInstancePrivacyLevel = {
PUBLIC: 1, // [DEPRECATED]
GUILD_ONLY: 2
Expand Down
Loading