generated at
ChannelManager.add(channel,guild,cache = true) の動作メモ
channelManager.add(channel,guild,cache = true)
this.cache にある
cache が true
更新
guild が truthy
guildChannelManager.add() を呼び出す
this.cache にない
Channel.create(this.client, data, guild);
cache が true ならば this.cache に登録
javascript
add(data, guild, cache = true) { const existing = this.cache.get(data.id); if (existing) { if (existing._patch && cache) existing._patch(data); if (guild) guild.channels.add(existing); return existing; } const channel = Channel.create(this.client, data, guild); if (!channel) { this.client.emit(Events.DEBUG, `Failed to find guild, or unknown type for channel ${data.id} ${data.type}`); return null; } if (cache) this.cache.set(channel.id, channel); return channel; }

guildChannelManager.add()
あれば無視して、なければ追加

Channel.create()
対象がGuildChannelではない
typeに基づいて適当にインスタンスが作られる
対象がGuildChannel
各種チャンネルが switch で作られる
GuildChannel._patch() がおそらく呼ばれる(おそらくというのは上書きされる可能性が0ではないから)
デフォルトでは各クラスオーバーライドしているが super._patch() している
特に変な副作用はない
Structures を用いた拡張はここで反映される。