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(editChannelPositions): add support for endpoint #1328

Merged
merged 18 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
8 changes: 8 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,12 @@ declare namespace Eris {
channel_id: string;
webhook_id: string;
}
interface ChannelPosition {
id: string;
position: number;
lockPermissions?: boolean;
parentID?: string;
}
interface CreateChannelOptions {
bitrate?: number;
nsfw?: boolean;
Expand Down Expand Up @@ -2282,6 +2288,7 @@ declare namespace Eris {
editCommand(commandID: string, command: ApplicationCommandStructure): Promise<ApplicationCommand>;
editCommandPermissions(guildID: string, commandID: string, permissions: ApplicationCommandPermissions[]): Promise<GuildApplicationCommandPermissions>;
editGuild(guildID: string, options: GuildOptions, reason?: string): Promise<Guild>;
editGuildChannelPositions(guildID: string, channelPositions: ChannelPosition[]): Promise<void>;
editGuildCommand(guildID: string, commandID: string, command: ApplicationCommandStructure): Promise<ApplicationCommand>;
editGuildDiscovery(guildID: string, options?: DiscoveryOptions): Promise<DiscoveryMetadata>;
editGuildEmoji(
Expand Down Expand Up @@ -2711,6 +2718,7 @@ declare namespace Eris {
dynamicSplashURL(format?: ImageFormat, size?: number): string | null;
edit(options: GuildOptions, reason?: string): Promise<Guild>;
editCommand(commandID: string, command: ApplicationCommandStructure): Promise<ApplicationCommand>;
editChannelPositions(channelPositions: ChannelPosition[]): Promise<void>;
editCommandPermissions(permissions: ApplicationCommandPermissions[]): Promise<GuildApplicationCommandPermissions[]>;
editDiscovery(options?: DiscoveryOptions): Promise<DiscoveryMetadata>;
editEmoji(emojiID: string, options: { name: string; roles?: string[] }, reason?: string): Promise<Emoji>;
Expand Down
22 changes: 22 additions & 0 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,28 @@ class Client extends EventEmitter {
}).then((guild) => new Guild(guild, this));
}

/**
* Edit guild channels' positions. Note that channel position numbers are lowest on top and highest at the bottom.
xaxim marked this conversation as resolved.
Show resolved Hide resolved
* @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)
xaxim marked this conversation as resolved.
Show resolved Hide resolved
* @arg {String} ChannelPosition[].id The ID of the channel
* @arg {Number} ChannelPosition[].position The new position of the channel
* @arg {Boolean} [ChannelPosition[].lockPermissions] Whether to sync the permissions with the new parent if moving to a new category
* @arg {String} [ChannelPosition[].parentID] The new parent ID (category channel) for the channel that is moved (only one channel can change category per request)
xaxim marked this conversation as resolved.
Show resolved Hide resolved
* @returns {Promise}
*/
editGuildChannelPositions(guildID, channelPositions) {
const body = channelPositions.map((channelPosition) => {
return {
id: channelPosition.id,
position: channelPosition.position,
lock_permissions: channelPosition.lockPermissions,
parent_id: channelPosition.parentID
};
});
return this.requestHandler.request("PATCH", Endpoints.GUILD_CHANNELS(guildID), true, body);
}

/**
* Edit a guild application command
* @arg {String} guildID The guild id
Expand Down
13 changes: 13 additions & 0 deletions lib/structures/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,19 @@ class Guild extends Base {
return this._client.editGuild.call(this._client, this.id, options, reason);
}

/**
* Edit guild channels' positions. Note that channel position numbers are lowest on top and highest at the bottom.
* @arg {Array<Object>} channelPositions An array of [ChannelPosition] (https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions)
* @arg {String} ChannelPosition[].id The ID of the channel
* @arg {Number} ChannelPosition[].position The new position of the channel
* @arg {Boolean} [ChannelPosition[].lockPermissions] Whether to sync the permissions with the new parent if moving to a new category
* @arg {String} [ChannelPosition[].parentID] The new parent ID (category channel) for the channel that is moved (only one channel can change category per request)
xaxim marked this conversation as resolved.
Show resolved Hide resolved
* @returns {Promise}
*/
editChannelPositions(channelPositions) {
return this._client.editChannelPositions.call(this._client, this.id, channelPositions);
}

/**
* Edit a guild application command
* @arg {String} commandID The command id
Expand Down