mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
make positions for channels and roles nicer (#1211)
* make role calculated position nicer * make channels sortable in a nice way too * stupid git web rebase editor * Update Guild.js * Update Guild.js * Update Guild.js * Update Guild.js * Update RESTMethods.js
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
const Action = require('./Action');
|
||||
|
||||
class GuildChannelsPositionUpdate extends Action {
|
||||
handle(data) {
|
||||
const client = this.client;
|
||||
|
||||
const guild = client.guilds.get(data.guild_id);
|
||||
if (guild) {
|
||||
for (const partialChannel of data.channels) {
|
||||
const channel = guild.roles.get(partialChannel.id);
|
||||
if (channel) channel.position = partialChannel.position;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
guild,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = GuildChannelsPositionUpdate;
|
||||
const Action = require('./Action');
|
||||
|
||||
class GuildChannelsPositionUpdate extends Action {
|
||||
handle(data) {
|
||||
const client = this.client;
|
||||
|
||||
const guild = client.guilds.get(data.guild_id);
|
||||
if (guild) {
|
||||
for (const partialChannel of data.channels) {
|
||||
const channel = guild.channels.get(partialChannel.id);
|
||||
if (channel) channel.position = partialChannel.position;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
guild,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = GuildChannelsPositionUpdate;
|
||||
|
||||
@@ -8,9 +8,7 @@ class GuildRolesPositionUpdate extends Action {
|
||||
if (guild) {
|
||||
for (const partialRole of data.roles) {
|
||||
const role = guild.roles.get(partialRole.id);
|
||||
if (role) {
|
||||
role.position = partialRole.position;
|
||||
}
|
||||
if (role) role.position = partialRole.position;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -805,6 +805,15 @@ class RESTMethods {
|
||||
);
|
||||
}
|
||||
|
||||
setChannelPositions(guildID, channels) {
|
||||
return this.rest.makeRequest('patch', Endpoints.Guild(guildID).channels, true, channels).then(() =>
|
||||
this.client.actions.GuildChannelsPositionUpdate.handle({
|
||||
guild_id: guildID,
|
||||
channels,
|
||||
}).guild
|
||||
);
|
||||
}
|
||||
|
||||
addMessageReaction(message, emoji) {
|
||||
return this.rest.makeRequest(
|
||||
'put', Endpoints.Message(message).Reaction(emoji).User('@me'), true
|
||||
|
||||
Reference in New Issue
Block a user