mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 09:33:32 +01:00
Several improvements
- Rename Guild#updateChannelPositions -> setChannelPositions - Allow Guild#setChannelPositions to take ChannelResolvables - Prioritise ClientDataResolver#resolveChannel's string case - Minor cleanup
This commit is contained in:
@@ -117,9 +117,9 @@ class ClientDataResolver {
|
||||
*/
|
||||
resolveChannel(channel) {
|
||||
if (channel instanceof Channel) return channel;
|
||||
if (typeof channel === 'string') return this.client.channels.get(channel) || null;
|
||||
if (channel instanceof Message) return channel.channel;
|
||||
if (channel instanceof Guild) return channel.channels.get(channel.id) || null;
|
||||
if (typeof channel === 'string') return this.client.channels.get(channel) || null;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,7 @@ class GuildChannelsPositionUpdate extends Action {
|
||||
if (guild) {
|
||||
for (const partialChannel of data.channels) {
|
||||
const channel = guild.roles.get(partialChannel.id);
|
||||
if (channel) {
|
||||
channel.position = partialChannel.position;
|
||||
}
|
||||
if (channel) channel.position = partialChannel.position;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -770,7 +770,15 @@ class RESTMethods {
|
||||
}
|
||||
|
||||
updateChannelPositions(guildID, channels) {
|
||||
return this.rest.makeRequest('patch', Constants.Endpoints.guildChannels(guildID), true, channels).then(() =>
|
||||
const data = new Array(channels.length);
|
||||
for (let i = 0; i < channels.length; i++) {
|
||||
data[i] = {
|
||||
id: this.client.resolver.resolveChannelID(channels[i].channel),
|
||||
position: channels[i].position,
|
||||
};
|
||||
}
|
||||
|
||||
return this.rest.makeRequest('patch', Constants.Endpoints.guildChannels(guildID), true, data).then(() =>
|
||||
this.client.actions.GuildChannelsPositionUpdate.handle({
|
||||
guild_id: guildID,
|
||||
channels,
|
||||
|
||||
@@ -55,7 +55,7 @@ class AudioPlayer extends EventEmitter {
|
||||
* @type {?StreamDispatcher}
|
||||
*/
|
||||
get currentDispatcher() {
|
||||
return (this.streams.last() || {}).dispatcher;
|
||||
return this.streams.size > 0 ? this.streams.last().dispatcher || null : null;
|
||||
}
|
||||
|
||||
destroy() {
|
||||
|
||||
Reference in New Issue
Block a user